This commit is contained in:
unknown 2015-11-22 12:55:23 -05:00
parent fa60e55f57
commit a1b88bdd5f
1290 changed files with 98382 additions and 304844 deletions

View File

@ -25,7 +25,7 @@
<ItemDefinitionGroup> <ItemDefinitionGroup>
<ClCompile> <ClCompile>
<PreprocessorDefinitions>WIN32;_WIN32;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>WIN32;_WIN32;_WINDOWS;WIN32_LEAN_AND_MEAN;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile> </ClCompile>
</ItemDefinitionGroup> </ItemDefinitionGroup>

View File

@ -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. ",
" ",
" "};

View File

@ -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# ",
" ",
" ",
" ",
" "};

View File

@ -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++ // Purpose: wrapper around the real wx/setup.h for Visual C++
// Author: Vadim Zeitlin // Author: Vadim Zeitlin
// Modified by: // Modified by:
// Created: 2004-12-12 // Created: 2004-12-12
// RCS-ID: $Id: setup.h 43687 2006-11-27 15:03:59Z VZ $
// Copyright: (c) 2004 Vadim Zeitlin <vadim@wxwindows.org> // Copyright: (c) 2004 Vadim Zeitlin <vadim@wxwindows.org>
// Licence: wxWindows licence // 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 // VC++ IDE predefines _DEBUG and _UNICODE for the new projects itself, but
// the other symbols (WXUSINGDLL, __WXUNIVERSAL__, ...) should be defined // the other symbols (WXUSINGDLL, __WXUNIVERSAL__, ...) should be defined
// explicitly! // explicitly!
#include "wx/version.h" #ifdef _MSC_VER
#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 _UNICODE #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 #ifdef WXUSINGDLL
#define wxLIB_SUBDIR \ #ifdef _DEBUG
wxCONCAT4(wxCOMPILER_PREFIX, wxARCH_SUFFIX, _dll, wxCFG) #include "../../../lib/vc_dll/mswud/wx/setup.h"
#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 #else
#define wxTOOLKIT_PREFIX msw #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 // 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 #endif
#define wxSETUPH_PATH_STR wxSTRINGIZE(wxSETUPH_PATH) #ifdef _DEBUG
#pragma comment(lib,"wxbase28ud")
#include wxSETUPH_PATH_STR #pragma comment(lib,"wxbase28ud_net")
#pragma comment(lib,"wxbase28ud_xml")
#if wxUSE_REGEX
// the library names depend on the build, these macro builds the correct #pragma comment(lib,"wxregexud")
// 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 #endif
#if wxUSE_GUI #if wxUSE_GUI
#if wxUSE_XML && !defined(wxNO_EXPAT_LIB) && !defined(WXUSINGDLL) #if wxUSE_XML
#pragma comment(lib, wx3RD_PARTY_LIB_NAME("expat")) #pragma comment(lib,"wxexpatd")
#endif #endif
#if wxUSE_LIBJPEG && !defined(wxNO_JPEG_LIB) && !defined(WXUSINGDLL) #if wxUSE_LIBJPEG
#pragma comment(lib, wx3RD_PARTY_LIB_NAME("jpeg")) #pragma comment(lib,"wxjpegd")
#endif #endif
#if wxUSE_LIBPNG && !defined(wxNO_PNG_LIB) && !defined(WXUSINGDLL) #if wxUSE_LIBPNG
#pragma comment(lib, wx3RD_PARTY_LIB_NAME("png")) #pragma comment(lib,"wxpngd")
#endif #endif
#if wxUSE_LIBTIFF && !defined(wxNO_TIFF_LIB) && !defined(WXUSINGDLL) #if wxUSE_LIBTIFF
#pragma comment(lib, wx3RD_PARTY_LIB_NAME("tiff")) #pragma comment(lib,"wxtiffd")
#endif #endif
#if wxUSE_ZLIB && !defined(wxNO_ZLIB_LIB) && !defined(WXUSINGDLL) #if wxUSE_ZLIB
#pragma comment(lib, wx3RD_PARTY_LIB_NAME("zlib")) #pragma comment(lib,"wxzlibd")
#endif #endif
#pragma comment(lib,"wxmsw28ud_adv")
#pragma comment(lib, wxTOOLKIT_LIB_NAME("core")) #pragma comment(lib,"wxmsw28ud_core")
#pragma comment(lib,"wxmsw28ud_html")
#ifndef wxNO_ADV_LIB #if wxUSE_GLCANVAS
#pragma comment(lib, wxTOOLKIT_LIB_NAME("adv")) #pragma comment(lib,"wxmsw28ud_gl")
#endif #endif
#if wxUSE_DEBUGREPORT
#if wxUSE_HTML && !defined(wxNO_HTML_LIB) #pragma comment(lib,"wxmsw28ud_qa")
#pragma comment(lib, wxTOOLKIT_LIB_NAME("html"))
#endif #endif
#if wxUSE_GLCANVAS && !defined(wxNO_GL_LIB) #if wxUSE_XRC
#pragma comment(lib, wxTOOLKIT_LIB_NAME("gl")) #pragma comment(lib,"wxmsw28ud_xrc")
#endif #endif
#if wxUSE_DEBUGREPORT && !defined(wxNO_QA_LIB) #if wxUSE_AUI
#pragma comment(lib, wxTOOLKIT_LIB_NAME("qa")) #pragma comment(lib,"wxmsw28ud_aui")
#endif #endif
#if wxUSE_XRC && !defined(wxNO_XRC_LIB) #if wxUSE_RICHTEXT
#pragma comment(lib, wxTOOLKIT_LIB_NAME("xrc")) #pragma comment(lib,"wxmsw28ud_richtext")
#endif #endif
#if wxUSE_AUI && !defined(wxNO_AUI_LIB) #if wxUSE_MEDIACTRL
#pragma comment(lib, wxTOOLKIT_LIB_NAME("aui")) #pragma comment(lib,"wxmsw28ud_media")
#endif #endif
#if wxUSE_PROPGRID && !defined(wxNO_PROPGRID_LIB) #if wxUSE_ODBC
#pragma comment(lib, wxTOOLKIT_LIB_NAME("propgrid")) #pragma comment(lib,"wxbase28ud_odbc")
#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"))
#endif
#endif
#if wxUSE_WEBVIEW && !defined(wxNO_WEBVIEW_LIB)
#pragma comment(lib, wxTOOLKIT_LIB_NAME("webview"))
#endif #endif
#endif // wxUSE_GUI #endif // wxUSE_GUI
#else // release
#pragma comment(lib,"wxbase28u")
#ifndef WXUSINGDLL #pragma comment(lib,"wxbase28u_net")
// Make sure all required system libraries are added to the linker too when #pragma comment(lib,"wxbase28u_xml")
// using static libraries. #if wxUSE_REGEX
#pragma comment(lib, "kernel32") #pragma comment(lib,"wxregexu")
#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 #endif
#ifdef __WXGTK__ #if wxUSE_GUI
#pragma comment(lib, "gtk-win32-2.0.lib") #if wxUSE_XML
#pragma comment(lib, "gdk-win32-2.0.lib") #pragma comment(lib,"wxexpat")
#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
#endif // !WXUSINGDLL #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

View File

@ -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 <vadim@wxwindows.org>
// 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_

View File

@ -4,6 +4,7 @@
// Author: Julian Smart, Robert Roebling, Vadim Zeitlin // Author: Julian Smart, Robert Roebling, Vadim Zeitlin
// Modified by: // Modified by:
// Created: 31.05.01 (extracted from other files) // 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 // Copyright: (c) wxWidgets team
// Licence: wxWindows licence // Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
@ -26,25 +27,24 @@ class WXDLLIMPEXP_FWD_CORE wxKeyEvent;
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// wxAcceleratorEntry flags // wxAcceleratorEntry flags
enum wxAcceleratorEntryFlags enum
{ {
wxACCEL_NORMAL = 0x0000, // no modifiers wxACCEL_NORMAL = 0x0000, // no modifiers
wxACCEL_ALT = 0x0001, // hold Alt key down wxACCEL_ALT = 0x0001, // hold Alt key down
wxACCEL_CTRL = 0x0002, // hold Ctrl key down wxACCEL_CTRL = 0x0002, // hold Ctrl key down
wxACCEL_SHIFT = 0x0004, // hold Shift key down wxACCEL_SHIFT = 0x0004, // hold Shift key down
#if defined(__WXMAC__) || defined(__WXCOCOA__) #if defined(__WXMAC__) || defined(__WXCOCOA__)
wxACCEL_RAW_CTRL= 0x0008, // wxACCEL_CMD = 0x0008 // Command key on OS X
#else #else
wxACCEL_RAW_CTRL= wxACCEL_CTRL,
#endif
wxACCEL_CMD = wxACCEL_CTRL wxACCEL_CMD = wxACCEL_CTRL
#endif
}; };
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// an entry in wxAcceleratorTable corresponds to one accelerator // an entry in wxAcceleratorTable corresponds to one accelerator
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxAcceleratorEntry class WXDLLEXPORT wxAcceleratorEntry
{ {
public: public:
wxAcceleratorEntry(int flags = 0, int keyCode = 0, int cmd = 0, wxAcceleratorEntry(int flags = 0, int keyCode = 0, int cmd = 0,
@ -68,7 +68,6 @@ public:
wxAcceleratorEntry& operator=(const wxAcceleratorEntry& entry) 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; return *this;
} }
@ -116,13 +115,8 @@ public:
// returns a wxString for the this accelerator. // returns a wxString for the this accelerator.
// this function formats it using the <flags>-<keycode> format // this function formats it using the <flags>-<keycode> format
// where <flags> maybe a hyphen-separated list of "shift|alt|ctrl" // where <flags> maybe a hyphen-separed list of "shift|alt|ctrl"
wxString ToString() const { return AsPossiblyLocalizedString(true); } wxString ToString() const;
// 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); }
// returns true if the given string correctly initialized this object // returns true if the given string correctly initialized this object
// (i.e. if IsOk() returns true after this call) // (i.e. if IsOk() returns true after this call)
@ -130,8 +124,6 @@ public:
private: private:
wxString AsPossiblyLocalizedString(bool localized) const;
// common part of Create() and FromString() // common part of Create() and FromString()
static bool ParseAccel(const wxString& str, int *flags, int *keycode); static bool ParseAccel(const wxString& str, int *flags, int *keycode);
@ -163,14 +155,14 @@ private:
#elif defined(__WXGTK__) #elif defined(__WXGTK__)
#include "wx/gtk1/accel.h" #include "wx/gtk1/accel.h"
#elif defined(__WXMAC__) #elif defined(__WXMAC__)
#include "wx/osx/accel.h" #include "wx/mac/accel.h"
#elif defined(__WXCOCOA__) #elif defined(__WXCOCOA__)
#include "wx/generic/accel.h" #include "wx/generic/accel.h"
#elif defined(__WXPM__) #elif defined(__WXPM__)
#include "wx/os2/accel.h" #include "wx/os2/accel.h"
#endif #endif
extern WXDLLIMPEXP_DATA_CORE(wxAcceleratorTable) wxNullAcceleratorTable; extern WXDLLEXPORT_DATA(wxAcceleratorTable) wxNullAcceleratorTable;
#endif // wxUSE_ACCEL #endif // wxUSE_ACCEL

View File

@ -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_

View File

@ -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_

View File

@ -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_

View File

@ -1,9 +1,10 @@
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// Name: wx/afterstd.h // Name: include/wx/afterstd.h
// Purpose: #include after STL headers // Purpose: #include after STL headers
// Author: Vadim Zeitlin // Author: Vadim Zeitlin
// Modified by: // Modified by:
// Created: 07/07/03 // Created: 07/07/03
// RCS-ID: $Id: afterstd.h 61871 2009-09-09 22:29:51Z VZ $
// Copyright: (c) 2003 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr> // Copyright: (c) 2003 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
// Licence: wxWindows licence // Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
@ -12,7 +13,7 @@
See the comments in beforestd.h. See the comments in beforestd.h.
*/ */
#if defined(__WINDOWS__) #if defined(__WXMSW__)
#include "wx/msw/winundef.h" #include "wx/msw/winundef.h"
#endif #endif
@ -20,6 +21,13 @@
#if defined(__VISUALC__) && __VISUALC__ <= 1201 #if defined(__VISUALC__) && __VISUALC__ <= 1201
// MSVC 5 does not have this // MSVC 5 does not have this
#if _MSC_VER > 1100 #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) #pragma warning(pop)
#else #else
// 'expression' : signed/unsigned mismatch // 'expression' : signed/unsigned mismatch
@ -38,7 +46,26 @@
#endif #endif
#endif #endif
// see beforestd.h for explanation /*
#if defined(HAVE_VISIBILITY) && defined(HAVE_BROKEN_LIBSTDCXX_VISIBILITY) Redefine _T if we undefined it in wx/beforestd.h (see comment there about
#pragma GCC visibility pop why do we do it) and if we need it (we always do when building wx itself
#endif 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) */

View File

@ -2,6 +2,7 @@
// Name: wx/anidecod.h // Name: wx/anidecod.h
// Purpose: wxANIDecoder, ANI reader for wxImage and wxAnimation // Purpose: wxANIDecoder, ANI reader for wxImage and wxAnimation
// Author: Francesco Montorsi // Author: Francesco Montorsi
// CVS-ID: $Id: anidecod.h 45563 2007-04-21 18:17:50Z VZ $
// Copyright: (c) 2006 Francesco Montorsi // Copyright: (c) 2006 Francesco Montorsi
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
@ -11,7 +12,7 @@
#include "wx/defs.h" #include "wx/defs.h"
#if wxUSE_STREAMS && (wxUSE_ICO_CUR || wxUSE_GIF) #if wxUSE_STREAMS && wxUSE_ICO_CUR
#include "wx/stream.h" #include "wx/stream.h"
#include "wx/image.h" #include "wx/image.h"
@ -19,7 +20,7 @@
#include "wx/dynarray.h" #include "wx/dynarray.h"
class /*WXDLLIMPEXP_CORE*/ wxANIFrameInfo; // private implementation detail class /*WXDLLEXPORT*/ wxANIFrameInfo;
WX_DECLARE_EXPORTED_OBJARRAY(wxANIFrameInfo, wxANIFrameInfoArray); WX_DECLARE_EXPORTED_OBJARRAY(wxANIFrameInfo, wxANIFrameInfoArray);
WX_DECLARE_EXPORTED_OBJARRAY(wxImage, wxImageArray); WX_DECLARE_EXPORTED_OBJARRAY(wxImage, wxImageArray);
@ -28,7 +29,7 @@ WX_DECLARE_EXPORTED_OBJARRAY(wxImage, wxImageArray);
// wxANIDecoder class // wxANIDecoder class
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxANIDecoder : public wxAnimationDecoder class WXDLLEXPORT wxANIDecoder : public wxAnimationDecoder
{ {
public: public:
// constructor, destructor, etc. // constructor, destructor, etc.
@ -43,7 +44,7 @@ public:
virtual wxColour GetTransparentColour(unsigned int frame) const; virtual wxColour GetTransparentColour(unsigned int frame) const;
// implementation of wxAnimationDecoder's pure virtuals // implementation of wxAnimationDecoder's pure virtuals
virtual bool CanRead( wxInputStream& stream ) const;
virtual bool Load( wxInputStream& stream ); virtual bool Load( wxInputStream& stream );
bool ConvertToImage(unsigned int frame, wxImage *image) const; bool ConvertToImage(unsigned int frame, wxImage *image) const;
@ -54,10 +55,6 @@ public:
{ return wxANIMATION_TYPE_ANI; } { return wxANIMATION_TYPE_ANI; }
private: 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 // 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 // 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. // two frames: they are just a list of images to display sequentially.
@ -71,10 +68,10 @@ private:
static wxCURHandler sm_handler; 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 #endif // _WX_ANIDECOD_H

View File

@ -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_

View File

@ -2,6 +2,7 @@
// Name: wx/animdecod.h // Name: wx/animdecod.h
// Purpose: wxAnimationDecoder // Purpose: wxAnimationDecoder
// Author: Francesco Montorsi // Author: Francesco Montorsi
// CVS-ID: $Id: animdecod.h 49563 2007-10-31 20:46:21Z VZ $
// Copyright: (c) 2006 Francesco Montorsi // Copyright: (c) 2006 Francesco Montorsi
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
@ -15,9 +16,8 @@
#include "wx/colour.h" #include "wx/colour.h"
#include "wx/gdicmn.h" #include "wx/gdicmn.h"
#include "wx/log.h"
#include "wx/stream.h"
class WXDLLIMPEXP_FWD_BASE wxInputStream;
class WXDLLIMPEXP_FWD_CORE wxImage; class WXDLLIMPEXP_FWD_CORE wxImage;
/* /*
@ -30,15 +30,15 @@ class WXDLLIMPEXP_FWD_CORE wxImage;
wxAnimationDecoders always load an input stream using some optimized format wxAnimationDecoders always load an input stream using some optimized format
to store it which is format-depedent. This allows to store a (possibly big) 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 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. 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 3) wxAnimationDecoders can be used by a wxImageHandler to retrieve a frame
in wxImage format; the viceversa cannot be done. 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) 5) wxAnimationDecoders are directly used by wxAnimation (generic implementation)
as wxObjectRefData while they need to be 'wrapped' by a wxImageHandler for as wxObjectRefData while they need to be 'wrapped' by a wxImageHandler for
@ -84,37 +84,19 @@ enum wxAnimationType
// wxAnimationDecoder class // wxAnimationDecoder class
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxAnimationDecoder : public wxObjectRefData class WXDLLEXPORT wxAnimationDecoder : public wxObjectRefData
{ {
public: public:
wxAnimationDecoder() wxAnimationDecoder()
{ {
m_background = wxNullColour;
m_nFrames = 0; m_nFrames = 0;
} }
virtual ~wxAnimationDecoder() { }
virtual bool Load( wxInputStream& stream ) = 0; virtual bool Load( wxInputStream& stream ) = 0;
virtual bool CanRead( wxInputStream& stream ) const = 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 wxAnimationDecoder *Clone() const = 0; virtual wxAnimationDecoder *Clone() const = 0;
virtual wxAnimationType GetType() const = 0; virtual wxAnimationType GetType() const = 0;
@ -150,12 +132,6 @@ public:
unsigned int GetFrameCount() const { return m_nFrames; } unsigned int GetFrameCount() const { return m_nFrames; }
protected: 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; wxSize m_szAnimation;
unsigned int m_nFrames; unsigned int m_nFrames;
@ -164,7 +140,7 @@ protected:
wxColour m_background; wxColour m_background;
}; };
#endif // wxUSE_STREAMS
#endif // wxUSE_STREAM
#endif // _WX_ANIMDECOD_H #endif // _WX_ANIMDECOD_H

File diff suppressed because it is too large Load Diff

View File

@ -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_

View File

@ -1,139 +0,0 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/anystr.h
// Purpose: wxAnyStrPtr class declaration
// Author: Vadim Zeitlin
// Created: 2009-03-23
// Copyright: (c) 2008 Vadim Zeitlin <vadim@wxwidgets.org>
// 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_

View File

@ -5,6 +5,7 @@
// Author: Julian Smart // Author: Julian Smart
// Modified by: // Modified by:
// Created: 01/02/97 // Created: 01/02/97
// RCS-ID: $Id: app.h 51592 2008-02-08 08:17:41Z VZ $
// Copyright: (c) Julian Smart // Copyright: (c) Julian Smart
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
@ -17,29 +18,21 @@
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
#include "wx/event.h" // for the base class #include "wx/event.h" // for the base class
#include "wx/eventfilter.h" // (and another one)
#include "wx/build.h" #include "wx/build.h"
#include "wx/cmdargs.h" // for wxCmdLineArgsArray used by wxApp::argv
#include "wx/init.h" // we must declare wxEntry() #include "wx/init.h" // we must declare wxEntry()
#include "wx/intl.h" // for wxLayoutDirection #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 wxAppConsole;
class WXDLLIMPEXP_FWD_BASE wxAppTraits; class WXDLLIMPEXP_FWD_BASE wxAppTraits;
class WXDLLIMPEXP_FWD_BASE wxCmdLineParser; class WXDLLIMPEXP_FWD_BASE wxCmdLineParser;
class WXDLLIMPEXP_FWD_BASE wxEventLoopBase; class WXDLLIMPEXP_FWD_BASE wxLog;
class WXDLLIMPEXP_FWD_BASE wxMessageOutput; class WXDLLIMPEXP_FWD_BASE wxMessageOutput;
#if wxUSE_GUI #if wxUSE_GUI
class WXDLLIMPEXP_FWD_BASE wxEventLoop;
struct WXDLLIMPEXP_FWD_CORE wxVideoMode; struct WXDLLIMPEXP_FWD_CORE wxVideoMode;
class WXDLLIMPEXP_FWD_CORE wxWindow;
#endif #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 // typedefs
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@ -58,25 +51,15 @@ enum
}; };
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// global variables // wxAppConsole: wxApp for non-GUI applications
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// use of this list is strongly deprecated, use wxApp ScheduleForDestruction() class WXDLLIMPEXP_BASE wxAppConsole : public wxEvtHandler
// 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
{ {
public: public:
// ctor and dtor // ctor and dtor
wxAppConsoleBase(); wxAppConsole();
virtual ~wxAppConsoleBase(); virtual ~wxAppConsole();
// the virtual functions which may/must be overridden in the derived class // the virtual functions which may/must be overridden in the derived class
@ -98,28 +81,17 @@ public:
// class OnInit() to do it. // class OnInit() to do it.
virtual bool OnInit(); 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 // This is the replacement for the normal main(): all program work should
// be done here. When OnRun() returns, the programs starts shutting down. // be done here. When OnRun() returns, the programs starts shutting down.
virtual int OnRun(); virtual int OnRun() = 0;
// 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)) {}
// This is only called if OnInit() returned true so it's a good place to do // This is only called if OnInit() returned true so it's a good place to do
// any cleanup matching the initializations done there. // any cleanup matching the initializations done there.
virtual int OnExit(); 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 // This is the very last function called on wxApp object before it is
// destroyed. If you override it (instead of overriding OnExit() as usual) // destroyed. If you override it (instead of overriding OnExit() as usual)
// do not forget to call the base class version! // do not forget to call the base class version!
@ -145,20 +117,12 @@ public:
// be argv[0] // be argv[0]
// set/get the application name // 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; } 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 // set/get the app class name
wxString GetClassName() const { return m_className; } wxString GetClassName() const { return m_className; }
void SetClassName(const wxString& name) { m_className = name; } void SetClassName(const wxString& name) { m_className = name; }
@ -167,19 +131,6 @@ public:
const wxString& GetVendorName() const { return m_vendorName; } const wxString& GetVendorName() const { return m_vendorName; }
void SetVendorName(const wxString& name) { m_vendorName = name; } 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 // cmd line parsing stuff
// ---------------------- // ----------------------
@ -219,68 +170,40 @@ public:
// either should be configurable by the user (then he can change the // either should be configurable by the user (then he can change the
// default behaviour simply by overriding CreateTraits() and returning his // default behaviour simply by overriding CreateTraits() and returning his
// own traits object) or which is GUI/console dependent as then wxAppTraits // 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(); wxAppTraits *GetTraits();
// this function provides safer access to traits object than // the functions below shouldn't be used now that we have wxAppTraits
// wxTheApp->GetTraits() during startup or termination when the global #if WXWIN_COMPATIBILITY_2_4
// 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();
// Return some valid traits object. #if wxUSE_LOG
// // override this function to create default log target of arbitrary
// This method checks if we have wxTheApp and returns its traits if it does // user-defined class (default implementation creates a wxLogGui
// exist and the traits are non-NULL, similarly to GetTraitsIfExists(), but // object) -- this log object is used by default by all wxLogXXX()
// falls back to wxConsoleAppTraits to ensure that it always returns // functions.
// something valid. wxDEPRECATED( virtual wxLog *CreateLogTarget() );
static wxAppTraits& GetValidTraits(); #endif // wxUSE_LOG
// returns the main event loop instance, i.e. the event loop which is started // similar to CreateLogTarget() but for the global wxMessageOutput
// by OnRun() and which dispatches all events sent from the native toolkit // object
// to the application (except when new event loops are temporarily set-up). wxDEPRECATED( virtual wxMessageOutput *CreateMessageOutput() );
// The returned value maybe NULL. Put initialization code which needs a
// non-NULL main event loop into OnEventLoopEnter().
wxEventLoopBase* GetMainLoop() const
{ return m_mainLoop; }
// This function sets the C locale to the default locale for the current #endif // WXWIN_COMPATIBILITY_2_4
// 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();
// event processing functions // event processing functions
// -------------------------- // --------------------------
// Implement the inherited wxEventFilter method but just return -1 from it // this method allows to filter all the events processed by the program, so
// to indicate that default processing should take place. // 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); 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 #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 // call the specified handler on the given object with the given event
// //
// this method only exists to allow catching the exceptions thrown by any // this method only exists to allow catching the exceptions thrown by any
@ -291,112 +214,33 @@ public:
wxEvent& event) const; wxEvent& event) const;
// Called when an unhandled C++ exception occurs inside OnRun(): note that // Called when an unhandled C++ exception occurs inside OnRun(): note that
// the main event loop has already terminated by now and the program will // the exception type is lost by now, so if you really want to handle the
// exit, if you need to really handle the exceptions you need to override // exception you should override OnRun() and put a try/catch around
// OnExceptionInMainLoop() // MainLoop() call there or use OnExceptionInMainLoop()
virtual void OnUnhandledException(); 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();
#endif // wxUSE_EXCEPTIONS #endif // wxUSE_EXCEPTIONS
// process all events in the wxPendingEvents list -- it is necessary to
// pending events // call this function to process posted events. This happens during each
// --------------
// 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
// event loop iteration in GUI mode but if there is no main loop, it may be // event loop iteration in GUI mode but if there is no main loop, it may be
// also called directly. // also called directly.
virtual void ProcessPendingEvents(); virtual void ProcessPendingEvents();
// check if there are pending events on global pending event list // doesn't do anything in this class, just a hook for GUI wxApp
bool HasPendingEvents() const; virtual bool Yield(bool WXUNUSED(onlyIfNeeded) = false) { return true; }
// temporary suspends processing of the pending events // make sure that idle events are sent again
void SuspendProcessingOfPendingEvents(); virtual void WakeUpIdle() { }
// resume processing of the pending events previously stopped because of a // this is just a convenience: by providing its implementation here we
// call to SuspendProcessingOfPendingEvents() // avoid #ifdefs in the code using it
void ResumeProcessingOfPendingEvents(); static bool IsMainLoopRunning() { return false; }
// 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;
// debugging support // debugging support
// ----------------- // -----------------
#ifdef __WXDEBUG__
// this function is called when an assert failure occurs, the base class // this function is called when an assert failure occurs, the base class
// version does the normal processing (i.e. shows the usual assert failure // version does the normal processing (i.e. shows the usual assert failure
// dialog box) // dialog box)
@ -416,12 +260,16 @@ public:
int line, int line,
const wxChar *cond, const wxChar *cond,
const wxChar *msg); const wxChar *msg);
#endif // __WXDEBUG__
// check that the wxBuildOptions object (constructed in the application // 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 // options of the library and abort if it doesn't
static bool CheckBuildOptions(const char *optionsSignature, static bool CheckBuildOptions(const char *optionsSignature,
const char *componentName); const char *componentName);
#if WXWIN_COMPATIBILITY_2_4
wxDEPRECATED( static bool CheckBuildOptions(const wxBuildOptions& buildOptions) );
#endif
// implementation only from now on // implementation only from now on
// ------------------------------- // -------------------------------
@ -442,87 +290,36 @@ public:
// command line arguments (public for backwards compatibility) // command line arguments (public for backwards compatibility)
int argc; int argc;
wxChar **argv;
// 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
protected: protected:
// delete all objects in wxPendingDelete list
//
// called from ProcessPendingEvents()
void DeletePendingObjects();
// the function which creates the traits object when GetTraits() needs it // the function which creates the traits object when GetTraits() needs it
// for the first time // for the first time
virtual wxAppTraits *CreateTraits(); virtual wxAppTraits *CreateTraits();
// function used for dynamic wxApp creation // function used for dynamic wxApp creation
static wxAppInitializerFunction ms_appInitFn; static wxAppInitializerFunction ms_appInitFn;
// the one and only global application object // the one and only global application object
static wxAppConsole *ms_appInstance; 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) // application info (must be set from the user code)
wxString m_vendorName, // vendor name ("acme") wxString m_vendorName, // vendor name (ACME Inc)
m_vendorDisplayName, // vendor display name (e.g. "ACME Inc") m_appName, // app name
m_appName, // app name ("myapp")
m_appDisplayName, // app display name ("My Application")
m_className; // class name m_className; // class name
// the class defining the application behaviour, NULL initially and created // the class defining the application behaviour, NULL initially and created
// by GetTraits() when first needed // by GetTraits() when first needed
wxAppTraits *m_traits; 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 // the application object is a singleton anyhow, there is no sense in
// copying it // 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 // 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 // the worker functions - usually not used directly by the user code
// ----------------------------------------------------------------- // -----------------------------------------------------------------
// safer alternatives to Yield(), using wxWindowDisabler // return true if we're running main loop, i.e. if the events can
virtual bool SafeYield(wxWindow *win, bool onlyIfNeeded); // (already) be dispatched
virtual bool SafeYieldFor(wxWindow *win, long eventsToProcess); 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 // this virtual function is called in the GUI mode when the application
// becomes idle and normally just sends wxIdleEvent to all interested // 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 // it should return true if more idle events are needed, false if not
virtual bool ProcessIdle(); virtual bool ProcessIdle();
// override base class version: GUI apps always use an event loop // Send idle event to window and all subwindows
virtual bool UsesEventLoop() const { return true; } // 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 // top level window functions
@ -614,10 +455,10 @@ public:
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
// Get display mode that is used use. This is only used in framebuffer // 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; virtual wxVideoMode GetDisplayMode() const;
// Set display mode to use. This is only used in framebuffer wxWin // 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 // wxApp::OnInitGui
virtual bool SetDisplayMode(const wxVideoMode& WXUNUSED(info)) { return true; } virtual bool SetDisplayMode(const wxVideoMode& WXUNUSED(info)) { return true; }
@ -637,9 +478,6 @@ public:
// if it's unknown // if it's unknown
virtual wxLayoutDirection GetLayoutDirection() const; 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) // command line parsing (GUI-specific)
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
@ -658,16 +496,28 @@ public:
virtual void SetActive(bool isActive, wxWindow *lastFocus); virtual void SetActive(bool isActive, wxWindow *lastFocus);
#if WXWIN_COMPATIBILITY_2_6 #if WXWIN_COMPATIBILITY_2_6
// OBSOLETE: don't use, always returns true
//
// returns true if the program is successfully initialized // returns true if the program is successfully initialized
wxDEPRECATED_MSG("always returns true now, don't call") wxDEPRECATED( bool Initialized() );
bool Initialized();
#endif // WXWIN_COMPATIBILITY_2_6 #endif // WXWIN_COMPATIBILITY_2_6
// perform standard OnIdle behaviour, ensure that this is always called
void OnIdle(wxIdleEvent& event);
protected: protected:
// delete all objects in wxPendingDelete list
void DeletePendingObjects();
// override base class method to use GUI traits // override base class method to use GUI traits
virtual wxAppTraits *CreateTraits(); 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) // the main top level window (may be NULL)
wxWindow *m_topWindow; wxWindow *m_topWindow;
@ -691,21 +541,29 @@ protected:
// does any of our windows have focus? // does any of our windows have focus?
bool m_isActive; bool m_isActive;
wxDECLARE_NO_COPY_CLASS(wxAppBase);
DECLARE_NO_COPY_CLASS(wxAppBase)
}; };
#if WXWIN_COMPATIBILITY_2_6 #if WXWIN_COMPATIBILITY_2_6
inline bool wxAppBase::Initialized() { return true; } inline bool wxAppBase::Initialized() { return true; }
#endif // WXWIN_COMPATIBILITY_2_6 #endif // WXWIN_COMPATIBILITY_2_6
#endif // wxUSE_GUI
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// now include the declaration of the real class // now include the declaration of the real class
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
#if defined(__WXMSW__) #if wxUSE_GUI
#if defined(__WXPALMOS__)
#include "wx/palmos/app.h"
#elif defined(__WXMSW__)
#include "wx/msw/app.h" #include "wx/msw/app.h"
#elif defined(__WXMOTIF__) #elif defined(__WXMOTIF__)
#include "wx/motif/app.h" #include "wx/motif/app.h"
#elif defined(__WXMGL__)
#include "wx/mgl/app.h"
#elif defined(__WXDFB__) #elif defined(__WXDFB__)
#include "wx/dfb/app.h" #include "wx/dfb/app.h"
#elif defined(__WXGTK20__) #elif defined(__WXGTK20__)
@ -715,19 +573,15 @@ protected:
#elif defined(__WXX11__) #elif defined(__WXX11__)
#include "wx/x11/app.h" #include "wx/x11/app.h"
#elif defined(__WXMAC__) #elif defined(__WXMAC__)
#include "wx/osx/app.h" #include "wx/mac/app.h"
#elif defined(__WXCOCOA__) #elif defined(__WXCOCOA__)
#include "wx/cocoa/app.h" #include "wx/cocoa/app.h"
#elif defined(__WXPM__) #elif defined(__WXPM__)
#include "wx/os2/app.h" #include "wx/os2/app.h"
#endif #endif
#else // !GUI #else // !GUI
// allow using just wxApp (instead of wxAppConsole) in console programs
// wxApp is defined in core and we cannot define another one in wxBase, typedef wxAppConsole wxApp;
// so use the preprocessor to allow using wxApp in console programs too
#define wxApp wxAppConsole
#endif // GUI/!GUI #endif // GUI/!GUI
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@ -738,12 +592,12 @@ protected:
// object of type wxApp // object of type wxApp
// //
// note that instead of using of wxTheApp in application code you should // 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) // 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 // the cast is safe as in GUI build we only use wxApp, not wxAppConsole, and in
// console mode it does nothing at all // console mode it does nothing at all
#define wxTheApp static_cast<wxApp*>(wxApp::GetInstance()) #define wxTheApp wx_static_cast(wxApp*, wxApp::GetInstance())
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// global functions // global functions
@ -753,20 +607,20 @@ protected:
// ------------------------------------------------------ // ------------------------------------------------------
// Force an exit from main loop // 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 // wx/utils.h, this results in warnings from g++ with -Wredundant-decls
#ifndef wx_YIELD_DECLARED #ifndef wx_YIELD_DECLARED
#define wx_YIELD_DECLARED #define wx_YIELD_DECLARED
// Yield to other apps/messages // Yield to other apps/messages
WXDLLIMPEXP_CORE bool wxYield(); extern bool WXDLLIMPEXP_BASE wxYield();
#endif // wx_YIELD_DECLARED #endif // wx_YIELD_DECLARED
// Yield to other apps/messages // Yield to other apps/messages
WXDLLIMPEXP_BASE void wxWakeUpIdle(); extern void WXDLLIMPEXP_BASE wxWakeUpIdle();
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// macros for dynamic creation of the application object // macros for dynamic creation of the application object
@ -783,53 +637,34 @@ public:
{ wxApp::SetInitializerFunction(fn); } { 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. // 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 #define IMPLEMENT_WXWIN_MAIN_CONSOLE \
// Unicode strings can be passed as command line parameters and not just those int main(int argc, char **argv) { return wxEntry(argc, argv); }
// 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
// port-specific header could have defined it already in some special way // port-specific header could have defined it already in some special way
#ifndef wxIMPLEMENT_WXWIN_MAIN #ifndef IMPLEMENT_WXWIN_MAIN
#define wxIMPLEMENT_WXWIN_MAIN wxIMPLEMENT_WXWIN_MAIN_CONSOLE #define IMPLEMENT_WXWIN_MAIN IMPLEMENT_WXWIN_MAIN_CONSOLE
#endif // defined(wxIMPLEMENT_WXWIN_MAIN) #endif // defined(IMPLEMENT_WXWIN_MAIN)
#ifdef __WXUNIVERSAL__ #ifdef __WXUNIVERSAL__
#include "wx/univ/theme.h" #include "wx/univ/theme.h"
#ifdef wxUNIV_DEFAULT_THEME #ifdef wxUNIV_DEFAULT_THEME
#define wxIMPLEMENT_WX_THEME_SUPPORT \ #define IMPLEMENT_WX_THEME_SUPPORT \
WX_USE_THEME(wxUNIV_DEFAULT_THEME); WX_USE_THEME(wxUNIV_DEFAULT_THEME);
#else #else
#define wxIMPLEMENT_WX_THEME_SUPPORT #define IMPLEMENT_WX_THEME_SUPPORT
#endif #endif
#else #else
#define wxIMPLEMENT_WX_THEME_SUPPORT #define IMPLEMENT_WX_THEME_SUPPORT
#endif #endif
// Use this macro if you want to define your own main() or WinMain() function // Use this macro if you want to define your own main() or WinMain() function
// and call wxEntry() from there. // and call wxEntry() from there.
#define wxIMPLEMENT_APP_NO_MAIN(appname) \ #define IMPLEMENT_APP_NO_MAIN(appname) \
appname& wxGetApp() { return *static_cast<appname*>(wxApp::GetInstance()); } \
wxAppConsole *wxCreateApp() \ wxAppConsole *wxCreateApp() \
{ \ { \
wxAppConsole::CheckBuildOptions(WX_BUILD_OPTIONS_SIGNATURE, \ wxAppConsole::CheckBuildOptions(WX_BUILD_OPTIONS_SIGNATURE, \
@ -837,53 +672,37 @@ public:
return new appname; \ return new appname; \
} \ } \
wxAppInitializer \ 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 // wxUniversal builds
#define wxIMPLEMENT_APP_NO_THEMES(appname) \ #define IMPLEMENT_APP_NO_THEMES(appname) \
wxIMPLEMENT_WXWIN_MAIN \ IMPLEMENT_APP_NO_MAIN(appname) \
wxIMPLEMENT_APP_NO_MAIN(appname) IMPLEMENT_WXWIN_MAIN
// Use this macro exactly once, the argument is the name of the wxApp-derived // Use this macro exactly once, the argument is the name of the wxApp-derived
// class which is the class of your application. // class which is the class of your application.
#define wxIMPLEMENT_APP(appname) \ #define IMPLEMENT_APP(appname) \
wxIMPLEMENT_WX_THEME_SUPPORT \ IMPLEMENT_APP_NO_THEMES(appname) \
wxIMPLEMENT_APP_NO_THEMES(appname) IMPLEMENT_WX_THEME_SUPPORT
// Same as IMPLEMENT_APP(), but for console applications. // Same as IMPLEMENT_APP(), but for console applications.
#define wxIMPLEMENT_APP_CONSOLE(appname) \ #define IMPLEMENT_APP_CONSOLE(appname) \
wxIMPLEMENT_WXWIN_MAIN_CONSOLE \ IMPLEMENT_APP_NO_MAIN(appname) \
wxIMPLEMENT_APP_NO_MAIN(appname) IMPLEMENT_WXWIN_MAIN_CONSOLE
// this macro can be used multiple times and just allows you to use wxGetApp() // this macro can be used multiple times and just allows you to use wxGetApp()
// function // function
#define wxDECLARE_APP(appname) \ #define DECLARE_APP(appname) extern appname& wxGetApp();
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 // anywhere else but at the very least it suppresses icc warnings about
// defining extern symbols without prior declaration, and it shouldn't do any // defining extern symbols without prior declaration, and it shouldn't do any
// harm // harm
extern wxAppConsole *wxCreateApp(); extern wxAppConsole *wxCreateApp();
extern wxAppInitializer wxTheAppInitializer; 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_ #endif // _WX_APP_H_BASE_

View File

@ -4,6 +4,7 @@
// Author: Vadim Zeitlin // Author: Vadim Zeitlin
// Modified by: // Modified by:
// Created: 19.06.2003 // Created: 19.06.2003
// RCS-ID: $Id: apptrait.h 49804 2007-11-10 01:09:42Z VZ $
// Copyright: (c) 2003 Vadim Zeitlin <vadim@wxwidgets.org> // Copyright: (c) 2003 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence: wxWindows licence // Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
@ -14,44 +15,34 @@
#include "wx/string.h" #include "wx/string.h"
#include "wx/platinfo.h" #include "wx/platinfo.h"
class WXDLLIMPEXP_FWD_BASE wxArrayString; class WXDLLIMPEXP_FWD_BASE wxObject;
class WXDLLIMPEXP_FWD_BASE wxConfigBase; class WXDLLIMPEXP_FWD_BASE wxAppTraits;
class WXDLLIMPEXP_FWD_BASE wxEventLoopBase;
#if wxUSE_FONTMAP #if wxUSE_FONTMAP
class WXDLLIMPEXP_FWD_CORE wxFontMapper; class WXDLLIMPEXP_FWD_CORE wxFontMapper;
#endif // wxUSE_FONTMAP #endif // wxUSE_FONTMAP
class WXDLLIMPEXP_FWD_BASE wxLog; class WXDLLIMPEXP_FWD_BASE wxLog;
class WXDLLIMPEXP_FWD_BASE wxMessageOutput; class WXDLLIMPEXP_FWD_BASE wxMessageOutput;
class WXDLLIMPEXP_FWD_BASE wxObject;
class WXDLLIMPEXP_FWD_CORE wxRendererNative; class WXDLLIMPEXP_FWD_CORE wxRendererNative;
class WXDLLIMPEXP_FWD_BASE wxStandardPaths;
class WXDLLIMPEXP_FWD_BASE wxString; 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 // wxAppTraits: this class defines various configurable aspects of wxApp
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
class WXDLLIMPEXP_FWD_BASE wxStandardPathsBase;
class WXDLLIMPEXP_BASE wxAppTraitsBase class WXDLLIMPEXP_BASE wxAppTraitsBase
{ {
public: public:
// needed since this class declares virtual members // needed since this class declares virtual members
virtual ~wxAppTraitsBase() { } 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 #if wxUSE_LOG
// create the default log target // create the default log target
virtual wxLog *CreateLogTarget() = 0; virtual wxLog *CreateLogTarget() = 0;
@ -72,14 +63,16 @@ public:
// NB: returned pointer will be deleted by the caller // NB: returned pointer will be deleted by the caller
virtual wxRendererNative *CreateRenderer() = 0; virtual wxRendererNative *CreateRenderer() = 0;
#if wxUSE_STDPATHS
// wxStandardPaths object is normally the same for wxBase and wxGUI // wxStandardPaths object is normally the same for wxBase and wxGUI
// except in the case of wxMac and wxCocoa // 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 // functions abstracting differences between GUI and console modes
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
#ifdef __WXDEBUG__
// show the assert dialog with the specified message in GUI or just print // show the assert dialog with the specified message in GUI or just print
// the string to stderr in console mode // the string to stderr in console mode
// //
@ -88,79 +81,53 @@ public:
// //
// return true to suppress subsequent asserts, false to continue as before // return true to suppress subsequent asserts, false to continue as before
virtual bool ShowAssertDialog(const wxString& msg) = 0; virtual bool ShowAssertDialog(const wxString& msg) = 0;
#endif // __WXDEBUG__
// return true if fprintf(stderr) goes somewhere, false otherwise // return true if fprintf(stderr) goes somewhere, false otherwise
virtual bool HasStderr() = 0; 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 #if wxUSE_SOCKETS
// this function is used by wxNet library to set the default socket manager // return table of GUI callbacks for GSocket code or NULL in wxBase. This
// to use: doing it like this allows us to keep all socket-related code in // is needed because networking classes are in their own library and so
// wxNet instead of having to pull it in wxBase itself as we'd have to do // they can't directly call GUI functions (the same net library can be
// if we really implemented wxSocketManager here // 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
// we don't take ownership of this pointer, it should have a lifetime // table can be passed around
// greater than that of any socket (e.g. be a pointer to a static object) virtual GSocketGUIFunctionsTable* GetSocketGUIFunctionsTable() = 0;
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; }
#endif #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 // return information about the (native) toolkit currently used and its
// runtime (not compile-time) version. // runtime (not compile-time) version.
// returns wxPORT_BASE for console applications and one of the remaining // returns wxPORT_BASE for console applications and one of the remaining
// wxPORT_* values for GUI applications. // 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 // return true if the port is using wxUniversal for the GUI, false if not
virtual bool IsUsingUniversalWidgets() const = 0; virtual bool IsUsingUniversalWidgets() const = 0;
// return the name of the Desktop Environment such as // return the name of the Desktop Environment such as
// "KDE" or "GNOME". May return an empty string. // "KDE" or "GNOME". May return an empty string.
virtual wxString GetDesktopEnvironment() const = 0; virtual wxString GetDesktopEnvironment() const { return wxEmptyString; }
// 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;
}
protected: protected:
#if wxUSE_STACKWALKER #if wxUSE_STACKWALKER && defined( __WXDEBUG__ )
// utility function: returns the stack frame as a plain wxString // utility function: returns the stack frame as a plain wxString
virtual wxString GetAssertStackTrace(); virtual wxString GetAssertStackTrace();
#endif #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 // NB: test for __UNIX__ before __WXMAC__ as under Darwin we want to use the
// Unix code (and otherwise __UNIX__ wouldn't be defined) // Unix code (and otherwise __UNIX__ wouldn't be defined)
// ABX: check __WIN32__ instead of __WXMSW__ for the same MSWBase in any Win32 port // 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" #include "wx/msw/apptbase.h"
#elif defined(__UNIX__) && !defined(__EMX__) #elif defined(__UNIX__) && !defined(__EMX__)
#include "wx/unix/apptbase.h" #include "wx/unix/apptbase.h"
#elif defined(__WXMAC__)
#include "wx/mac/apptbase.h"
#elif defined(__OS2__) #elif defined(__OS2__)
#include "wx/os2/apptbase.h" #include "wx/os2/apptbase.h"
#else // no platform-specific methods to add to wxAppTraits #else // no platform-specific methods to add to wxAppTraits
@ -194,10 +165,6 @@ private:
class WXDLLIMPEXP_BASE wxConsoleAppTraitsBase : public wxAppTraits class WXDLLIMPEXP_BASE wxConsoleAppTraitsBase : public wxAppTraits
{ {
public: public:
#if !wxUSE_CONSOLE_EVENTLOOP
virtual wxEventLoopBase *CreateEventLoop() { return NULL; }
#endif // !wxUSE_CONSOLE_EVENTLOOP
#if wxUSE_LOG #if wxUSE_LOG
virtual wxLog *CreateLogTarget(); virtual wxLog *CreateLogTarget();
#endif // wxUSE_LOG #endif // wxUSE_LOG
@ -206,12 +173,20 @@ public:
virtual wxFontMapper *CreateFontMapper(); virtual wxFontMapper *CreateFontMapper();
#endif // wxUSE_FONTMAP #endif // wxUSE_FONTMAP
virtual wxRendererNative *CreateRenderer(); virtual wxRendererNative *CreateRenderer();
#if wxUSE_SOCKETS
virtual GSocketGUIFunctionsTable* GetSocketGUIFunctionsTable();
#endif
#ifdef __WXDEBUG__
virtual bool ShowAssertDialog(const wxString& msg); virtual bool ShowAssertDialog(const wxString& msg);
#endif // __WXDEBUG__
virtual bool HasStderr(); virtual bool HasStderr();
virtual void ScheduleForDestroy(wxObject *object);
virtual void RemoveFromPendingDelete(wxObject *object);
// the GetToolkitVersion for console application is always the same // 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) // no toolkits (wxBase is for console applications without GUI support)
// NB: zero means "no toolkit", -1 means "not initialized yet" // NB: zero means "no toolkit", -1 means "not initialized yet"
@ -222,7 +197,6 @@ public:
} }
virtual bool IsUsingUniversalWidgets() const { return false; } virtual bool IsUsingUniversalWidgets() const { return false; }
virtual wxString GetDesktopEnvironment() const { return wxEmptyString; }
}; };
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@ -231,7 +205,7 @@ public:
#if wxUSE_GUI #if wxUSE_GUI
class WXDLLIMPEXP_CORE wxGUIAppTraitsBase : public wxAppTraits class WXDLLEXPORT wxGUIAppTraitsBase : public wxAppTraits
{ {
public: public:
#if wxUSE_LOG #if wxUSE_LOG
@ -242,10 +216,18 @@ public:
virtual wxFontMapper *CreateFontMapper(); virtual wxFontMapper *CreateFontMapper();
#endif // wxUSE_FONTMAP #endif // wxUSE_FONTMAP
virtual wxRendererNative *CreateRenderer(); virtual wxRendererNative *CreateRenderer();
#if wxUSE_SOCKETS
virtual GSocketGUIFunctionsTable* GetSocketGUIFunctionsTable();
#endif
#ifdef __WXDEBUG__
virtual bool ShowAssertDialog(const wxString& msg); virtual bool ShowAssertDialog(const wxString& msg);
#endif // __WXDEBUG__
virtual bool HasStderr(); virtual bool HasStderr();
virtual void ScheduleForDestroy(wxObject *object);
virtual void RemoveFromPendingDelete(wxObject *object);
virtual bool IsUsingUniversalWidgets() const virtual bool IsUsingUniversalWidgets() const
{ {
#ifdef __WXUNIVERSAL__ #ifdef __WXUNIVERSAL__
@ -254,8 +236,6 @@ public:
return false; return false;
#endif #endif
} }
virtual wxString GetDesktopEnvironment() const { return wxEmptyString; }
}; };
#endif // wxUSE_GUI #endif // wxUSE_GUI
@ -265,12 +245,16 @@ public:
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// ABX: check __WIN32__ instead of __WXMSW__ for the same MSWBase in any Win32 port // 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" #include "wx/msw/apptrait.h"
#elif defined(__OS2__) #elif defined(__OS2__)
#include "wx/os2/apptrait.h" #include "wx/os2/apptrait.h"
#elif defined(__UNIX__) #elif defined(__UNIX__)
#include "wx/unix/apptrait.h" #include "wx/unix/apptrait.h"
#elif defined(__WXMAC__)
#include "wx/mac/apptrait.h"
#elif defined(__DOS__) #elif defined(__DOS__)
#include "wx/msdos/apptrait.h" #include "wx/msdos/apptrait.h"
#else #else

View File

@ -2,6 +2,7 @@
// Name: wx/archive.h // Name: wx/archive.h
// Purpose: Streams for archive formats // Purpose: Streams for archive formats
// Author: Mike Wetherell // Author: Mike Wetherell
// RCS-ID: $Id: archive.h 43445 2006-11-16 14:30:20Z MW $
// Copyright: (c) 2004 Mike Wetherell // Copyright: (c) 2004 Mike Wetherell
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
@ -224,7 +225,7 @@ public:
if (it.m_rep) if (it.m_rep)
it.m_rep.AddRef(); it.m_rep.AddRef();
if (m_rep) if (m_rep)
this->m_rep.UnRef(); m_rep.UnRef();
m_rep = it.m_rep; m_rep = it.m_rep;
return *this; return *this;
} }
@ -340,13 +341,11 @@ public:
const wxString& name, const wxString& name,
wxPathFormat format = wxPATH_NATIVE) const = 0; 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; } void SetConv(wxMBConv& conv) { m_pConv = &conv; }
wxMBConv& GetConv() const wxMBConv& GetConv() const
{ if (m_pConv) return *m_pConv; else return wxConvLocal; } { 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 wxStreamProtocolType type
= wxSTREAM_PROTOCOL); = wxSTREAM_PROTOCOL);

View File

@ -4,8 +4,9 @@
// Author: Vadim Zeitlin // Author: Vadim Zeitlin
// Modified by: // Modified by:
// Created: 16.10.97 // Created: 16.10.97
// RCS-ID: $Id: arrimpl.cpp 34241 2005-05-22 12:10:55Z JS $
// Copyright: (c) 1997 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr> // Copyright: (c) 1997 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
// 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); \ 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 ( bFromEnd ) { \
if ( size() > 0 ) { \ if ( size() > 0 ) { \
size_t ui = size() - 1; \ size_t ui = size() - 1; \
do { \ do { \
if ( (T*)base_array::operator[](ui) == &item ) \ if ( (T*)base_array::operator[](ui) == &Item ) \
return static_cast<int>(ui); \ return wx_static_cast(int, ui); \
ui--; \ ui--; \
} \ } \
while ( ui != 0 ); \ while ( ui != 0 ); \
@ -105,8 +106,8 @@ int name::Index(const T& item, bool bFromEnd) const \
} \ } \
else { \ else { \
for( size_t ui = 0; ui < size(); ui++ ) { \ for( size_t ui = 0; ui < size(); ui++ ) { \
if( (T*)base_array::operator[](ui) == &item ) \ if( (T*)base_array::operator[](ui) == &Item ) \
return static_cast<int>(ui); \ return wx_static_cast(int, ui); \
} \ } \
} \ } \
\ \

View File

@ -1,9 +1,10 @@
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// Name: wx/arrstr.h // Name: include/wx/arrstr.h
// Purpose: wxArrayString class // Purpose: wxArrayString class
// Author: Mattia Barbon and Vadim Zeitlin // Author: Mattia Barbon and Vadim Zeitlin
// Modified by: // Modified by:
// Created: 07/07/03 // Created: 07/07/03
// RCS-ID: $Id: arrstr.h 61872 2009-09-09 22:37:05Z VZ $
// Copyright: (c) 2003 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr> // Copyright: (c) 2003 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
// Licence: wxWindows licence // Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
@ -14,20 +15,10 @@
#include "wx/defs.h" #include "wx/defs.h"
#include "wx/string.h" #include "wx/string.h"
// these functions are only used in STL build now but we define them in any WXDLLIMPEXP_BASE int wxCMPFUNC_CONV wxStringSortAscending(wxString*, wxString*);
// case for compatibility with the existing code outside of the library which WXDLLIMPEXP_BASE int wxCMPFUNC_CONV wxStringSortDescending(wxString*, wxString*);
// could be using them
inline int wxCMPFUNC_CONV wxStringSortAscending(wxString* s1, wxString* s2)
{
return s1->Cmp(*s2);
}
inline int wxCMPFUNC_CONV wxStringSortDescending(wxString* s1, wxString* s2) #if wxUSE_STL
{
return wxStringSortAscending(s2, s1);
}
#if wxUSE_STD_CONTAINERS
#include "wx/dynarray.h" #include "wx/dynarray.h"
@ -51,11 +42,10 @@ public:
wxArrayString() { } wxArrayString() { }
wxArrayString(const wxArrayString& a) : wxArrayStringBase(a) { } wxArrayString(const wxArrayString& a) : wxArrayStringBase(a) { }
wxArrayString(size_t sz, const char** a); wxArrayString(size_t sz, const wxChar** a);
wxArrayString(size_t sz, const wchar_t** a);
wxArrayString(size_t sz, const wxString* 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(bool reverseOrder = false);
void Sort(CompareFunction function); void Sort(CompareFunction function);
@ -85,37 +75,25 @@ public:
Add(src[n]); Add(src[n]);
} }
int Index(const wxString& str, bool bCase = true, bool bFromEnd = false) const; int Index(const wxChar* sz, 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" );
}
}; };
#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 // Of course, it can be called a dirty hack, but we use twice less memory and
// doesn't export template methods from DLL correctly so even though // this approach is also more speed efficient, so it's probably worth it.
// it compiles them fine, we get link errors when using wxArrayString //
#if !defined(__VISUALC6__) || !(defined(WXMAKINGDLL) || defined(WXUSINGDLL)) // Usage notes: when a string is added/inserted, a new copy of it is created,
#define wxHAS_VECTOR_TEMPLATE_ASSIGN // so the original string may be safely deleted. When a string is retrieved
#endif // from the array (operator[] or Item() method), a reference is returned.
// ----------------------------------------------------------------------------
#ifdef wxHAS_VECTOR_TEMPLATE_ASSIGN
#include "wx/beforestd.h"
#include <iterator>
#include "wx/afterstd.h"
#endif // wxHAS_VECTOR_TEMPLATE_ASSIGN
class WXDLLIMPEXP_BASE wxArrayString 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 // 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 // using this ctor for implicit conversions from "const char *" (which
// we'd like to be implicitly converted to wxString instead!). This // we'd like to be implicitly converted to wxString instead!)
// wouldn't be needed if the 'explicit' keyword was supported by all //
// compilers, or if this was protected ctor for wxSortedArrayString, // of course, using explicit would be even better - if all compilers
// but we're stuck with it now. // supported it...
wxEXPLICIT wxArrayString(int autoSort) { Init(autoSort != 0); } wxArrayString(int autoSort) { Init(autoSort != 0); }
// C string array ctor // C string array ctor
wxArrayString(size_t sz, const char** a); wxArrayString(size_t sz, const wxChar** a);
wxArrayString(size_t sz, const wchar_t** a);
// wxString string array ctor // wxString string array ctor
wxArrayString(size_t sz, const wxString* a); wxArrayString(size_t sz, const wxString* a);
// copy ctor // copy ctor
@ -172,34 +149,38 @@ public:
// items access (range checking is done in debug version) // items access (range checking is done in debug version)
// get item at position uiIndex // get item at position uiIndex
wxString& Item(size_t nIndex) wxString& Item(size_t nIndex) const
{ {
wxASSERT_MSG( nIndex < m_nCount, wxASSERT_MSG( nIndex < m_nCount,
wxT("wxArrayString: index out of bounds") ); 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<wxArrayString*>(this)->Item(nIndex); }
// same as Item() // same as Item()
wxString& operator[](size_t nIndex) { return Item(nIndex); } wxString& operator[](size_t nIndex) const { return Item(nIndex); }
const wxString& operator[](size_t nIndex) const { return Item(nIndex); }
// get last item // get last item
wxString& Last() wxString& Last() const
{ {
wxASSERT_MSG( !IsEmpty(), wxASSERT_MSG( !IsEmpty(),
wxT("wxArrayString: index out of bounds") ); wxT("wxArrayString: index out of bounds") );
return Item(GetCount() - 1); return Item(Count() - 1);
} }
const wxString& Last() const { return const_cast<wxArrayString*>(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 // item management
// Search the element in the array, starting from the beginning if // Search the element in the array, starting from the beginning if
// bFromEnd is false or from end otherwise. If bCase, comparison is case // bFromEnd is false or from end otherwise. If bCase, comparison is case
// sensitive (default). Returns index of the first item matched or // sensitive (default). Returns index of the first item matched or
// wxNOT_FOUND // 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 // add new element at the end (if the array is not sorted), return its
// index // index
size_t Add(const wxString& str, size_t nInsert = 1); size_t Add(const wxString& str, size_t nInsert = 1);
@ -208,15 +189,18 @@ public:
// expand the array to have count elements // expand the array to have count elements
void SetCount(size_t count); void SetCount(size_t count);
// remove first item matching this value // remove first item matching this value
void Remove(const wxString& sz); void Remove(const wxChar *sz);
// remove item by index // 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); void RemoveAt(size_t nIndex, size_t nRemove = 1);
// sorting // sorting
// sort array elements in alphabetical order (or reversed alphabetical // sort array elements in alphabetical order (or reversed alphabetical
// order if reverseOrder parameter is true) // order if reverseOrder parameter is true)
void Sort(bool reverseOrder = false); 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(CompareFunction compareFunction);
void Sort(CompareFunction2 compareFunction); void Sort(CompareFunction2 compareFunction);
@ -251,7 +235,7 @@ public:
public: public:
pointer m_ptr; pointer m_ptr;
reverse_iterator() : m_ptr(NULL) { } 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) { } reverse_iterator(const itor& it) : m_ptr(it.m_ptr) { }
reference operator*() const { return *m_ptr; } reference operator*() const { return *m_ptr; }
pointer operator->() const { return m_ptr; } pointer operator->() const { return m_ptr; }
@ -277,7 +261,7 @@ public:
public: public:
pointer m_ptr; pointer m_ptr;
const_reverse_iterator() : m_ptr(NULL) { } 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 itor& it) : m_ptr(it.m_ptr) { }
const_reverse_iterator(const reverse_iterator& it) : m_ptr(it.m_ptr) { } const_reverse_iterator(const reverse_iterator& it) : m_ptr(it.m_ptr) { }
reference operator*() const { return *m_ptr; } reference operator*() const { return *m_ptr; }
@ -294,32 +278,13 @@ public:
wxArrayString(const_iterator first, const_iterator last) wxArrayString(const_iterator first, const_iterator last)
{ Init(false); assign(first, last); } { Init(false); assign(first, last); }
wxArrayString(size_type n, const_reference v) { Init(false); assign(n, v); } wxArrayString(size_type n, const_reference v) { Init(false); assign(n, v); }
void assign(const_iterator first, const_iterator last);
#ifdef wxHAS_VECTOR_TEMPLATE_ASSIGN
template <class Iterator>
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(size_type n, const_reference v) void assign(size_type n, const_reference v)
{ clear(); Add(v, n); } { clear(); Add(v, n); }
reference back() { return *(end() - 1); } reference back() { return *(end() - 1); }
const_reference back() const { return *(end() - 1); } const_reference back() const { return *(end() - 1); }
iterator begin() { return m_pItems; } iterator begin() { return (wxString *)&(m_pItems[0]); }
const_iterator begin() const { return m_pItems; } const_iterator begin() const { return (wxString *)&(m_pItems[0]); }
size_type capacity() const { return m_nSize; } size_type capacity() const { return m_nSize; }
void clear() { Clear(); } void clear() { Clear(); }
bool empty() const { return IsEmpty(); } bool empty() const { return IsEmpty(); }
@ -343,36 +308,27 @@ public:
void pop_back() { RemoveAt(GetCount() - 1); } void pop_back() { RemoveAt(GetCount() - 1); }
void push_back(const_reference v) { Add(v); } void push_back(const_reference v) { Add(v); }
reverse_iterator rbegin() { return reverse_iterator(end() - 1); } reverse_iterator rbegin() { return reverse_iterator(end() - 1); }
const_reverse_iterator rbegin() const const_reverse_iterator rbegin() const;
{ return const_reverse_iterator(end() - 1); }
reverse_iterator rend() { return reverse_iterator(begin() - 1); } reverse_iterator rend() { return reverse_iterator(begin() - 1); }
const_reverse_iterator rend() const const_reverse_iterator rend() const;
{ return const_reverse_iterator(begin() - 1); }
void reserve(size_type n) /* base::reserve*/; void reserve(size_type n) /* base::reserve*/;
void resize(size_type n, value_type v = value_type()); void resize(size_type n, value_type v = value_type());
size_type size() const { return GetCount(); } 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: protected:
void Init(bool autoSort); // common part of all ctors void Init(bool autoSort); // common part of all ctors
void Copy(const wxArrayString& src); // copies the contents of another array void Copy(const wxArrayString& src); // copies the contents of another array
private: private:
// Allocate the new buffer big enough to hold m_nCount + nIncrement items and void Grow(size_t nIncrement = 0); // makes array bigger if needed
// return the pointer to the old buffer, which must be deleted by the caller void Free(); // free all the strings stored
// (if the old buffer is big enough, just return NULL).
wxString *Grow(size_t nIncrement); void DoSort(); // common part of all Sort() variants
size_t m_nSize, // current size of the array size_t m_nSize, // current size of the array
m_nCount; // current number of elements 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 bool m_autoSort; // if true, keep the array always sorted
}; };
@ -386,7 +342,7 @@ public:
{ Copy(array); } { Copy(array); }
}; };
#endif // !wxUSE_STD_CONTAINERS #endif // !wxUSE_STL
// this class provides a temporary wxString* from a // this class provides a temporary wxString* from a
// wxArrayString // wxArrayString
@ -409,110 +365,13 @@ public:
return m_strings; return m_strings;
} }
wxString* Release() #if wxABI_VERSION >= 20810
{ wxString* Release();
wxString *r = GetStrings(); #endif // wxABI_VERSION >= 20810
m_strings = NULL;
return r;
}
private: private:
const wxArrayString& m_array; const wxArrayString& m_array;
wxString* m_strings; wxString* m_strings;
}; };
#endif
// ----------------------------------------------------------------------------
// 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

View File

@ -4,6 +4,7 @@
// Author: Vaclav Slavik // Author: Vaclav Slavik
// Modified by: // Modified by:
// Created: 18/03/2002 // Created: 18/03/2002
// RCS-ID: $Id: artprov.h 61872 2009-09-09 22:37:05Z VZ $
// Copyright: (c) Vaclav Slavik // Copyright: (c) Vaclav Slavik
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
@ -14,7 +15,6 @@
#include "wx/string.h" #include "wx/string.h"
#include "wx/bitmap.h" #include "wx/bitmap.h"
#include "wx/icon.h" #include "wx/icon.h"
#include "wx/iconbndl.h"
class WXDLLIMPEXP_FWD_CORE wxArtProvidersList; class WXDLLIMPEXP_FWD_CORE wxArtProvidersList;
class WXDLLIMPEXP_FWD_CORE wxArtProviderCache; class WXDLLIMPEXP_FWD_CORE wxArtProviderCache;
@ -27,10 +27,10 @@ class wxArtProviderModule;
typedef wxString wxArtClient; typedef wxString wxArtClient;
typedef wxString wxArtID; typedef wxString wxArtID;
#define wxART_MAKE_CLIENT_ID_FROM_STR(id) ((id) + "_C") #define wxART_MAKE_CLIENT_ID_FROM_STR(id) (id + wxT("_C"))
#define wxART_MAKE_CLIENT_ID(id) (#id "_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_FROM_STR(id) (id)
#define wxART_MAKE_ART_ID(id) (#id) #define wxART_MAKE_ART_ID(id) wxT(#id)
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// Art clients // Art clients
@ -44,7 +44,6 @@ typedef wxString wxArtID;
#define wxART_HELP_BROWSER wxART_MAKE_CLIENT_ID(wxART_HELP_BROWSER) #define wxART_HELP_BROWSER wxART_MAKE_CLIENT_ID(wxART_HELP_BROWSER)
#define wxART_MESSAGE_BOX wxART_MAKE_CLIENT_ID(wxART_MESSAGE_BOX) #define wxART_MESSAGE_BOX wxART_MAKE_CLIENT_ID(wxART_MESSAGE_BOX)
#define wxART_BUTTON wxART_MAKE_CLIENT_ID(wxART_BUTTON) #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) #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_DOWN wxART_MAKE_ART_ID(wxART_GO_DOWN)
#define wxART_GO_TO_PARENT wxART_MAKE_ART_ID(wxART_GO_TO_PARENT) #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_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_OPEN wxART_MAKE_ART_ID(wxART_FILE_OPEN)
#define wxART_FILE_SAVE wxART_MAKE_ART_ID(wxART_FILE_SAVE) #define wxART_FILE_SAVE wxART_MAKE_ART_ID(wxART_FILE_SAVE)
#define wxART_FILE_SAVE_AS wxART_MAKE_ART_ID(wxART_FILE_SAVE_AS) #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_UNDO wxART_MAKE_ART_ID(wxART_UNDO)
#define wxART_REDO wxART_MAKE_ART_ID(wxART_REDO) #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_QUIT wxART_MAKE_ART_ID(wxART_QUIT)
#define wxART_FIND wxART_MAKE_ART_ID(wxART_FIND) #define wxART_FIND wxART_MAKE_ART_ID(wxART_FIND)
@ -116,14 +109,12 @@ typedef wxString wxArtID;
// wxArtProvider class // wxArtProvider class
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxArtProvider : public wxObject class WXDLLEXPORT wxArtProvider : public wxObject
{ {
public: public:
// Dtor removes the provider from providers stack if it's still on it // Dtor removes the provider from providers stack if it's still on it
virtual ~wxArtProvider(); 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 // Add new provider to the top of providers stack (i.e. the provider will
// be queried first of all). // be queried first of all).
@ -131,12 +122,11 @@ public:
// Add new provider to the bottom of providers stack (i.e. the provider // Add new provider to the bottom of providers stack (i.e. the provider
// will be queried as the last one). // will be queried as the last one).
#if wxABI_VERSION >= 20810
static void PushBack(wxArtProvider *provider); static void PushBack(wxArtProvider *provider);
#if WXWIN_COMPATIBILITY_2_8
// use PushBack(), it's the same thing
static wxDEPRECATED( void Insert(wxArtProvider *provider) );
#endif #endif
// same as PushBack()
static void Insert(wxArtProvider *provider);
// Remove latest added provider and delete it. // Remove latest added provider and delete it.
static bool Pop(); static bool Pop();
@ -160,54 +150,26 @@ public:
const wxArtClient& client = wxART_OTHER, const wxArtClient& client = wxART_OTHER,
const wxSize& size = wxDefaultSize); 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 // Get the size hint of an icon from a specific wxArtClient, queries
// the topmost provider if platform_dependent = false // the topmost provider if platform_dependent = false
static wxSize GetSizeHint(const wxArtClient& client, bool platform_dependent = false); static wxSize GetSizeHint(const wxArtClient& client, bool platform_dependent = false);
#if WXWIN_COMPATIBILITY_2_6 #if WXWIN_COMPATIBILITY_2_6
// use the corresponding methods without redundant "Provider" suffix // use the corresponding methods without redundant "Provider" suffix
static wxDEPRECATED( void PushProvider(wxArtProvider *provider) ); wxDEPRECATED( static void PushProvider(wxArtProvider *provider) );
static wxDEPRECATED( void InsertProvider(wxArtProvider *provider) ); wxDEPRECATED( static void InsertProvider(wxArtProvider *provider) );
static wxDEPRECATED( bool PopProvider() ); wxDEPRECATED( static bool PopProvider() );
// use Delete() if this is what you really need, or just delete the // 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 // provider pointer, do not use Remove() as it does not delete the pointer
// unlike RemoveProvider() which does // unlike RemoveProvider() which does
static wxDEPRECATED( bool RemoveProvider(wxArtProvider *provider) ); wxDEPRECATED( static bool RemoveProvider(wxArtProvider *provider) );
#endif // WXWIN_COMPATIBILITY_2_6 #endif // WXWIN_COMPATIBILITY_2_6
protected: protected:
friend class wxArtProviderModule; friend class wxArtProviderModule;
#if wxUSE_ARTPROVIDER_STD
// Initializes default provider // Initializes default provider
static void InitStdProvider(); 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) // Initializes platform's native provider, if available (e.g. GTK2)
static void InitNativeProvider(); static void InitNativeProvider();
// Destroy caches & all providers // Destroy caches & all providers
@ -219,26 +181,15 @@ protected:
return GetSizeHint(client, true); return GetSizeHint(client, true);
} }
// Derived classes must override CreateBitmap or CreateIconBundle // Derived classes must override this method to create requested
// (or both) to create requested art resource. This method is called // art resource. This method is called only once per instance's
// only once per instance's lifetime for each requested wxArtID. // lifetime for each requested wxArtID.
virtual wxBitmap CreateBitmap(const wxArtID& WXUNUSED(id), virtual wxBitmap CreateBitmap(const wxArtID& WXUNUSED(id),
const wxArtClient& WXUNUSED(client), const wxArtClient& WXUNUSED(client),
const wxSize& WXUNUSED(size)) const wxSize& WXUNUSED(size)) = 0;
{
return wxNullBitmap;
}
virtual wxIconBundle CreateIconBundle(const wxArtID& WXUNUSED(id),
const wxArtClient& WXUNUSED(client))
{
return wxNullIconBundle;
}
private: private:
static void CommonAddingProvider(); static void CommonAddingProvider();
static wxIconBundle DoGetIconBundle(const wxArtID& id,
const wxArtClient& client);
private: private:
// list of providers: // 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_ #endif // _WX_ARTPROV_H_

View File

@ -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 <atomic.h>
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_

View File

@ -1,144 +0,0 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/bannerwindow.h
// Purpose: wxBannerWindow class declaration
// Author: Vadim Zeitlin
// Created: 2011-08-16
// Copyright: (c) 2011 Vadim Zeitlin <vadim@wxwidgets.org>
// 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_

View File

@ -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_

View File

@ -1,9 +1,10 @@
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// Name: wx/beforestd.h // Name: include/wx/beforestd.h
// Purpose: #include before STL headers // Purpose: #include before STL headers
// Author: Vadim Zeitlin // Author: Vadim Zeitlin
// Modified by: // Modified by:
// Created: 07/07/03 // Created: 07/07/03
// RCS-ID: $Id: beforestd.h 61871 2009-09-09 22:29:51Z VZ $
// Copyright: (c) 2003 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr> // Copyright: (c) 2003 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
// Licence: wxWindows licence // 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 // 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 // defines _MSC_VER as 1201) does need to be included as it's VC6-like
#if defined(__VISUALC__) && __VISUALC__ <= 1201 #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 // MSVC 5 does not have this
#if __VISUALC__ > 1100 #if __VISUALC__ > 1100
// we have to disable (and reenable in afterstd.h) this one because, // we have to disable (and reenable in afterstd.h) this one because,
@ -61,15 +48,28 @@
// 'identifier' use the following syntax // 'identifier' use the following syntax
#pragma warning(disable:4663) #pragma warning(disable:4663)
#endif #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 #endif // VC++ < 7
/** /*
GCC's visibility support is broken for libstdc++ in some older versions Recent versions of Sun C++ compiler use _T in their standard headers and
(namely Debian/Ubuntu's GCC 4.1, see our definition of it in wx/wxchar.h conflicts with them and breaks
https://bugs.launchpad.net/ubuntu/+source/gcc-4.1/+bug/109262). We fix it compilation, so undefine _T before including them and redefine it back in
here by mimicking newer versions' behaviour of using default visibility wx/afterstd.h if needed.
for libstdc++ code.
*/ */
#if defined(HAVE_VISIBILITY) && defined(HAVE_BROKEN_LIBSTDCXX_VISIBILITY) #if defined(__SUNPRO_CC) || defined(__SUNPRO_C)
#pragma GCC visibility push(default) #undef _T
#endif #endif /* SUNCC */

View File

@ -4,6 +4,7 @@
// Author: Vaclav Slavik // Author: Vaclav Slavik
// Modified by: // Modified by:
// Created: 22.04.01 // Created: 22.04.01
// RCS-ID: $Id: bitmap.h 49563 2007-10-31 20:46:21Z VZ $
// Copyright: (c) wxWidgets team // Copyright: (c) wxWidgets team
// Licence: wxWindows licence // Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
@ -18,14 +19,13 @@
#include "wx/string.h" #include "wx/string.h"
#include "wx/gdicmn.h" // for wxBitmapType #include "wx/gdicmn.h" // for wxBitmapType
#include "wx/colour.h" #include "wx/colour.h"
#include "wx/image.h"
class WXDLLIMPEXP_FWD_CORE wxBitmap; class WXDLLIMPEXP_FWD_CORE wxBitmap;
class WXDLLIMPEXP_FWD_CORE wxBitmapHandler; class WXDLLIMPEXP_FWD_CORE wxBitmapHandler;
class WXDLLIMPEXP_FWD_CORE wxIcon; class WXDLLIMPEXP_FWD_CORE wxIcon;
class WXDLLIMPEXP_FWD_CORE wxImage;
class WXDLLIMPEXP_FWD_CORE wxMask; class WXDLLIMPEXP_FWD_CORE wxMask;
class WXDLLIMPEXP_FWD_CORE wxPalette; class WXDLLIMPEXP_FWD_CORE wxPalette;
class WXDLLIMPEXP_FWD_CORE wxDC;
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// wxVariant support // wxVariant support
@ -33,16 +33,14 @@ class WXDLLIMPEXP_FWD_CORE wxDC;
#if wxUSE_VARIANT #if wxUSE_VARIANT
#include "wx/variant.h" #include "wx/variant.h"
DECLARE_VARIANT_OBJECT_EXPORTED(wxBitmap,WXDLLIMPEXP_CORE) DECLARE_VARIANT_OBJECT_EXPORTED(wxBitmap,WXDLLEXPORT)
#endif #endif
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// wxMask represents the transparent area of the bitmap // wxMask represents the transparent area of the bitmap
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// TODO: all implementation of wxMask, except the generic one, class WXDLLEXPORT wxMaskBase : public wxObject
// do not derive from wxMaskBase,,, they should
class WXDLLIMPEXP_CORE wxMaskBase : public wxObject
{ {
public: public:
// create the mask from bitmap pixels of the given colour // create the mask from bitmap pixels of the given colour
@ -68,7 +66,8 @@ protected:
virtual bool InitFromMonoBitmap(const wxBitmap& bitmap) = 0; virtual bool InitFromMonoBitmap(const wxBitmap& bitmap) = 0;
}; };
#if defined(__WXDFB__) || \ #if defined(__WXMGL__) || \
defined(__WXDFB__) || \
defined(__WXMAC__) || \ defined(__WXMAC__) || \
defined(__WXGTK__) || \ defined(__WXGTK__) || \
defined(__WXCOCOA__) || \ defined(__WXCOCOA__) || \
@ -79,30 +78,8 @@ protected:
#define wxUSE_BITMAP_BASE 0 #define wxUSE_BITMAP_BASE 0
#endif #endif
// a more readable way to tell // Only used by some ports
#define wxBITMAP_SCREEN_DEPTH (-1) // FIXME -- make all ports (but MSW which uses wxGDIImage) use these base classes
// ----------------------------------------------------------------------------
// 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.
#if wxUSE_BITMAP_BASE #if wxUSE_BITMAP_BASE
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@ -110,29 +87,18 @@ public:
// different formats // different formats
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxBitmapHandler : public wxObject class WXDLLEXPORT wxBitmapHandlerBase : public wxObject
{ {
public: public:
wxBitmapHandler() { m_type = wxBITMAP_TYPE_INVALID; } wxBitmapHandlerBase() { m_type = wxBITMAP_TYPE_INVALID; }
virtual ~wxBitmapHandler() { } virtual ~wxBitmapHandlerBase() { }
// NOTE: the following functions should be pure virtuals, but they aren't virtual bool Create(wxBitmap *bitmap, const void* data, long flags,
// because otherwise almost all ports would have to implement int width, int height, int depth = 1);
// them as "return false"... virtual bool LoadFile(wxBitmap *bitmap, const wxString& name, long flags,
int desiredWidth, int desiredHeight);
virtual bool Create(wxBitmap *WXUNUSED(bitmap), const void* WXUNUSED(data), virtual bool SaveFile(const wxBitmap *bitmap, const wxString& name,
wxBitmapType WXUNUSED(type), int WXUNUSED(width), int WXUNUSED(height), int type, const wxPalette *palette = NULL);
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; }
void SetName(const wxString& name) { m_name = name; } void SetName(const wxString& name) { m_name = name; }
void SetExtension(const wxString& ext) { m_extension = ext; } void SetExtension(const wxString& ext) { m_extension = ext; }
@ -146,65 +112,43 @@ private:
wxString m_extension; wxString m_extension;
wxBitmapType m_type; wxBitmapType m_type;
DECLARE_ABSTRACT_CLASS(wxBitmapHandler) DECLARE_ABSTRACT_CLASS(wxBitmapHandlerBase)
}; };
// ---------------------------------------------------------------------------- class WXDLLEXPORT wxBitmapBase : public wxGDIObject
// wxBitmap: class which represents platform-dependent bitmap (unlike wxImage)
// ----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxBitmapBase : public wxGDIObject,
public wxBitmapHelpers
{ {
public: public:
/* /*
Derived class must implement these: Derived class must implement these:
wxBitmap(); 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(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 char* const* bits);
wxBitmap(const wxString &filename, wxBitmapType type = wxBITMAP_TYPE_XPM); 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(); static void InitStandardHandlers();
*/ */
virtual bool Create(int width, int height, int depth = wxBITMAP_SCREEN_DEPTH) = 0; virtual bool Ok() const { return IsOk(); }
virtual bool Create(const wxSize& sz, int depth = wxBITMAP_SCREEN_DEPTH) = 0; virtual bool IsOk() const = 0;
virtual bool CreateScaled(int w, int h, int d, double logicalScale)
{ return Create(w*logicalScale,h*logicalScale,d); }
virtual int GetHeight() const = 0; virtual int GetHeight() const = 0;
virtual int GetWidth() const = 0; virtual int GetWidth() const = 0;
virtual int GetDepth() 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; 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 wxMask *GetMask() const = 0;
virtual void SetMask(wxMask *mask) = 0; virtual void SetMask(wxMask *mask) = 0;
virtual wxBitmap GetSubBitmap(const wxRect& rect) const = 0; virtual wxBitmap GetSubBitmap(const wxRect& rect) const = 0;
virtual bool SaveFile(const wxString &name, wxBitmapType type, 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; virtual bool LoadFile(const wxString &name, wxBitmapType type) = 0;
/* /*
@ -230,8 +174,8 @@ public:
// Format handling // Format handling
static inline wxList& GetHandlers() { return sm_handlers; } static inline wxList& GetHandlers() { return sm_handlers; }
static void AddHandler(wxBitmapHandler *handler); static void AddHandler(wxBitmapHandlerBase *handler);
static void InsertHandler(wxBitmapHandler *handler); static void InsertHandler(wxBitmapHandlerBase *handler);
static bool RemoveHandler(const wxString& name); static bool RemoveHandler(const wxString& name);
static wxBitmapHandler *FindHandler(const wxString& name); static wxBitmapHandler *FindHandler(const wxString& name);
static wxBitmapHandler *FindHandler(const wxString& extension, wxBitmapType bitmapType); static wxBitmapHandler *FindHandler(const wxString& extension, wxBitmapType bitmapType);
@ -259,58 +203,32 @@ protected:
#endif // wxUSE_BITMAP_BASE #endif // wxUSE_BITMAP_BASE
#if defined(__WXPALMOS__)
// the wxBITMAP_DEFAULT_TYPE constant defines the default argument value #include "wx/palmos/bitmap.h"
// for wxBitmap's ctor and wxBitmap::LoadFile() functions. #elif defined(__WXMSW__)
#if defined(__WXMSW__)
#define wxBITMAP_DEFAULT_TYPE wxBITMAP_TYPE_BMP_RESOURCE
#include "wx/msw/bitmap.h" #include "wx/msw/bitmap.h"
#elif defined(__WXMOTIF__) #elif defined(__WXMOTIF__)
#define wxBITMAP_DEFAULT_TYPE wxBITMAP_TYPE_XPM
#include "wx/x11/bitmap.h" #include "wx/x11/bitmap.h"
#elif defined(__WXGTK20__) #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" #include "wx/gtk/bitmap.h"
#elif defined(__WXGTK__) #elif defined(__WXGTK__)
#define wxBITMAP_DEFAULT_TYPE wxBITMAP_TYPE_XPM
#include "wx/gtk1/bitmap.h" #include "wx/gtk1/bitmap.h"
#elif defined(__WXX11__) #elif defined(__WXX11__)
#define wxBITMAP_DEFAULT_TYPE wxBITMAP_TYPE_XPM
#include "wx/x11/bitmap.h" #include "wx/x11/bitmap.h"
#elif defined(__WXMGL__)
#include "wx/mgl/bitmap.h"
#elif defined(__WXDFB__) #elif defined(__WXDFB__)
#define wxBITMAP_DEFAULT_TYPE wxBITMAP_TYPE_BMP_RESOURCE
#include "wx/dfb/bitmap.h" #include "wx/dfb/bitmap.h"
#elif defined(__WXMAC__) #elif defined(__WXMAC__)
#define wxBITMAP_DEFAULT_TYPE wxBITMAP_TYPE_PICT_RESOURCE #include "wx/mac/bitmap.h"
#include "wx/osx/bitmap.h"
#elif defined(__WXCOCOA__) #elif defined(__WXCOCOA__)
#define wxBITMAP_DEFAULT_TYPE wxBITMAP_TYPE_BMP_RESOURCE
#include "wx/cocoa/bitmap.h" #include "wx/cocoa/bitmap.h"
#elif defined(__WXPM__) #elif defined(__WXPM__)
#define wxBITMAP_DEFAULT_TYPE wxBITMAP_TYPE_BMP_RESOURCE
#include "wx/os2/bitmap.h" #include "wx/os2/bitmap.h"
#endif #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 // we must include generic mask.h after wxBitmap definition
#if defined(__WXDFB__) #if defined(__WXMGL__) || defined(__WXDFB__)
#define wxUSE_GENERIC_MASK 1 #define wxUSE_GENERIC_MASK 1
#else #else
#define wxUSE_GENERIC_MASK 0 #define wxUSE_GENERIC_MASK 0

View File

@ -1,9 +1,10 @@
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// Name: wx/bmpbuttn.h // Name: wx/bmpbutton.h
// Purpose: wxBitmapButton class interface // Purpose: wxBitmapButton class interface
// Author: Vadim Zeitlin // Author: Vadim Zeitlin
// Modified by: // Modified by:
// Created: 25.08.00 // Created: 25.08.00
// RCS-ID: $Id: bmpbuttn.h 45498 2007-04-16 13:03:05Z VZ $
// Copyright: (c) 2000 Vadim Zeitlin // Copyright: (c) 2000 Vadim Zeitlin
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
@ -15,75 +16,57 @@
#if wxUSE_BMPBUTTON #if wxUSE_BMPBUTTON
#include "wx/bitmap.h"
#include "wx/button.h" #include "wx/button.h"
// FIXME: right now only wxMSW, wxGTK and wxOSX implement bitmap support in wxButton extern WXDLLEXPORT_DATA(const wxChar) wxButtonNameStr[];
// 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;
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// wxBitmapButton: a button which shows bitmaps instead of the usual string. // wxBitmapButton: a button which shows bitmaps instead of the usual string.
// It has different bitmaps for different states (focused/disabled/pressed) // It has different bitmaps for different states (focused/disabled/pressed)
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxBitmapButtonBase : public wxButton class WXDLLEXPORT wxBitmapButtonBase : public wxButton
{ {
public: public:
wxBitmapButtonBase() wxBitmapButtonBase()
{ {
#ifndef wxHAS_BUTTON_BITMAP
m_marginX = m_marginX =
m_marginY = 0; m_marginY = 0;
#endif // wxHAS_BUTTON_BITMAP
} }
bool Create(wxWindow *parent, // set the bitmaps
wxWindowID winid, void SetBitmapLabel(const wxBitmap& bitmap)
const wxPoint& pos, { m_bmpNormal = bitmap; OnSetBitmap(); }
const wxSize& size, void SetBitmapSelected(const wxBitmap& sel)
long style, { m_bmpSelected = sel; OnSetBitmap(); }
const wxValidator& validator, void SetBitmapFocus(const wxBitmap& focus)
const wxString& name) { m_bmpFocus = focus; OnSetBitmap(); }
{ void SetBitmapDisabled(const wxBitmap& disabled)
// We use wxBU_NOTEXT to let the base class Create() know that we are { m_bmpDisabled = disabled; OnSetBitmap(); }
// not going to show the label: this is a hack needed for wxGTK where void SetBitmapHover(const wxBitmap& hover)
// we can show both label and bitmap only with GTK 2.6+ but we always { m_bmpHover = hover; OnSetBitmap(); }
// 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);
// 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 // set/get the margins around the button
virtual void SetMargins(int x, int y) virtual void SetMargins(int x, int y) { m_marginX = x; m_marginY = y; }
{ int GetMarginX() const { return m_marginX; }
DoSetBitmapMargins(x, y); int GetMarginY() const { return m_marginY; }
}
int GetMarginX() const { return DoGetBitmapMargins().x; }
int GetMarginY() const { return DoGetBitmapMargins().y; }
// deprecated synonym for SetBitmapLabel() // deprecated synonym for SetBitmapLabel()
#if WXWIN_COMPATIBILITY_2_6 #if WXWIN_COMPATIBILITY_2_6
wxDEPRECATED_INLINE( void SetLabel(const wxBitmap& bitmap), wxDEPRECATED( void SetLabel(const wxBitmap& bitmap) );
SetBitmapLabel(bitmap); )
// prevent virtual function hiding // prevent virtual function hiding
virtual void SetLabel(const wxString& label) virtual void SetLabel(const wxString& label)
@ -91,36 +74,31 @@ public:
#endif // WXWIN_COMPATIBILITY_2_6 #endif // WXWIN_COMPATIBILITY_2_6
protected: protected:
#ifndef wxHAS_BUTTON_BITMAP
// function called when any of the bitmaps changes // function called when any of the bitmaps changes
virtual void OnSetBitmap() { InvalidateBestSize(); Refresh(); } 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 // 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 // the margins around the bitmap
int m_marginX, int m_marginX,
m_marginY; 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__) #if defined(__WXUNIVERSAL__)
#include "wx/univ/bmpbuttn.h" #include "wx/univ/bmpbuttn.h"
#elif defined(__WXMSW__) #elif defined(__WXMSW__)
@ -132,7 +110,7 @@ protected:
#elif defined(__WXGTK__) #elif defined(__WXGTK__)
#include "wx/gtk1/bmpbuttn.h" #include "wx/gtk1/bmpbuttn.h"
#elif defined(__WXMAC__) #elif defined(__WXMAC__)
#include "wx/osx/bmpbuttn.h" #include "wx/mac/bmpbuttn.h"
#elif defined(__WXCOCOA__) #elif defined(__WXCOCOA__)
#include "wx/cocoa/bmpbuttn.h" #include "wx/cocoa/bmpbuttn.h"
#elif defined(__WXPM__) #elif defined(__WXPM__)

View File

@ -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_

View File

@ -4,6 +4,7 @@
// Author: Vadim Zeitlin // Author: Vadim Zeitlin
// Modified by: // Modified by:
// Created: 19.08.03 // Created: 19.08.03
// RCS-ID: $Id: bookctrl.h 49563 2007-10-31 20:46:21Z VZ $
// Copyright: (c) 2003 Vadim Zeitlin <vadim@wxwidgets.org> // Copyright: (c) 2003 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence: wxWindows licence // Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
@ -21,12 +22,11 @@
#include "wx/control.h" #include "wx/control.h"
#include "wx/dynarray.h" #include "wx/dynarray.h"
#include "wx/withimages.h"
WX_DEFINE_EXPORTED_ARRAY_PTR(wxWindow *, wxArrayPages); WX_DEFINE_EXPORTED_ARRAY_PTR(wxWindow *, wxArrayPages);
class WXDLLIMPEXP_FWD_CORE wxImageList; class WXDLLIMPEXP_FWD_CORE wxImageList;
class WXDLLIMPEXP_FWD_CORE wxBookCtrlEvent; class WXDLLIMPEXP_FWD_CORE wxBookCtrlBaseEvent;
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// constants // constants
@ -54,8 +54,7 @@ enum
// wxBookCtrlBase // wxBookCtrlBase
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxBookCtrlBase : public wxControl, class WXDLLEXPORT wxBookCtrlBase : public wxControl
public wxWithImages
{ {
public: public:
// construction // construction
@ -86,6 +85,9 @@ public:
long style = 0, long style = 0,
const wxString& name = wxEmptyString); const wxString& name = wxEmptyString);
// dtor
virtual ~wxBookCtrlBase();
// accessors // accessors
// --------- // ---------
@ -94,7 +96,8 @@ public:
virtual size_t GetPageCount() const { return m_pages.size(); } virtual size_t GetPageCount() const { return m_pages.size(); }
// get the panel which represents the given page // 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 // get the current page or NULL if none
wxWindow *GetCurrentPage() const wxWindow *GetCurrentPage() const
@ -104,7 +107,7 @@ public:
} }
// get the currently selected page or wxNOT_FOUND if none // 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 // set/get the title of a page
virtual bool SetPageText(size_t n, const wxString& strText) = 0; virtual bool SetPageText(size_t n, const wxString& strText) = 0;
@ -115,6 +118,15 @@ public:
// images belong to the same image list) // 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 // sets/returns item's image index in the current image list
virtual int GetPageImage(size_t n) const = 0; virtual int GetPageImage(size_t n) const = 0;
virtual bool SetPageImage(size_t n, int imageId) = 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 // resize the notebook so that all pages will have the specified size
virtual void SetPageSize(const wxSize& 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 // calculate the size of the control from the size of its page
// virtual wxSize CalcSizeFromPage(const wxSize& sizePage) const = 0;
// by default this simply returns size enough to fit both the page and the
// controller
virtual wxSize CalcSizeFromPage(const wxSize& sizePage) const;
// get/set size of area between book control area and page area // get/set size of area between book control area and page area
unsigned int GetInternalBorder() const { return m_internalBorder; } unsigned int GetInternalBorder() const { return m_internalBorder; }
@ -153,7 +159,6 @@ public:
// returns the sizer containing the control, if any // returns the sizer containing the control, if any
wxSizer* GetControlSizer() const { return m_controlSizer; } wxSizer* GetControlSizer() const { return m_controlSizer; }
// operations // operations
// ---------- // ----------
@ -170,7 +175,6 @@ public:
// remove all pages and delete them // remove all pages and delete them
virtual bool DeleteAllPages() virtual bool DeleteAllPages()
{ {
m_selection = wxNOT_FOUND;
DoInvalidateBestSize(); DoInvalidateBestSize();
WX_CLEAR_ARRAY(m_pages); WX_CLEAR_ARRAY(m_pages);
return true; return true;
@ -180,7 +184,7 @@ public:
virtual bool AddPage(wxWindow *page, virtual bool AddPage(wxWindow *page,
const wxString& text, const wxString& text,
bool bSelect = false, bool bSelect = false,
int imageId = NO_IMAGE) int imageId = -1)
{ {
DoInvalidateBestSize(); DoInvalidateBestSize();
return InsertPage(GetPageCount(), page, text, bSelect, imageId); return InsertPage(GetPageCount(), page, text, bSelect, imageId);
@ -191,10 +195,10 @@ public:
wxWindow *page, wxWindow *page,
const wxString& text, const wxString& text,
bool bSelect = false, bool bSelect = false,
int imageId = NO_IMAGE) = 0; int imageId = -1) = 0;
// set the currently selected page, return the index of the previously // 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 // NB: this function will generate PAGE_CHANGING/ED events
virtual int SetSelection(size_t n) = 0; virtual int SetSelection(size_t n) = 0;
@ -207,16 +211,13 @@ public:
void AdvanceSelection(bool forward = true) void AdvanceSelection(bool forward = true)
{ {
int nPage = GetNextPage(forward); int nPage = GetNextPage(forward);
if ( nPage != wxNOT_FOUND ) if ( nPage != -1 )
{ {
// cast is safe because of the check above // cast is safe because of the check above
SetSelection((size_t)nPage); 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) // hit test: returns which page is hit and, optionally, where (icon, label)
virtual int HitTest(const wxPoint& WXUNUSED(pt), virtual int HitTest(const wxPoint& WXUNUSED(pt),
long * WXUNUSED(flags) = NULL) const long * WXUNUSED(flags) = NULL) const
@ -228,11 +229,6 @@ public:
// we do have multiple pages // we do have multiple pages
virtual bool HasMultiplePages() const { return true; } 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: protected:
// flags for DoSetSelection() // flags for DoSetSelection()
@ -241,24 +237,6 @@ protected:
SetSelection_SendEvent = 1 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 // set the selection to the given page, sending the events (which can
// possibly prevent the page change from taking place) if SendEvent flag is // possibly prevent the page change from taking place) if SendEvent flag is
// included // included
@ -274,20 +252,15 @@ protected:
{ wxFAIL_MSG(wxT("Override this function!")); } { wxFAIL_MSG(wxT("Override this function!")); }
// create a new "page changing" event // create a new "page changing" event
virtual wxBookCtrlEvent* CreatePageChangingEvent() const virtual wxBookCtrlBaseEvent* CreatePageChangingEvent() const
{ wxFAIL_MSG(wxT("Override this function!")); return NULL; } { wxFAIL_MSG(wxT("Override this function!")); return NULL; }
// modify the event created by CreatePageChangingEvent() to "page changed" // modify the event created by CreatePageChangingEvent() to "page changed"
// event, usually by just calling SetEventType() on it // 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!")); } { 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()? // Should we accept NULL page pointers in Add/InsertPage()?
// //
// Default is no but derived classes may override it if they can treat NULL // 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) // having nodes without any associated page)
virtual bool AllowNullPage() const { return false; } virtual bool AllowNullPage() const { return false; }
// Remove the page and return a pointer to it. // 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.
virtual wxWindow *DoRemovePage(size_t page) = 0; virtual wxWindow *DoRemovePage(size_t page) = 0;
// our best size is the size which fits all our pages // our best size is the size which fits all our pages
@ -309,7 +278,7 @@ protected:
int GetNextPage(bool forward) const; int GetNextPage(bool forward) const;
// Lay out controls // Lay out controls
virtual void DoSize(); void DoSize();
// This method also invalidates the size of the controller and should be // This method also invalidates the size of the controller and should be
// called instead of just InvalidateBestSize() whenever pages are added or // called instead of just InvalidateBestSize() whenever pages are added or
@ -325,10 +294,17 @@ protected:
// the array of all pages of this control // the array of all pages of this control
wxArrayPages m_pages; 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 // get the page area
virtual wxRect GetPageRect() const; wxRect GetPageRect() const;
// event handlers // event handlers
virtual wxSize GetControllerSize() const;
void OnSize(wxSizeEvent& event); void OnSize(wxSizeEvent& event);
// controller buddy if available, NULL otherwise (usually for native book controls like wxNotebook) // controller buddy if available, NULL otherwise (usually for native book controls like wxNotebook)
@ -343,11 +319,6 @@ protected:
// the margin around the choice control // the margin around the choice control
int m_controlMargin; 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: private:
// common part of all ctors // common part of all ctors
@ -357,81 +328,68 @@ private:
unsigned int m_internalBorder; unsigned int m_internalBorder;
DECLARE_ABSTRACT_CLASS(wxBookCtrlBase) DECLARE_ABSTRACT_CLASS(wxBookCtrlBase)
wxDECLARE_NO_COPY_CLASS(wxBookCtrlBase); DECLARE_NO_COPY_CLASS(wxBookCtrlBase)
DECLARE_EVENT_TABLE() 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: public:
wxBookCtrlEvent(wxEventType commandType = wxEVT_NULL, int winid = 0, wxBookCtrlBaseEvent(wxEventType commandType = wxEVT_NULL, int winid = 0,
int nSel = wxNOT_FOUND, int nOldSel = wxNOT_FOUND) int nSel = -1, int nOldSel = -1)
: wxNotifyEvent(commandType, winid) : wxNotifyEvent(commandType, winid)
{ {
m_nSel = nSel; m_nSel = nSel;
m_nOldSel = nOldSel; m_nOldSel = nOldSel;
} }
wxBookCtrlEvent(const wxBookCtrlEvent& event) wxBookCtrlBaseEvent(const wxBookCtrlBaseEvent& event)
: wxNotifyEvent(event) : wxNotifyEvent(event)
{ {
m_nSel = event.m_nSel; m_nSel = event.m_nSel;
m_nOldSel = event.m_nOldSel; m_nOldSel = event.m_nOldSel;
} }
virtual wxEvent *Clone() const { return new wxBookCtrlEvent(*this); }
// accessors // accessors
// the currently selected page (wxNOT_FOUND if none) // the currently selected page (-1 if none)
int GetSelection() const { return m_nSel; } int GetSelection() const { return m_nSel; }
void SetSelection(int nSel) { m_nSel = 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; } int GetOldSelection() const { return m_nOldSel; }
void SetOldSelection(int nOldSel) { m_nOldSel = nOldSel; } void SetOldSelection(int nOldSel) { m_nOldSel = nOldSel; }
private: private:
int m_nSel, // currently selected page int m_nSel, // currently selected page
m_nOldSel; // previously 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 // make a default book control for given platform
#if wxUSE_NOTEBOOK #if wxUSE_NOTEBOOK
// dedicated to majority of desktops // dedicated to majority of desktops
#include "wx/notebook.h" #include "wx/notebook.h"
#define wxBookCtrl wxNotebook #define wxBookCtrl wxNotebook
#define wxEVT_BOOKCTRL_PAGE_CHANGED wxEVT_NOTEBOOK_PAGE_CHANGED #define wxBookCtrlEvent wxNotebookEvent
#define wxEVT_BOOKCTRL_PAGE_CHANGING wxEVT_NOTEBOOK_PAGE_CHANGING #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_CHANGED(id, fn) EVT_NOTEBOOK_PAGE_CHANGED(id, fn)
#define EVT_BOOKCTRL_PAGE_CHANGING(id, fn) EVT_NOTEBOOK_PAGE_CHANGING(id, fn) #define EVT_BOOKCTRL_PAGE_CHANGING(id, fn) EVT_NOTEBOOK_PAGE_CHANGING(id, fn)
#define wxBookctrlEventHandler(func) wxNotebookEventHandler(func)
#else #else
// dedicated to Smartphones // dedicated to Smartphones
#include "wx/choicebk.h" #include "wx/choicebk.h"
#define wxBookCtrl wxChoicebook #define wxBookCtrl wxChoicebook
#define wxEVT_BOOKCTRL_PAGE_CHANGED wxEVT_CHOICEBOOK_PAGE_CHANGED #define wxBookCtrlEvent wxChoicebookEvent
#define wxEVT_BOOKCTRL_PAGE_CHANGING wxEVT_CHOICEBOOK_PAGE_CHANGING #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_CHANGED(id, fn) EVT_CHOICEBOOK_PAGE_CHANGED(id, fn)
#define EVT_BOOKCTRL_PAGE_CHANGING(id, fn) EVT_CHOICEBOOK_PAGE_CHANGING(id, fn) #define EVT_BOOKCTRL_PAGE_CHANGING(id, fn) EVT_CHOICEBOOK_PAGE_CHANGING(id, fn)
#define wxBookctrlEventHandler(func) wxChoicebookEventHandler(func)
#endif #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 #if WXWIN_COMPATIBILITY_2_6
#define wxBC_TOP wxBK_TOP #define wxBC_TOP wxBK_TOP
#define wxBC_BOTTOM wxBK_BOTTOM #define wxBC_BOTTOM wxBK_BOTTOM

View File

@ -4,6 +4,7 @@
// Author: Julian Smart // Author: Julian Smart
// Modified by: // Modified by:
// Created: // Created:
// RCS-ID: $Id: brush.h 40865 2006-08-27 09:42:42Z VS $
// Copyright: Julian Smart // Copyright: Julian Smart
// Licence: wxWindows Licence // Licence: wxWindows Licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
@ -14,62 +15,22 @@
#include "wx/defs.h" #include "wx/defs.h"
#include "wx/object.h" #include "wx/object.h"
#include "wx/gdiobj.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 // wxBrushBase
class WXDLLIMPEXP_CORE wxBrushBase: public wxGDIObject class WXDLLEXPORT wxBrushBase: public wxGDIObject
{ {
public: public:
virtual ~wxBrushBase() { } virtual ~wxBrushBase() { }
virtual void SetColour(const wxColour& col) = 0; virtual int GetStyle() const = 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 bool IsHatch() const virtual bool IsHatch() const
{ return (GetStyle()>=wxBRUSHSTYLE_FIRST_HATCH) && (GetStyle()<=wxBRUSHSTYLE_LAST_HATCH); } { return (GetStyle()>=wxFIRST_HATCH) && (GetStyle()<=wxLAST_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;
}
}; };
#if defined(__WXMSW__) #if defined(__WXPALMOS__)
#include "wx/palmos/brush.h"
#elif defined(__WXMSW__)
#include "wx/msw/brush.h" #include "wx/msw/brush.h"
#elif defined(__WXMOTIF__) || defined(__WXX11__) #elif defined(__WXMOTIF__) || defined(__WXX11__)
#include "wx/x11/brush.h" #include "wx/x11/brush.h"
@ -77,60 +38,17 @@ public:
#include "wx/gtk/brush.h" #include "wx/gtk/brush.h"
#elif defined(__WXGTK__) #elif defined(__WXGTK__)
#include "wx/gtk1/brush.h" #include "wx/gtk1/brush.h"
#elif defined(__WXMGL__)
#include "wx/mgl/brush.h"
#elif defined(__WXDFB__) #elif defined(__WXDFB__)
#include "wx/dfb/brush.h" #include "wx/dfb/brush.h"
#elif defined(__WXMAC__) #elif defined(__WXMAC__)
#include "wx/osx/brush.h" #include "wx/mac/brush.h"
#elif defined(__WXCOCOA__) #elif defined(__WXCOCOA__)
#include "wx/cocoa/brush.h" #include "wx/cocoa/brush.h"
#elif defined(__WXPM__) #elif defined(__WXPM__)
#include "wx/os2/brush.h" #include "wx/os2/brush.h"
#endif #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 #endif
// _WX_BRUSH_H_BASE_
#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<int>(s) == static_cast<int>(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_

View File

@ -4,6 +4,7 @@
// Author: Vadim Zeitlin // Author: Vadim Zeitlin
// Modified by: // Modified by:
// Created: 12.04.99 // Created: 12.04.99
// RCS-ID: $Id: buffer.h 61872 2009-09-09 22:37:05Z VZ $
// Copyright: (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr> // Copyright: (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
// Licence: wxWindows licence // Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
@ -11,426 +12,144 @@
#ifndef _WX_BUFFER_H #ifndef _WX_BUFFER_H
#define _WX_BUFFER_H #define _WX_BUFFER_H
#include "wx/chartype.h" #include "wx/wxchar.h"
#include "wx/wxcrtbase.h"
#include <stdlib.h> // malloc() and free() #include <stdlib.h> // malloc() and free()
class WXDLLIMPEXP_FWD_BASE wxCStrData;
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// Special classes for (wide) character strings: they use malloc/free instead // Special classes for (wide) character strings: they use malloc/free instead
// of new/delete // of new/delete
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// helpers used by wxCharTypeBuffer #define DEFINE_BUFFER(classname, chartype, strdupfunc) \
namespace wxPrivate class WXDLLIMPEXP_BASE classname \
{ { \
public: \
struct UntypedBufferData classname(const chartype *str = NULL) \
{ : m_str(str ? strdupfunc(str) : NULL) \
enum Kind { \
{ } \
Owned, \
NonOwned classname(size_t len) \
}; : m_str((chartype *)malloc((len + 1)*sizeof(chartype))) \
{ \
UntypedBufferData(void *str, size_t len, Kind kind = Owned) m_str[len] = (chartype)0; \
: m_str(str), m_length(len), m_ref(1), m_owned(kind == Owned) {} } \
\
~UntypedBufferData() /* no need to check for NULL, free() does it */ \
{ ~classname() { free(m_str); } \
if ( m_owned ) \
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; \
} }
void *m_str; #if wxABI_VERSION >= 20804
size_t m_length; // needed for wxString::char_str() and wchar_str()
#define DEFINE_WRITABLE_BUFFER(classname, baseclass, chartype) \
// "short" to have sizeof(Data)=12 on 32bit archs class WXDLLIMPEXP_BASE classname : public baseclass \
unsigned short m_ref; { \
public: \
bool m_owned; classname(const baseclass& src) : baseclass(src) {} \
}; classname(const chartype *str = NULL) : baseclass(str) {} \
\
// NB: this is defined in string.cpp and not the (non-existent) buffer.cpp operator chartype*() { return this->data(); } \
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<T> for persistent variant.
template <typename T>
class wxScopedCharTypeBuffer
{
public:
typedef T CharType;
wxScopedCharTypeBuffer()
{
m_data = GetNullData();
} }
#endif // wxABI_VERSION >= 20804
// Creates "non-owned" buffer, i.e. 'str' is not owned by the buffer DEFINE_BUFFER(wxCharBuffer, char, wxStrdupA);
// and doesn't get freed by dtor. Used e.g. to point to wxString's internal #if wxABI_VERSION >= 20804
// storage. DEFINE_WRITABLE_BUFFER(wxWritableCharBuffer, wxCharBuffer, char);
static #endif
const wxScopedCharTypeBuffer CreateNonOwned(const CharType *str,
size_t len = wxNO_LEN)
{
if ( len == wxNO_LEN )
len = wxStrlen(str);
wxScopedCharTypeBuffer buf; #if wxUSE_WCHAR_T
if ( str )
buf.m_data = new Data(const_cast<CharType*>(str), len, Data::NonOwned);
return buf;
}
// Creates "owned" buffer, i.e. takes over ownership of 'str' and frees it DEFINE_BUFFER(wxWCharBuffer, wchar_t, wxStrdupW);
// in dtor (if ref.count reaches 0). #if wxABI_VERSION >= 20804
static DEFINE_WRITABLE_BUFFER(wxWritableWCharBuffer, wxWCharBuffer, wchar_t);
const wxScopedCharTypeBuffer CreateOwned(CharType *str, #endif
size_t len = wxNO_LEN )
{
if ( len == wxNO_LEN )
len = wxStrlen(str);
wxScopedCharTypeBuffer buf; #endif // wxUSE_WCHAR_T
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<wxScopedCharTypeBuffer*>(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<CharType *>(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<Data *>(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<char> wxScopedCharBuffer;
typedef wxScopedCharTypeBuffer<wchar_t> wxScopedWCharBuffer;
// this buffer class always stores data in "owned" (persistent) manner
template <typename T>
class wxCharTypeBuffer : public wxScopedCharTypeBuffer<T>
{
protected:
typedef typename wxScopedCharTypeBuffer<T>::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<T>(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<T>::operator=(src);
return *this;
}
wxCharTypeBuffer(const wxScopedCharTypeBuffer<T>& src)
{
this->MakeOwnedCopyOf(src);
}
wxCharTypeBuffer& operator=(const wxScopedCharTypeBuffer<T>& 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<char> )
WXDLLIMPEXP_TEMPLATE_INSTANCE_BASE( wxCharTypeBuffer<char> )
class wxCharBuffer : public wxCharTypeBuffer<char>
{
public:
typedef wxCharTypeBuffer<char> wxCharTypeBufferBase;
typedef wxScopedCharTypeBuffer<char> 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<wchar_t> )
WXDLLIMPEXP_TEMPLATE_INSTANCE_BASE( wxCharTypeBuffer<wchar_t> )
class wxWCharBuffer : public wxCharTypeBuffer<wchar_t>
{
public:
typedef wxCharTypeBuffer<wchar_t> wxCharTypeBufferBase;
typedef wxScopedCharTypeBuffer<wchar_t> 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<T> implicitly convertible to T*
template <typename T>
class wxWritableCharTypeBuffer : public wxCharTypeBuffer<T>
{
public:
typedef typename wxScopedCharTypeBuffer<T>::CharType CharType;
wxWritableCharTypeBuffer(const wxScopedCharTypeBuffer<T>& src)
: wxCharTypeBuffer<T>(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<T>(str) {}
operator CharType*() { return this->data(); }
};
typedef wxWritableCharTypeBuffer<char> wxWritableCharBuffer;
typedef wxWritableCharTypeBuffer<wchar_t> wxWritableWCharBuffer;
#undef DEFINE_BUFFER
#undef DEFINE_WRITABLE_BUFFER
#if wxUSE_UNICODE #if wxUSE_UNICODE
#define wxWxCharBuffer wxWCharBuffer typedef wxWCharBuffer wxWxCharBuffer;
#define wxMB2WXbuf wxWCharBuffer #define wxMB2WXbuf wxWCharBuffer
#define wxWX2MBbuf wxCharBuffer #define wxWX2MBbuf wxCharBuffer
#if wxUSE_UNICODE_WCHAR
#define wxWC2WXbuf wxChar* #define wxWC2WXbuf wxChar*
#define wxWX2WCbuf wxChar* #define wxWX2WCbuf wxChar*
#elif wxUSE_UNICODE_UTF8
#define wxWC2WXbuf wxWCharBuffer
#define wxWX2WCbuf wxWCharBuffer
#endif
#else // ANSI #else // ANSI
#define wxWxCharBuffer wxCharBuffer typedef wxCharBuffer wxWxCharBuffer;
#define wxMB2WXbuf wxChar* #define wxMB2WXbuf wxChar*
#define wxWX2MBbuf wxChar* #define wxWX2MBbuf wxChar*
@ -451,7 +170,7 @@ public:
friend class wxMemoryBuffer; 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: private:
wxMemoryBufferData(size_t size = wxMemoryBufferData::DefBufSize) wxMemoryBufferData(size_t size = wxMemoryBufferData::DefBufSize)
: m_data(size ? malloc(size) : NULL), m_size(size), m_len(0), m_ref(0) : m_data(size ? malloc(size) : NULL), m_size(size), m_len(0), m_ref(0)
@ -483,21 +202,6 @@ private:
delete this; 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 // the buffer containing the data
void *m_data; void *m_data;
@ -511,7 +215,7 @@ private:
// the reference count // the reference count
size_t m_ref; size_t m_ref;
wxDECLARE_NO_COPY_CLASS(wxMemoryBufferData); DECLARE_NO_COPY_CLASS(wxMemoryBufferData)
}; };
@ -536,13 +240,10 @@ public:
} }
wxMemoryBuffer& operator=(const wxMemoryBuffer& src) wxMemoryBuffer& operator=(const wxMemoryBuffer& src)
{
if (&src != this)
{ {
m_bufdata->DecRef(); m_bufdata->DecRef();
m_bufdata = src.m_bufdata; m_bufdata = src.m_bufdata;
m_bufdata->IncRef(); m_bufdata->IncRef();
}
return *this; return *this;
} }
@ -552,8 +253,6 @@ public:
size_t GetBufSize() const { return m_bufdata->m_size; } size_t GetBufSize() const { return m_bufdata->m_size; }
size_t GetDataLen() const { return m_bufdata->m_len; } 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 SetBufSize(size_t size) { m_bufdata->ResizeIfNeeded(size); }
void SetDataLen(size_t len) void SetDataLen(size_t len)
{ {
@ -561,8 +260,6 @@ public:
m_bufdata->m_len = len; m_bufdata->m_len = len;
} }
void Clear() { SetDataLen(0); }
// Ensure the buffer is big enough and return a pointer to it // Ensure the buffer is big enough and return a pointer to it
void *GetWriteBuf(size_t sizeNeeded) void *GetWriteBuf(size_t sizeNeeded)
{ {
@ -604,13 +301,6 @@ public:
operator const char *() const { return (const char*)GetData(); } 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: private:
wxMemoryBufferData* m_bufdata; wxMemoryBufferData* m_bufdata;
}; };

View File

@ -4,6 +4,7 @@
// Author: Vadim Zeitlin, Vaclav Slavik // Author: Vadim Zeitlin, Vaclav Slavik
// Modified by: // Modified by:
// Created: 07.05.02 // Created: 07.05.02
// RCS-ID: $Id: build.h 35858 2005-10-09 15:48:42Z MBN $
// Copyright: (c) 2002 Vadim Zeitlin <vadim@wxwidgets.org> // Copyright: (c) 2002 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence: wxWindows licence // Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
@ -14,7 +15,7 @@
#include "wx/version.h" #include "wx/version.h"
// NB: This file contains macros for checking binary compatibility of libraries // 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 // The WX_BUILD_OPTIONS_SIGNATURE macro expands into string that should
// uniquely identify binary compatible builds: i.e. if two builds of the // uniquely identify binary compatible builds: i.e. if two builds of the
// library are binary compatible, their signature string should be 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) __WX_BO_STRINGIZE(x) "." __WX_BO_STRINGIZE(y) "." __WX_BO_STRINGIZE(z)
#endif #endif
#if wxUSE_UNICODE_UTF8 #ifdef __WXDEBUG__
#define __WX_BO_UNICODE "UTF-8" #define __WX_BO_DEBUG "debug"
#elif wxUSE_UNICODE_WCHAR #else
#define __WX_BO_UNICODE "wchar_t" #define __WX_BO_DEBUG "no debug"
#endif
#if wxUSE_UNICODE
#define __WX_BO_UNICODE "Unicode"
#else #else
#define __WX_BO_UNICODE "ANSI" #define __WX_BO_UNICODE "ANSI"
#endif #endif
@ -54,16 +59,13 @@
#if defined(__GXX_ABI_VERSION) #if defined(__GXX_ABI_VERSION)
#define __WX_BO_COMPILER \ #define __WX_BO_COMPILER \
",compiler with C++ ABI " __WX_BO_STRINGIZE(__GXX_ABI_VERSION) ",compiler with C++ ABI " __WX_BO_STRINGIZE(__GXX_ABI_VERSION)
#elif defined(__INTEL_COMPILER)
#define __WX_BO_COMPILER ",Intel C++"
#elif defined(__GNUG__) #elif defined(__GNUG__)
#define __WX_BO_COMPILER ",GCC " \ #define __WX_BO_COMPILER ",GCC " \
__WX_BO_STRINGIZE(__GNUC__) "." __WX_BO_STRINGIZE(__GNUC_MINOR__) __WX_BO_STRINGIZE(__GNUC__) "." __WX_BO_STRINGIZE(__GNUC_MINOR__)
#elif defined(__VISUALC__) #elif defined(__VISUALC__)
#define __WX_BO_COMPILER ",Visual C++ " __WX_BO_STRINGIZE(_MSC_VER) #define __WX_BO_COMPILER ",Visual C++"
#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++"
#elif defined(__BORLANDC__) #elif defined(__BORLANDC__)
#define __WX_BO_COMPILER ",Borland C++" #define __WX_BO_COMPILER ",Borland C++"
#elif defined(__DIGITALMARS__) #elif defined(__DIGITALMARS__)
@ -75,19 +77,19 @@
#endif #endif
// WXWIN_COMPATIBILITY macros affect presence of virtual functions // 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 #if WXWIN_COMPATIBILITY_2_6
#define __WX_BO_WXWIN_COMPAT_2_6 ",compatible with 2.6" #define __WX_BO_WXWIN_COMPAT_2_6 ",compatible with 2.6"
#else #else
#define __WX_BO_WXWIN_COMPAT_2_6 #define __WX_BO_WXWIN_COMPAT_2_6
#endif #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: // deriving wxWin containers from STL ones changes them completely:
#if wxUSE_STD_CONTAINERS #if wxUSE_STL
#define __WX_BO_STL ",STL containers" #define __WX_BO_STL ",STL containers"
#else #else
#define __WX_BO_STL ",wx containers" #define __WX_BO_STL ",wx containers"
@ -96,10 +98,10 @@
// This macro is passed as argument to wxConsoleApp::CheckBuildOptions() // This macro is passed as argument to wxConsoleApp::CheckBuildOptions()
#define WX_BUILD_OPTIONS_SIGNATURE \ #define WX_BUILD_OPTIONS_SIGNATURE \
__WX_BO_VERSION(wxMAJOR_VERSION, wxMINOR_VERSION, wxRELEASE_NUMBER) \ __WX_BO_VERSION(wxMAJOR_VERSION, wxMINOR_VERSION, wxRELEASE_NUMBER) \
" (" __WX_BO_UNICODE \ " (" __WX_BO_DEBUG "," __WX_BO_UNICODE \
__WX_BO_COMPILER \ __WX_BO_COMPILER \
__WX_BO_STL \ __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 // 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) \ #define WX_CHECK_BUILD_OPTIONS(libName) \
static struct wxBuildOptionsChecker \ static struct wxBuildOptionsChecker \
{ \ { \
@ -120,4 +122,28 @@
} gs_buildOptionsCheck; } 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_ #endif // _WX_BUILD_H_

View File

@ -3,6 +3,7 @@
// Purpose: Information window (when app is busy) // Purpose: Information window (when app is busy)
// Author: Vaclav Slavik // Author: Vaclav Slavik
// Copyright: (c) 1999 Vaclav Slavik // Copyright: (c) 1999 Vaclav Slavik
// RCS-ID: $Id: busyinfo.h 37158 2006-01-26 15:40:46Z ABX $
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////

View File

@ -4,6 +4,7 @@
// Author: Vadim Zetlin // Author: Vadim Zetlin
// Modified by: // Modified by:
// Created: 15.08.00 // Created: 15.08.00
// RCS-ID: $Id: button.h 49563 2007-10-31 20:46:21Z VZ $
// Copyright: (c) Vadim Zetlin // Copyright: (c) Vadim Zetlin
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
@ -13,37 +14,70 @@
#include "wx/defs.h" #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 #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 // wxButton: a push button
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxButtonBase : public wxAnyButton class WXDLLEXPORT wxButtonBase : public wxControl
{ {
public: public:
wxButtonBase() { } wxButtonBase() { }
// show the authentication needed symbol on the button: this is currently // show the image in the button in addition to the label
// only implemented on Windows Vista and newer (on which it shows the UAC virtual void SetImageLabel(const wxBitmap& WXUNUSED(bitmap)) { }
// shield symbol)
void SetAuthNeeded(bool show = true) { DoSetAuthNeeded(show); }
bool GetAuthNeeded() const { return DoGetAuthNeeded(); }
// make this button the default button in its top level window // set the margins around the image
// virtual void SetImageMargins(wxCoord WXUNUSED(x), wxCoord WXUNUSED(y)) { }
// returns the old default item (possibly NULL)
virtual wxWindow *SetDefault(); // 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 // returns the default button size for this platform
static wxSize GetDefaultSize(); static wxSize GetDefaultSize();
protected: protected:
wxDECLARE_NO_COPY_CLASS(wxButtonBase); DECLARE_NO_COPY_CLASS(wxButtonBase)
}; };
#if defined(__WXUNIVERSAL__) #if defined(__WXUNIVERSAL__)
@ -57,13 +91,16 @@ protected:
#elif defined(__WXGTK__) #elif defined(__WXGTK__)
#include "wx/gtk1/button.h" #include "wx/gtk1/button.h"
#elif defined(__WXMAC__) #elif defined(__WXMAC__)
#include "wx/osx/button.h" #include "wx/mac/button.h"
#elif defined(__WXCOCOA__) #elif defined(__WXCOCOA__)
#include "wx/cocoa/button.h" #include "wx/cocoa/button.h"
#elif defined(__WXPM__) #elif defined(__WXPM__)
#include "wx/os2/button.h" #include "wx/os2/button.h"
#elif defined(__WXPALMOS__)
#include "wx/palmos/button.h"
#endif #endif
#endif // wxUSE_BUTTON #endif // wxUSE_BUTTON
#endif // _WX_BUTTON_H_BASE_ #endif
// _WX_BUTTON_H_BASE_

View File

@ -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 <zeitlin@dptmaths.ens-cachan.fr>
// 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_

View File

@ -4,6 +4,7 @@
// Author: Vadim Zeitlin // Author: Vadim Zeitlin
// Modified by: // Modified by:
// Created: 23.05.99 // Created: 23.05.99
// RCS-ID: $Id: caret.h 49804 2007-11-10 01:09:42Z VZ $
// Copyright: (c) wxWidgets team // Copyright: (c) wxWidgets team
// Licence: wxWindows licence // 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) // appear. It can be either a solid block or a custom bitmap (TODO)
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxCaretBase class WXDLLEXPORT wxCaretBase
{ {
public: public:
// ctors // ctors
@ -146,7 +147,7 @@ public:
virtual void OnKillFocus() { } virtual void OnKillFocus() { }
protected: 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 // should call the base class version first
virtual bool DoCreate(wxWindowBase *window, int width, int height) virtual bool DoCreate(wxWindowBase *window, int width, int height)
{ {
@ -166,7 +167,7 @@ protected:
// the common initialization // the common initialization
void Init() void Init()
{ {
m_window = NULL; m_window = (wxWindowBase *)NULL;
m_x = m_y = 0; m_x = m_y = 0;
m_width = m_height = 0; m_width = m_height = 0;
m_countVisible = 0; m_countVisible = 0;
@ -185,7 +186,7 @@ protected:
int m_countVisible; int m_countVisible;
private: private:
wxDECLARE_NO_COPY_CLASS(wxCaretBase); DECLARE_NO_COPY_CLASS(wxCaretBase)
}; };
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
@ -207,17 +208,17 @@ private:
#ifdef wxHAS_CARET_USING_OVERLAYS #ifdef wxHAS_CARET_USING_OVERLAYS
// we don't need to hide the caret if it's rendered using overlays // we don't need to hide the caret if it's rendered using overlays
class WXDLLIMPEXP_CORE wxCaretSuspend class WXDLLEXPORT wxCaretSuspend
{ {
public: public:
wxCaretSuspend(wxWindow *WXUNUSED(win)) {} wxCaretSuspend(wxWindow *WXUNUSED(win)) {}
wxDECLARE_NO_COPY_CLASS(wxCaretSuspend); DECLARE_NO_COPY_CLASS(wxCaretSuspend)
}; };
#else // !wxHAS_CARET_USING_OVERLAYS #else // !wxHAS_CARET_USING_OVERLAYS
class WXDLLIMPEXP_CORE wxCaretSuspend class WXDLLEXPORT wxCaretSuspend
{ {
public: public:
wxCaretSuspend(wxWindow *win) wxCaretSuspend(wxWindow *win)
@ -241,7 +242,7 @@ private:
wxCaret *m_caret; wxCaret *m_caret;
bool m_show; bool m_show;
wxDECLARE_NO_COPY_CLASS(wxCaretSuspend); DECLARE_NO_COPY_CLASS(wxCaretSuspend)
}; };
#endif // wxHAS_CARET_USING_OVERLAYS/!wxHAS_CARET_USING_OVERLAYS #endif // wxHAS_CARET_USING_OVERLAYS/!wxHAS_CARET_USING_OVERLAYS

View File

@ -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 <sys/types.h>
#ifdef __cplusplus
extern "C" {
#endif
#endif /* Cygwin */
#include <wchar.h>
#if defined(__CYGWIN__) && defined(__cplusplus)
}
#endif /* Cygwin and C++ */
#elif defined(HAVE_WCSTR_H)
/* old compilers have relevant declarations here */
#include <wcstr.h>
#elif defined(__FreeBSD__) || defined(__DARWIN__) || defined(__EMX__)
/* include stdlib.h for wchar_t */
#include <stdlib.h>
#endif /* HAVE_WCHAR_H */
#ifdef HAVE_WIDEC_H
#include <widec.h>
#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 <ctype.h>
#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 <stddef.h>
#include <string.h>
#include <ctype.h>
#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 <tchar.h>
/* 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 <ctype.h>
#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_ */

View File

@ -4,6 +4,7 @@
// Author: Vadim Zeitlin // Author: Vadim Zeitlin
// Modified by: // Modified by:
// Created: 07.09.00 // Created: 07.09.00
// RCS-ID: $Id: checkbox.h 39901 2006-06-30 10:51:44Z VS $
// Copyright: (c) wxWidgets team // Copyright: (c) wxWidgets team
// Licence: wxWindows licence // Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
@ -24,12 +25,8 @@
* Determine whether to use a 3-state or 2-state * Determine whether to use a 3-state or 2-state
* checkbox. 3-state enables to differentiate * checkbox. 3-state enables to differentiate
* between 'unchecked', 'checked' and 'undetermined'. * 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 #define wxCHK_3STATE 0x1000
/* /*
@ -40,13 +37,25 @@
*/ */
#define wxCHK_ALLOW_3RD_STATE_FOR_USER 0x2000 #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 // 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: public:
wxCheckBoxBase() { } wxCheckBoxBase() { }
@ -109,9 +118,6 @@ public:
} }
protected: protected:
// choose the default border for this window
virtual wxBorder GetDefaultBorder() const { return wxBORDER_NONE; }
virtual void DoSet3StateValue(wxCheckBoxState WXUNUSED(state)) { wxFAIL; } virtual void DoSet3StateValue(wxCheckBoxState WXUNUSED(state)) { wxFAIL; }
virtual wxCheckBoxState DoGet3StateValue() const virtual wxCheckBoxState DoGet3StateValue() const
@ -120,51 +126,10 @@ protected:
return wxCHK_UNCHECKED; 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: 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__) #if defined(__WXUNIVERSAL__)
#include "wx/univ/checkbox.h" #include "wx/univ/checkbox.h"
#elif defined(__WXMSW__) #elif defined(__WXMSW__)
@ -174,17 +139,18 @@ private:
#elif defined(__WXGTK20__) #elif defined(__WXGTK20__)
#include "wx/gtk/checkbox.h" #include "wx/gtk/checkbox.h"
#elif defined(__WXGTK__) #elif defined(__WXGTK__)
#undef wxHAS_3STATE_CHECKBOX
#include "wx/gtk1/checkbox.h" #include "wx/gtk1/checkbox.h"
#elif defined(__WXMAC__) #elif defined(__WXMAC__)
#include "wx/osx/checkbox.h" #include "wx/mac/checkbox.h"
#elif defined(__WXCOCOA__) #elif defined(__WXCOCOA__)
#include "wx/cocoa/checkbox.h" #include "wx/cocoa/checkbox.h"
#elif defined(__WXPM__) #elif defined(__WXPM__)
#undef wxHAS_3STATE_CHECKBOX
#include "wx/os2/checkbox.h" #include "wx/os2/checkbox.h"
#elif defined(__WXPALMOS__)
#include "wx/palmos/checkbox.h"
#endif #endif
#endif // wxUSE_CHECKBOX #endif // wxUSE_CHECKBOX
#endif // _WX_CHECKBOX_H_BASE_ #endif
// _WX_CHECKBOX_H_BASE_

View File

@ -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_

View File

@ -4,6 +4,7 @@
// Author: Vadim Zeitlin // Author: Vadim Zeitlin
// Modified by: // Modified by:
// Created: 12.09.00 // Created: 12.09.00
// RCS-ID: $Id: checklst.h 38319 2006-03-23 22:05:23Z VZ $
// Copyright: (c) Vadim Zeitlin // Copyright: (c) Vadim Zeitlin
// Licence: wxWindows licence // Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
@ -11,8 +12,6 @@
#ifndef _WX_CHECKLST_H_BASE_ #ifndef _WX_CHECKLST_H_BASE_
#define _WX_CHECKLST_H_BASE_ #define _WX_CHECKLST_H_BASE_
#include "wx/defs.h"
#if wxUSE_CHECKLISTBOX #if wxUSE_CHECKLISTBOX
#include "wx/listbox.h" #include "wx/listbox.h"
@ -21,7 +20,7 @@
// wxCheckListBox: a listbox whose items may be checked // wxCheckListBox: a listbox whose items may be checked
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxCheckListBoxBase : public class WXDLLEXPORT wxCheckListBoxBase : public
#ifdef __WXWINCE__ #ifdef __WXWINCE__
// keep virtuals synchronised // keep virtuals synchronised
wxListBoxBase wxListBoxBase
@ -36,9 +35,7 @@ public:
virtual bool IsChecked(unsigned int item) const = 0; virtual bool IsChecked(unsigned int item) const = 0;
virtual void Check(unsigned int item, bool check = true) = 0; virtual void Check(unsigned int item, bool check = true) = 0;
virtual unsigned int GetCheckedItems(wxArrayInt& checkedItems) const; DECLARE_NO_COPY_CLASS(wxCheckListBoxBase)
wxDECLARE_NO_COPY_CLASS(wxCheckListBoxBase);
}; };
#if defined(__WXUNIVERSAL__) #if defined(__WXUNIVERSAL__)
@ -54,7 +51,7 @@ public:
#elif defined(__WXGTK__) #elif defined(__WXGTK__)
#include "wx/gtk1/checklst.h" #include "wx/gtk1/checklst.h"
#elif defined(__WXMAC__) #elif defined(__WXMAC__)
#include "wx/osx/checklst.h" #include "wx/mac/checklst.h"
#elif defined(__WXCOCOA__) #elif defined(__WXCOCOA__)
#include "wx/cocoa/checklst.h" #include "wx/cocoa/checklst.h"
#elif defined(__WXPM__) #elif defined(__WXPM__)

File diff suppressed because it is too large Load Diff

View File

@ -1,9 +1,10 @@
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// Name: wx/choicdlg.h // Name: wx/choicdgg.h
// Purpose: Includes generic choice dialog file // Purpose: Includes generic choice dialog file
// Author: Julian Smart // Author: Julian Smart
// Modified by: // Modified by:
// Created: // Created:
// RCS-ID: $Id: choicdlg.h 33948 2005-05-04 18:57:50Z JS $
// Copyright: Julian Smart // Copyright: Julian Smart
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
@ -11,12 +12,11 @@
#ifndef _WX_CHOICDLG_H_BASE_ #ifndef _WX_CHOICDLG_H_BASE_
#define _WX_CHOICDLG_H_BASE_ #define _WX_CHOICDLG_H_BASE_
#include "wx/defs.h"
#if wxUSE_CHOICEDLG #if wxUSE_CHOICEDLG
#include "wx/generic/choicdgg.h" #include "wx/generic/choicdgg.h"
#endif #endif
#endif // _WX_CHOICDLG_H_BASE_ #endif
// _WX_CHOICDLG_H_BASE_

View File

@ -4,6 +4,7 @@
// Author: Vadim Zeitlin // Author: Vadim Zeitlin
// Modified by: // Modified by:
// Created: 26.07.99 // Created: 26.07.99
// RCS-ID: $Id: choice.h 42727 2006-10-30 16:04:27Z VZ $
// Copyright: (c) wxWidgets team // Copyright: (c) wxWidgets team
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
@ -25,13 +26,13 @@
// global data // 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 // wxChoice allows to select one of a non-modifiable list of strings
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxChoiceBase : public wxControlWithItems class WXDLLEXPORT wxChoiceBase : public wxControlWithItems
{ {
public: public:
wxChoiceBase() { } wxChoiceBase() { }
@ -54,18 +55,8 @@ public:
// emulate selecting the item event.GetInt() // emulate selecting the item event.GetInt()
void Command(wxCommandEvent& event); 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: private:
wxDECLARE_NO_COPY_CLASS(wxChoiceBase); DECLARE_NO_COPY_CLASS(wxChoiceBase)
}; };
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@ -85,7 +76,7 @@ private:
#elif defined(__WXGTK__) #elif defined(__WXGTK__)
#include "wx/gtk1/choice.h" #include "wx/gtk1/choice.h"
#elif defined(__WXMAC__) #elif defined(__WXMAC__)
#include "wx/osx/choice.h" #include "wx/mac/choice.h"
#elif defined(__WXCOCOA__) #elif defined(__WXCOCOA__)
#include "wx/cocoa/choice.h" #include "wx/cocoa/choice.h"
#elif defined(__WXPM__) #elif defined(__WXPM__)

View File

@ -4,6 +4,7 @@
// Author: Vadim Zeitlin // Author: Vadim Zeitlin
// Modified by: Wlodzimierz ABX Skiba from wx/listbook.h // Modified by: Wlodzimierz ABX Skiba from wx/listbook.h
// Created: 15.09.04 // Created: 15.09.04
// RCS-ID: $Id: choicebk.h 59616 2009-03-18 21:58:15Z VZ $
// Copyright: (c) Vadim Zeitlin, Wlodzimierz Skiba // Copyright: (c) Vadim Zeitlin, Wlodzimierz Skiba
// Licence: wxWindows licence // Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
@ -17,12 +18,11 @@
#include "wx/bookctrl.h" #include "wx/bookctrl.h"
#include "wx/choice.h" #include "wx/choice.h"
#include "wx/containr.h"
class WXDLLIMPEXP_FWD_CORE wxChoice; class WXDLLIMPEXP_FWD_CORE wxChoice;
wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_CHOICEBOOK_PAGE_CHANGED, wxBookCtrlEvent ); extern WXDLLIMPEXP_CORE const wxEventType wxEVT_COMMAND_CHOICEBOOK_PAGE_CHANGED;
wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_CHOICEBOOK_PAGE_CHANGING, wxBookCtrlEvent ); extern WXDLLIMPEXP_CORE const wxEventType wxEVT_COMMAND_CHOICEBOOK_PAGE_CHANGING;
// wxChoicebook flags // wxChoicebook flags
#define wxCHB_DEFAULT wxBK_DEFAULT #define wxCHB_DEFAULT wxBK_DEFAULT
@ -36,10 +36,13 @@ wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_CHOICEBOOK_PAGE_CHANGING, wxBo
// wxChoicebook // wxChoicebook
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxChoicebook : public wxNavigationEnabled<wxBookCtrlBase> class WXDLLEXPORT wxChoicebook : public wxBookCtrlBase
{ {
public: public:
wxChoicebook() { } wxChoicebook()
{
Init();
}
wxChoicebook(wxWindow *parent, wxChoicebook(wxWindow *parent,
wxWindowID id, wxWindowID id,
@ -48,6 +51,8 @@ public:
long style = 0, long style = 0,
const wxString& name = wxEmptyString) const wxString& name = wxEmptyString)
{ {
Init();
(void)Create(parent, id, pos, size, style, name); (void)Create(parent, id, pos, size, style, name);
} }
@ -60,17 +65,18 @@ public:
const wxString& name = wxEmptyString); const wxString& name = wxEmptyString);
virtual int GetSelection() const;
virtual bool SetPageText(size_t n, const wxString& strText); virtual bool SetPageText(size_t n, const wxString& strText);
virtual wxString GetPageText(size_t n) const; virtual wxString GetPageText(size_t n) const;
virtual int GetPageImage(size_t n) const; virtual int GetPageImage(size_t n) const;
virtual bool SetPageImage(size_t n, int imageId); virtual bool SetPageImage(size_t n, int imageId);
virtual wxSize CalcSizeFromPage(const wxSize& sizePage) const;
virtual bool InsertPage(size_t n, virtual bool InsertPage(size_t n,
wxWindow *page, wxWindow *page,
const wxString& text, const wxString& text,
bool bSelect = false, bool bSelect = false,
int imageId = NO_IMAGE); int imageId = -1);
virtual int SetSelection(size_t n) virtual int SetSelection(size_t n) { return DoSetSelection(n, SetSelection_SendEvent); }
{ return DoSetSelection(n, SetSelection_SendEvent); }
virtual int ChangeSelection(size_t n) { return DoSetSelection(n); } virtual int ChangeSelection(size_t n) { return DoSetSelection(n); }
virtual void SetImageList(wxImageList *imageList); virtual void SetImageList(wxImageList *imageList);
@ -79,29 +85,31 @@ public:
// returns the choice control // returns the choice control
wxChoice* GetChoiceCtrl() const { return (wxChoice*)m_bookctrl; } 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: protected:
virtual void DoSetWindowVariant(wxWindowVariant variant);
virtual wxWindow *DoRemovePage(size_t page); virtual wxWindow *DoRemovePage(size_t page);
// get the size which the choice control should have
virtual wxSize GetControllerSize() const;
void UpdateSelectedPage(size_t newsel) void UpdateSelectedPage(size_t newsel)
{ {
m_selection = static_cast<int>(newsel); m_selection = wx_static_cast(int, newsel);
GetChoiceCtrl()->Select(m_selection); GetChoiceCtrl()->Select(m_selection);
} }
wxBookCtrlEvent* CreatePageChangingEvent() const; wxBookCtrlBaseEvent* CreatePageChangingEvent() const;
void MakeChangedEvent(wxBookCtrlEvent &event); void MakeChangedEvent(wxBookCtrlBaseEvent &event);
// event handlers // event handlers
void OnChoiceSelected(wxCommandEvent& event); void OnChoiceSelected(wxCommandEvent& event);
// the currently selected page or wxNOT_FOUND if none
int m_selection;
private: private:
// common part of all constructors
void Init();
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
DECLARE_DYNAMIC_CLASS_NO_COPY(wxChoicebook) DECLARE_DYNAMIC_CLASS_NO_COPY(wxChoicebook)
}; };
@ -110,20 +118,36 @@ private:
// choicebook event class and related stuff // choicebook event class and related stuff
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// wxChoicebookEvent is obsolete and defined for compatibility only class WXDLLEXPORT wxChoicebookEvent : public wxBookCtrlBaseEvent
#define wxChoicebookEvent wxBookCtrlEvent {
typedef wxBookCtrlEventFunction wxChoicebookEventFunction; public:
#define wxChoicebookEventHandler(func) wxBookCtrlEventHandler(func) 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) \ #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) \ #define EVT_CHOICEBOOK_PAGE_CHANGING(winid, fn) \
wx__DECLARE_EVT1(wxEVT_CHOICEBOOK_PAGE_CHANGING, winid, wxBookCtrlEventHandler(fn)) wx__DECLARE_EVT1(wxEVT_COMMAND_CHOICEBOOK_PAGE_CHANGING, winid, wxChoicebookEventHandler(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
#endif // wxUSE_CHOICEBOOK #endif // wxUSE_CHOICEBOOK

View File

@ -4,6 +4,7 @@
// Author: Vadim Zeitlin // Author: Vadim Zeitlin
// Modified by: // Modified by:
// Created: 19.10.99 // Created: 19.10.99
// RCS-ID: $Id: clipbrd.h 49563 2007-10-31 20:46:21Z VZ $
// Copyright: (c) wxWidgets Team // Copyright: (c) wxWidgets Team
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
@ -16,11 +17,11 @@
#if wxUSE_CLIPBOARD #if wxUSE_CLIPBOARD
#include "wx/event.h" #include "wx/object.h"
#include "wx/chartype.h" #include "wx/wxchar.h"
#include "wx/dataobj.h" // for wxDataFormat
#include "wx/vector.h"
class WXDLLIMPEXP_FWD_CORE wxDataFormat;
class WXDLLIMPEXP_FWD_CORE wxDataObject;
class WXDLLIMPEXP_FWD_CORE wxClipboard; class WXDLLIMPEXP_FWD_CORE wxClipboard;
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@ -31,10 +32,10 @@ class WXDLLIMPEXP_FWD_CORE wxClipboard;
// with wxDataObject. // with wxDataObject.
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxClipboardBase : public wxObject class WXDLLEXPORT wxClipboardBase : public wxObject
{ {
public: public:
wxClipboardBase() { m_usePrimary = false; } wxClipboardBase() {}
// open the clipboard before Add/SetData() and GetData() // open the clipboard before Add/SetData() and GetData()
virtual bool Open() = 0; virtual bool Open() = 0;
@ -58,9 +59,6 @@ public:
// ask if data in correct format is available // ask if data in correct format is available
virtual bool IsSupported( const wxDataFormat& format ) = 0; 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) // fill data with data on the clipboard (if available)
virtual bool GetData( wxDataObject& data ) = 0; virtual bool GetData( wxDataObject& data ) = 0;
@ -72,72 +70,13 @@ public:
// eating memory), otherwise the clipboard will be emptied on exit // eating memory), otherwise the clipboard will be emptied on exit
virtual bool Flush() { return false; } virtual bool Flush() { return false; }
// this allows to choose whether we work with CLIPBOARD (default) or // X11 has two clipboards which get selected by this call. Empty on MSW.
// PRIMARY selection on X11-based systems virtual void UsePrimarySelection( bool WXUNUSED(primary) = false ) { }
//
// 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; }
// Returns global instance (wxTheClipboard) of the object: // Returns global instance (wxTheClipboard) of the object:
static wxClipboard *Get(); 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<wxDataFormat> 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 // globals
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@ -159,8 +98,10 @@ typedef void (wxEvtHandler::*wxClipboardEventFunction)(wxClipboardEvent&);
#include "wx/gtk1/clipbrd.h" #include "wx/gtk1/clipbrd.h"
#elif defined(__WXX11__) #elif defined(__WXX11__)
#include "wx/x11/clipbrd.h" #include "wx/x11/clipbrd.h"
#elif defined(__WXMGL__)
#include "wx/mgl/clipbrd.h"
#elif defined(__WXMAC__) #elif defined(__WXMAC__)
#include "wx/osx/clipbrd.h" #include "wx/mac/clipbrd.h"
#elif defined(__WXCOCOA__) #elif defined(__WXCOCOA__)
#include "wx/cocoa/clipbrd.h" #include "wx/cocoa/clipbrd.h"
#elif defined(__WXPM__) #elif defined(__WXPM__)
@ -171,10 +112,10 @@ typedef void (wxEvtHandler::*wxClipboardEventFunction)(wxClipboardEvent&);
// helpful class for opening the clipboard and automatically closing it // helpful class for opening the clipboard and automatically closing it
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxClipboardLocker class WXDLLEXPORT wxClipboardLocker
{ {
public: public:
wxClipboardLocker(wxClipboard *clipboard = NULL) wxClipboardLocker(wxClipboard *clipboard = (wxClipboard *)NULL)
{ {
m_clipboard = clipboard ? clipboard : wxTheClipboard; m_clipboard = clipboard ? clipboard : wxTheClipboard;
if ( m_clipboard ) if ( m_clipboard )
@ -196,7 +137,7 @@ public:
private: private:
wxClipboard *m_clipboard; wxClipboard *m_clipboard;
wxDECLARE_NO_COPY_CLASS(wxClipboardLocker); DECLARE_NO_COPY_CLASS(wxClipboardLocker)
}; };
#endif // wxUSE_CLIPBOARD #endif // wxUSE_CLIPBOARD

View File

@ -4,6 +4,7 @@
// Author: Robin Dunn // Author: Robin Dunn
// Modified by: // Modified by:
// Created: 9-Oct-2001 // Created: 9-Oct-2001
// RCS-ID: $Id: clntdata.h 36973 2006-01-18 16:45:41Z JS $
// Copyright: (c) wxWidgets team // Copyright: (c) wxWidgets team
// Licence: wxWindows licence // 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__ #endif // _WX_CLNTDATAH__

View File

@ -5,6 +5,7 @@
// Modified by: // Modified by:
// Created: 14/4/2006 // Created: 14/4/2006
// Copyright: (c) Vadim Zeitlin, Francesco Montorsi // Copyright: (c) Vadim Zeitlin, Francesco Montorsi
// RCS-ID: $Id: clrpicker.h 53135 2008-04-12 02:31:04Z VZ $
// Licence: wxWindows Licence // Licence: wxWindows Licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
@ -21,15 +22,8 @@
class WXDLLIMPEXP_FWD_CORE wxColourPickerEvent; class WXDLLIMPEXP_FWD_CORE wxColourPickerEvent;
extern WXDLLIMPEXP_DATA_CORE(const char) wxColourPickerWidgetNameStr[]; extern WXDLLEXPORT_DATA(const wxChar) wxColourPickerWidgetNameStr[];
extern WXDLLIMPEXP_DATA_CORE(const char) wxColourPickerCtrlNameStr[]; extern WXDLLEXPORT_DATA(const wxChar) 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)
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@ -76,7 +70,7 @@ protected:
// same prototype for their contructor (and also explains why we use // same prototype for their contructor (and also explains why we use
// define instead of a typedef) // define instead of a typedef)
// since GTK > 2.4, there is GtkColorButton // since GTK > 2.4, there is GtkColorButton
#if defined(__WXGTK20__) && !defined(__WXUNIVERSAL__) #if defined(__WXGTK24__) && !defined(__WXUNIVERSAL__)
#include "wx/gtk/clrpicker.h" #include "wx/gtk/clrpicker.h"
#define wxColourPickerWidget wxColourButton #define wxColourPickerWidget wxColourButton
#else #else
@ -97,7 +91,7 @@ protected:
class WXDLLIMPEXP_CORE wxColourPickerCtrl : public wxPickerBase class WXDLLIMPEXP_CORE wxColourPickerCtrl : public wxPickerBase
{ {
public: public:
wxColourPickerCtrl() {} wxColourPickerCtrl() : m_bIgnoreNextTextCtrlUpdate(false) {}
virtual ~wxColourPickerCtrl() {} virtual ~wxColourPickerCtrl() {}
@ -106,6 +100,7 @@ public:
const wxSize& size = wxDefaultSize, long style = wxCLRP_DEFAULT_STYLE, const wxSize& size = wxDefaultSize, long style = wxCLRP_DEFAULT_STYLE,
const wxValidator& validator = wxDefaultValidator, const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxColourPickerCtrlNameStr) const wxString& name = wxColourPickerCtrlNameStr)
: m_bIgnoreNextTextCtrlUpdate(false)
{ Create(parent, id, col, pos, size, style, validator, name); } { Create(parent, id, col, pos, size, style, validator, name); }
bool Create(wxWindow *parent, wxWindowID id, bool Create(wxWindow *parent, wxWindowID id,
@ -146,6 +141,9 @@ protected:
virtual long GetPickerStyle(long style) const virtual long GetPickerStyle(long style) const
{ return (style & wxCLRP_SHOW_LABEL); } { return (style & wxCLRP_SHOW_LABEL); }
// true if the next UpdateTextCtrl() call is to ignore
bool m_bIgnoreNextTextCtrlUpdate;
private: private:
DECLARE_DYNAMIC_CLASS(wxColourPickerCtrl) DECLARE_DYNAMIC_CLASS(wxColourPickerCtrl)
}; };
@ -155,14 +153,16 @@ private:
// wxColourPickerEvent: used by wxColourPickerCtrl only // 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 class WXDLLIMPEXP_CORE wxColourPickerEvent : public wxCommandEvent
{ {
public: public:
wxColourPickerEvent() {} wxColourPickerEvent() {}
wxColourPickerEvent(wxObject *generator, int id, const wxColour &col) wxColourPickerEvent(wxObject *generator, int id, const wxColour &col)
: wxCommandEvent(wxEVT_COLOURPICKER_CHANGED, id), : wxCommandEvent(wxEVT_COMMAND_COLOURPICKER_CHANGED, id),
m_colour(col) m_colour(col)
{ {
SetEventObject(generator); SetEventObject(generator);
@ -188,15 +188,12 @@ private:
typedef void (wxEvtHandler::*wxColourPickerEventFunction)(wxColourPickerEvent&); typedef void (wxEvtHandler::*wxColourPickerEventFunction)(wxColourPickerEvent&);
#define wxColourPickerEventHandler(func) \ #define wxColourPickerEventHandler(func) \
wxEVENT_HANDLER_CAST(wxColourPickerEventFunction, func) (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxColourPickerEventFunction, &func)
#define EVT_COLOURPICKER_CHANGED(id, fn) \ #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 // wxUSE_COLOURPICKERCTRL
#endif // _WX_CLRPICKER_H_BASE_ #endif // _WX_CLRPICKER_H_BASE_

View File

@ -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 <vadim@wxwindows.org>
// 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 <typename T>
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 <typename T>
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_

View File

@ -5,6 +5,7 @@
// Author: Vadim Zeitlin // Author: Vadim Zeitlin
// Modified by: // Modified by:
// Created: 04.01.00 // Created: 04.01.00
// RCS-ID: $Id: cmdline.h 49563 2007-10-31 20:46:21Z VZ $
// Copyright: (c) 2000 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr> // Copyright: (c) 2000 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
// Licence: wxWindows licence // Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
@ -16,14 +17,6 @@
#include "wx/string.h" #include "wx/string.h"
#include "wx/arrstr.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 #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 // 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 // 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_OPTION_MANDATORY = 0x01, // this option must be given
wxCMD_LINE_PARAM_OPTIONAL = 0x02, // the parameter may be omitted wxCMD_LINE_PARAM_OPTIONAL = 0x02, // the parameter may be omitted
wxCMD_LINE_PARAM_MULTIPLE = 0x04, // the parameter may be repeated wxCMD_LINE_PARAM_MULTIPLE = 0x04, // the parameter may be repeated
wxCMD_LINE_OPTION_HELP = 0x08, // this option is a help request wxCMD_LINE_OPTION_HELP = 0x08, // this option is a help request
wxCMD_LINE_NEEDS_SEPARATOR = 0x10, // must have sep before the value wxCMD_LINE_NEEDS_SEPARATOR = 0x10 // must have sep before the value
wxCMD_LINE_SWITCH_NEGATABLE = 0x20 // this switch can be negated (e.g. /S-)
}; };
// an option value or parameter may be a string (the most common case), a // 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_STRING, // should be 0 (default)
wxCMD_LINE_VAL_NUMBER, wxCMD_LINE_VAL_NUMBER,
wxCMD_LINE_VAL_DATE, wxCMD_LINE_VAL_DATE,
wxCMD_LINE_VAL_DOUBLE,
wxCMD_LINE_VAL_NONE wxCMD_LINE_VAL_NONE
}; };
@ -62,18 +53,9 @@ enum wxCmdLineEntryType
wxCMD_LINE_SWITCH, wxCMD_LINE_SWITCH,
wxCMD_LINE_OPTION, wxCMD_LINE_OPTION,
wxCMD_LINE_PARAM, wxCMD_LINE_PARAM,
wxCMD_LINE_USAGE_TEXT,
wxCMD_LINE_NONE // to terminate the list 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 // wxCmdLineEntryDesc is a description of one command line
// switch/option/parameter // switch/option/parameter
@ -82,17 +64,13 @@ enum wxCmdLineSwitchState
struct wxCmdLineEntryDesc struct wxCmdLineEntryDesc
{ {
wxCmdLineEntryType kind; wxCmdLineEntryType kind;
const char *shortName; const wxChar *shortName;
const char *longName; const wxChar *longName;
const char *description; const wxChar *description;
wxCmdLineParamType type; wxCmdLineParamType type;
int flags; 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. // wxCmdLineParser is a class for parsing command line.
// //
@ -122,8 +100,6 @@ public:
wxCmdLineParser(int argc, char **argv) { Init(); SetCmdLine(argc, argv); } wxCmdLineParser(int argc, char **argv) { Init(); SetCmdLine(argc, argv); }
#if wxUSE_UNICODE #if wxUSE_UNICODE
wxCmdLineParser(int argc, wxChar **argv) { Init(); SetCmdLine(argc, argv); } wxCmdLineParser(int argc, wxChar **argv) { Init(); SetCmdLine(argc, argv); }
wxCmdLineParser(int argc, const wxCmdLineArgsArray& argv)
{ Init(); SetCmdLine(argc, argv); }
#endif // wxUSE_UNICODE #endif // wxUSE_UNICODE
wxCmdLineParser(const wxString& cmdline) { Init(); SetCmdLine(cmdline); } wxCmdLineParser(const wxString& cmdline) { Init(); SetCmdLine(cmdline); }
@ -136,10 +112,6 @@ public:
#if wxUSE_UNICODE #if wxUSE_UNICODE
wxCmdLineParser(const wxCmdLineEntryDesc *desc, int argc, wxChar **argv) wxCmdLineParser(const wxCmdLineEntryDesc *desc, int argc, wxChar **argv)
{ Init(); SetCmdLine(argc, argv); SetDesc(desc); } { Init(); SetCmdLine(argc, argv); SetDesc(desc); }
wxCmdLineParser(const wxCmdLineEntryDesc *desc,
int argc,
const wxCmdLineArgsArray& argv)
{ Init(); SetCmdLine(argc, argv); SetDesc(desc); }
#endif // wxUSE_UNICODE #endif // wxUSE_UNICODE
wxCmdLineParser(const wxCmdLineEntryDesc *desc, const wxString& cmdline) wxCmdLineParser(const wxCmdLineEntryDesc *desc, const wxString& cmdline)
{ Init(); SetCmdLine(cmdline); SetDesc(desc); } { Init(); SetCmdLine(cmdline); SetDesc(desc); }
@ -148,7 +120,6 @@ public:
void SetCmdLine(int argc, char **argv); void SetCmdLine(int argc, char **argv);
#if wxUSE_UNICODE #if wxUSE_UNICODE
void SetCmdLine(int argc, wxChar **argv); void SetCmdLine(int argc, wxChar **argv);
void SetCmdLine(int argc, const wxCmdLineArgsArray& argv);
#endif // wxUSE_UNICODE #endif // wxUSE_UNICODE
void SetCmdLine(const wxString& cmdline); void SetCmdLine(const wxString& cmdline);
@ -167,7 +138,7 @@ public:
void EnableLongOptions(bool enable = true); void EnableLongOptions(bool enable = true);
void DisableLongOptions() { EnableLongOptions(false); } void DisableLongOptions() { EnableLongOptions(false); }
bool AreLongOptionsEnabled() const; bool AreLongOptionsEnabled();
// extra text may be shown by Usage() method if set by this function // extra text may be shown by Usage() method if set by this function
void SetLogo(const wxString& logo); void SetLogo(const wxString& logo);
@ -182,34 +153,18 @@ public:
void AddSwitch(const wxString& name, const wxString& lng = wxEmptyString, void AddSwitch(const wxString& name, const wxString& lng = wxEmptyString,
const wxString& desc = wxEmptyString, const wxString& desc = wxEmptyString,
int flags = 0); 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 // an option taking a value of the given type
void AddOption(const wxString& name, const wxString& lng = wxEmptyString, void AddOption(const wxString& name, const wxString& lng = wxEmptyString,
const wxString& desc = wxEmptyString, const wxString& desc = wxEmptyString,
wxCmdLineParamType type = wxCMD_LINE_VAL_STRING, wxCmdLineParamType type = wxCMD_LINE_VAL_STRING,
int flags = 0); 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 // a parameter
void AddParam(const wxString& desc = wxEmptyString, void AddParam(const wxString& desc = wxEmptyString,
wxCmdLineParamType type = wxCMD_LINE_VAL_STRING, wxCmdLineParamType type = wxCMD_LINE_VAL_STRING,
int flags = 0); int flags = 0);
// add an explanatory text to be shown to the user in help
void AddUsageText(const wxString& text);
// actions // actions
// ------- // -------
@ -222,10 +177,7 @@ public:
int Parse(bool showUsage = true); int Parse(bool showUsage = true);
// give the usage message describing all program options // give the usage message describing all program options
void Usage() const; void Usage();
// return the usage string, call Usage() to directly show it to the user
wxString GetUsageString() const;
// get the command line arguments // get the command line arguments
// ------------------------------ // ------------------------------
@ -233,12 +185,6 @@ public:
// returns true if the given switch was found // returns true if the given switch was found
bool Found(const wxString& name) const; 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 // returns true if an option taking a string value was found and stores the
// value in the provided pointer // value in the provided pointer
bool Found(const wxString& name, wxString *value) const; bool Found(const wxString& name, wxString *value) const;
@ -247,10 +193,6 @@ public:
// the value in the provided pointer // the value in the provided pointer
bool Found(const wxString& name, long *value) const; 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 #if wxUSE_DATETIME
// returns true if an option taking a date value was found and stores the // returns true if an option taking a date value was found and stores the
// value in the provided pointer // value in the provided pointer
@ -267,17 +209,18 @@ public:
void Reset(); void Reset();
// break down the command line in arguments // break down the command line in arguments
static wxArrayString static wxArrayString ConvertStringToArgs(const wxChar *cmdline);
ConvertStringToArgs(const wxString& cmdline,
wxCmdLineSplitType type = wxCMD_LINE_SPLIT_DOS);
private: private:
// get usage string
wxString GetUsageString();
// common part of all ctors // common part of all ctors
void Init(); void Init();
struct wxCmdLineParserData *m_data; struct wxCmdLineParserData *m_data;
wxDECLARE_NO_COPY_CLASS(wxCmdLineParser); DECLARE_NO_COPY_CLASS(wxCmdLineParser)
}; };
#else // !wxUSE_CMDLINE_PARSER #else // !wxUSE_CMDLINE_PARSER
@ -287,11 +230,10 @@ private:
class WXDLLIMPEXP_BASE wxCmdLineParser class WXDLLIMPEXP_BASE wxCmdLineParser
{ {
public: public:
static wxArrayString static wxArrayString ConvertStringToArgs(const wxChar *cmdline);
ConvertStringToArgs(const wxString& cmdline,
wxCmdLineSplitType type = wxCMD_LINE_SPLIT_DOS);
}; };
#endif // wxUSE_CMDLINE_PARSER/!wxUSE_CMDLINE_PARSER #endif // wxUSE_CMDLINE_PARSER/!wxUSE_CMDLINE_PARSER
#endif // _WX_CMDLINE_H_ #endif // _WX_CMDLINE_H_

View File

@ -4,6 +4,7 @@
// Author: Julian Smart (extracted from docview.h by VZ) // Author: Julian Smart (extracted from docview.h by VZ)
// Modified by: // Modified by:
// Created: 05.11.00 // Created: 05.11.00
// RCS-ID: $Id: cmdproc.h 49804 2007-11-10 01:09:42Z VZ $
// Copyright: (c) wxWidgets team // Copyright: (c) wxWidgets team
// Licence: wxWindows licence // Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
@ -21,7 +22,7 @@ class WXDLLIMPEXP_FWD_CORE wxMenu;
// wxCommand: a single command capable of performing itself // wxCommand: a single command capable of performing itself
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxCommand : public wxObject class WXDLLEXPORT wxCommand : public wxObject
{ {
public: public:
wxCommand(bool canUndoIt = false, const wxString& name = wxEmptyString); wxCommand(bool canUndoIt = false, const wxString& name = wxEmptyString);
@ -48,7 +49,7 @@ private:
// wxCommandProcessor: wxCommand manager // wxCommandProcessor: wxCommand manager
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxCommandProcessor : public wxObject class WXDLLEXPORT wxCommandProcessor : public wxObject
{ {
public: public:
// if max number of commands is -1, it is unlimited // if max number of commands is -1, it is unlimited
@ -96,7 +97,10 @@ public:
virtual void ClearCommands(); virtual void ClearCommands();
// Has the current project been changed? // 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 // Mark the current command as the one where the last save took place
void MarkAsSaved() void MarkAsSaved()
@ -133,7 +137,7 @@ protected:
private: private:
DECLARE_DYNAMIC_CLASS(wxCommandProcessor) DECLARE_DYNAMIC_CLASS(wxCommandProcessor)
wxDECLARE_NO_COPY_CLASS(wxCommandProcessor); DECLARE_NO_COPY_CLASS(wxCommandProcessor)
}; };
#endif // _WX_CMDPROC_H_ #endif // _WX_CMDPROC_H_

View File

@ -4,6 +4,7 @@
// Author: Julian Smart and others // Author: Julian Smart and others
// Modified by: // Modified by:
// Created: 01/02/97 // Created: 01/02/97
// RCS-ID: $Id: cmndata.h 53135 2008-04-12 02:31:04Z VZ $
// Copyright: (c) // Copyright: (c)
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
@ -11,18 +12,134 @@
#ifndef _WX_CMNDATA_H_BASE_ #ifndef _WX_CMNDATA_H_BASE_
#define _WX_CMNDATA_H_BASE_ #define _WX_CMNDATA_H_BASE_
#include "wx/defs.h" #include "wx/window.h"
#include "wx/font.h"
#if wxUSE_PRINTING_ARCHITECTURE #include "wx/encinfo.h"
#include "wx/colour.h"
#include "wx/gdicmn.h" #include "wx/gdicmn.h"
#if wxUSE_STREAMS #if wxUSE_STREAMS
#include "wx/stream.h" #include "wx/stream.h"
#endif #endif
class WXDLLIMPEXP_FWD_CORE wxPrintNativeDataBase; 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 * wxPrintData
* Encapsulates printer information (not printer dialog information) * Encapsulates printer information (not printer dialog information)
@ -51,7 +168,7 @@ enum wxPrintBin
const int wxPRINTMEDIA_DEFAULT = 0; const int wxPRINTMEDIA_DEFAULT = 0;
class WXDLLIMPEXP_CORE wxPrintData: public wxObject class WXDLLEXPORT wxPrintData: public wxObject
{ {
public: public:
wxPrintData(); wxPrintData();
@ -60,7 +177,7 @@ public:
int GetNoCopies() const { return m_printNoCopies; } int GetNoCopies() const { return m_printNoCopies; }
bool GetCollate() const { return m_printCollate; } bool GetCollate() const { return m_printCollate; }
wxPrintOrientation GetOrientation() const { return m_printOrientation; } int GetOrientation() const { return m_printOrientation; }
bool IsOrientationReversed() const { return m_printOrientationReversed; } bool IsOrientationReversed() const { return m_printOrientationReversed; }
// Is this data OK for showing the print dialog? // Is this data OK for showing the print dialog?
@ -80,11 +197,7 @@ public:
void SetNoCopies(int v) { m_printNoCopies = v; } void SetNoCopies(int v) { m_printNoCopies = v; }
void SetCollate(bool flag) { m_printCollate = flag; } void SetCollate(bool flag) { m_printCollate = flag; }
void SetOrientation(int orient) { m_printOrientation = orient; }
// Please use the overloaded method below
wxDEPRECATED_INLINE(void SetOrientation(int orient),
m_printOrientation = (wxPrintOrientation)orient; )
void SetOrientation(wxPrintOrientation orient) { m_printOrientation = orient; }
void SetOrientationReversed(bool reversed) { m_printOrientationReversed = reversed; } void SetOrientationReversed(bool reversed) { m_printOrientationReversed = reversed; }
void SetPrinterName(const wxString& name) { m_printerName = name; } void SetPrinterName(const wxString& name) { m_printerName = name; }
@ -100,13 +213,36 @@ public:
wxString GetFilename() const { return m_filename; } wxString GetFilename() const { return m_filename; }
void SetFilename( const wxString &filename ) { m_filename = 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; } char* GetPrivData() const { return m_privData; }
int GetPrivDataLen() const { return m_privDataLen; } int GetPrivDataLen() const { return m_privDataLen; }
void SetPrivData( char *privData, int len ); 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 // Convert between wxPrintData and native data
void ConvertToNative(); void ConvertToNative();
void ConvertFromNative(); void ConvertFromNative();
@ -119,7 +255,7 @@ private:
wxPrintMode m_printMode; wxPrintMode m_printMode;
int m_printNoCopies; int m_printNoCopies;
wxPrintOrientation m_printOrientation; int m_printOrientation;
bool m_printOrientationReversed; bool m_printOrientationReversed;
bool m_printCollate; bool m_printCollate;
@ -148,7 +284,7 @@ private:
* from the dialog. * from the dialog.
*/ */
class WXDLLIMPEXP_CORE wxPrintDialogData: public wxObject class WXDLLEXPORT wxPrintDialogData: public wxObject
{ {
public: public:
wxPrintDialogData(); wxPrintDialogData();
@ -165,7 +301,9 @@ public:
bool GetSelection() const { return m_printSelection; } bool GetSelection() const { return m_printSelection; }
bool GetCollate() const { return m_printCollate; } bool GetCollate() const { return m_printCollate; }
bool GetPrintToFile() const { return m_printToFile; } 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 SetFromPage(int v) { m_printFromPage = v; }
void SetToPage(int v) { m_printToPage = v; } void SetToPage(int v) { m_printToPage = v; }
void SetMinPage(int v) { m_printMinPage = v; } void SetMinPage(int v) { m_printMinPage = v; }
@ -175,7 +313,9 @@ public:
void SetSelection(bool flag) { m_printSelection = flag; } void SetSelection(bool flag) { m_printSelection = flag; }
void SetCollate(bool flag) { m_printCollate = flag; } void SetCollate(bool flag) { m_printCollate = flag; }
void SetPrintToFile(bool flag) { m_printToFile = 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 EnablePrintToFile(bool flag) { m_printEnablePrintToFile = flag; }
void EnableSelection(bool flag) { m_printEnableSelection = flag; } void EnableSelection(bool flag) { m_printEnableSelection = flag; }
void EnablePageNumbers(bool flag) { m_printEnablePageNumbers = flag; } void EnablePageNumbers(bool flag) { m_printEnablePageNumbers = flag; }
@ -188,7 +328,7 @@ public:
// Is this data OK for showing the print dialog? // Is this data OK for showing the print dialog?
bool Ok() const { return IsOk(); } bool Ok() const { return IsOk(); }
bool IsOk() const { return m_printData.IsOk() ; } bool IsOk() const { return m_printData.Ok() ; }
wxPrintData& GetPrintData() { return m_printData; } wxPrintData& GetPrintData() { return m_printData; }
void SetPrintData(const wxPrintData& printData) { m_printData = printData; } void SetPrintData(const wxPrintData& printData) { m_printData = printData; }
@ -210,6 +350,9 @@ private:
bool m_printEnablePageNumbers; bool m_printEnablePageNumbers;
bool m_printEnableHelp; bool m_printEnableHelp;
bool m_printEnablePrintToFile; bool m_printEnablePrintToFile;
#if WXWIN_COMPATIBILITY_2_4
bool m_printSetupDialog;
#endif
wxPrintData m_printData; wxPrintData m_printData;
private: private:
@ -223,7 +366,7 @@ private:
// Compatibility with old name // Compatibility with old name
#define wxPageSetupData wxPageSetupDialogData #define wxPageSetupData wxPageSetupDialogData
class WXDLLIMPEXP_CORE wxPageSetupDialogData: public wxObject class WXDLLEXPORT wxPageSetupDialogData: public wxObject
{ {
public: public:
wxPageSetupDialogData(); wxPageSetupDialogData();
@ -248,7 +391,7 @@ public:
// Is this data OK for showing the page setup dialog? // Is this data OK for showing the page setup dialog?
bool Ok() const { return IsOk(); } 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 // If a corresponding paper type is found in the paper database, will set the m_printData
// paper size id member as well. // paper size id member as well.
@ -279,7 +422,7 @@ public:
// Use paper id in wxPrintData to set this object's paper size // Use paper id in wxPrintData to set this object's paper size
void CalculatePaperSizeFromId(); void CalculatePaperSizeFromId();
wxPageSetupDialogData& operator=(const wxPageSetupDialogData& data); wxPageSetupDialogData& operator=(const wxPageSetupData& data);
wxPageSetupDialogData& operator=(const wxPrintData& data); wxPageSetupDialogData& operator=(const wxPrintData& data);
wxPrintData& GetPrintData() { return m_printData; } wxPrintData& GetPrintData() { return m_printData; }

View File

@ -4,6 +4,7 @@
// Author: Francesco Montorsi // Author: Francesco Montorsi
// Modified by: // Modified by:
// Created: 8/10/2006 // Created: 8/10/2006
// RCS-ID: $Id: collpane.h 43300 2006-11-11 07:32:08Z RD $
// Copyright: (c) Francesco Montorsi // Copyright: (c) Francesco Montorsi
// Licence: wxWindows Licence // Licence: wxWindows Licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
@ -18,8 +19,6 @@
#include "wx/control.h" #include "wx/control.h"
// class name
extern WXDLLIMPEXP_DATA_CORE(const char) wxCollapsiblePaneNameStr[];
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// wxCollapsiblePaneBase: interface for wxCollapsiblePane // wxCollapsiblePaneBase: interface for wxCollapsiblePane
@ -50,16 +49,16 @@ public:
// event types and macros // event types and macros
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
class WXDLLIMPEXP_FWD_CORE wxCollapsiblePaneEvent; BEGIN_DECLARE_EVENT_TYPES()
DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_CORE, wxEVT_COMMAND_COLLPANE_CHANGED, 1102)
wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_COLLAPSIBLEPANE_CHANGED, wxCollapsiblePaneEvent ); END_DECLARE_EVENT_TYPES()
class WXDLLIMPEXP_CORE wxCollapsiblePaneEvent : public wxCommandEvent class WXDLLIMPEXP_CORE wxCollapsiblePaneEvent : public wxCommandEvent
{ {
public: public:
wxCollapsiblePaneEvent() {} wxCollapsiblePaneEvent() {}
wxCollapsiblePaneEvent(wxObject *generator, int id, bool collapsed) wxCollapsiblePaneEvent(wxObject *generator, int id, bool collapsed)
: wxCommandEvent(wxEVT_COLLAPSIBLEPANE_CHANGED, id), : wxCommandEvent(wxEVT_COMMAND_COLLPANE_CHANGED, id),
m_bCollapsed(collapsed) m_bCollapsed(collapsed)
{ {
SetEventObject(generator); SetEventObject(generator);
@ -85,13 +84,13 @@ private:
typedef void (wxEvtHandler::*wxCollapsiblePaneEventFunction)(wxCollapsiblePaneEvent&); typedef void (wxEvtHandler::*wxCollapsiblePaneEventFunction)(wxCollapsiblePaneEvent&);
#define wxCollapsiblePaneEventHandler(func) \ #define wxCollapsiblePaneEventHandler(func) \
wxEVENT_HANDLER_CAST(wxCollapsiblePaneEventFunction, func) (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxCollapsiblePaneEventFunction, &func)
#define EVT_COLLAPSIBLEPANE_CHANGED(id, fn) \ #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" #include "wx/gtk/collpane.h"
#else #else
#include "wx/generic/collpaneg.h" #include "wx/generic/collpaneg.h"
@ -100,9 +99,6 @@ typedef void (wxEvtHandler::*wxCollapsiblePaneEventFunction)(wxCollapsiblePaneEv
#define wxCollapsiblePane wxGenericCollapsiblePane #define wxCollapsiblePane wxGenericCollapsiblePane
#endif #endif
// old wxEVT_COMMAND_* constant
#define wxEVT_COMMAND_COLLPANE_CHANGED wxEVT_COLLAPSIBLEPANE_CHANGED
#endif // wxUSE_COLLPANE #endif // wxUSE_COLLPANE
#endif // _WX_COLLAPSABLE_PANE_H_BASE_ #endif // _WX_COLLAPSABLE_PANE_H_BASE_

View File

@ -1,9 +1,10 @@
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// Name: wx/colordlg.h // Name: wx/colrdlgg.h
// Purpose: wxColourDialog // Purpose: wxColourDialog
// Author: Vadim Zeitiln // Author: Vadim Zeitiln
// Modified by: // Modified by:
// Created: 01/02/97 // Created: 01/02/97
// RCS-ID: $Id: colordlg.h 36623 2006-01-02 14:26:36Z JS $
// Copyright: (c) wxWidgets team // Copyright: (c) wxWidgets team
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
@ -15,14 +16,14 @@
#if wxUSE_COLOURDLG #if wxUSE_COLOURDLG
#include "wx/colourdata.h"
#if defined(__WXMSW__) && !defined(__WXUNIVERSAL__) #if defined(__WXMSW__) && !defined(__WXUNIVERSAL__)
#include "wx/msw/colordlg.h" #include "wx/msw/colordlg.h"
#elif defined(__WXMAC__) && !defined(__WXUNIVERSAL__) #elif defined(__WXMAC__) && !defined(__WXUNIVERSAL__)
#include "wx/osx/colordlg.h" #include "wx/mac/colordlg.h"
#elif defined(__WXGTK20__) && !defined(__WXUNIVERSAL__) #elif defined(__WXGTK20__) && !defined(__WXUNIVERSAL__)
#include "wx/gtk/colordlg.h" #include "wx/gtk/colordlg.h"
#elif defined(__WXPALMOS__)
#include "wx/palmos/colordlg.h"
#else #else
#include "wx/generic/colrdlgg.h" #include "wx/generic/colrdlgg.h"
@ -30,10 +31,9 @@
#endif #endif
// get the colour from user and return it // get the colour from user and return it
WXDLLIMPEXP_CORE wxColour wxGetColourFromUser(wxWindow *parent = NULL, wxColour WXDLLEXPORT
const wxColour& colInit = wxNullColour, wxGetColourFromUser(wxWindow *parent = (wxWindow *)NULL,
const wxString& caption = wxEmptyString, const wxColour& colInit = wxNullColour, const wxString& caption = wxEmptyString);
wxColourData *data = NULL);
#endif // wxUSE_COLOURDLG #endif // wxUSE_COLOURDLG

View File

@ -4,6 +4,7 @@
// Author: Julian Smart // Author: Julian Smart
// Modified by: Francesco Montorsi // Modified by: Francesco Montorsi
// Created: // Created:
// RCS-ID: $Id: colour.h 53135 2008-04-12 02:31:04Z VZ $
// Copyright: Julian Smart // Copyright: Julian Smart
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
@ -14,46 +15,38 @@
#include "wx/defs.h" #include "wx/defs.h"
#include "wx/gdiobj.h" #include "wx/gdiobj.h"
class WXDLLIMPEXP_FWD_CORE wxColour; class WXDLLIMPEXP_FWD_CORE wxColour;
// A macro to define the standard wxColour constructors: // the standard wxColour constructors;
// // this macro avoids to repeat these lines across all colour.h files, since
// 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
// Set() is a virtual function and thus cannot be called by wxColourBase ctors // constructors
#define DEFINE_STD_WXCOLOUR_CONSTRUCTORS \ #define DEFINE_STD_WXCOLOUR_CONSTRUCTORS \
wxColour() { Init(); } \ wxColour( ChannelType red, ChannelType green, ChannelType blue, \
wxColour(ChannelType red, \
ChannelType green, \
ChannelType blue, \
ChannelType alpha = wxALPHA_OPAQUE ) \ ChannelType alpha = wxALPHA_OPAQUE ) \
{ Init(); Set(red, green, blue, alpha); } \ { Set(red, green, blue, alpha); } \
wxColour(unsigned long colRGB) { Init(); Set(colRGB ); } \ wxColour( unsigned long colRGB ) { Set(colRGB); } \
wxColour(const wxString& colourName) { Init(); Set(colourName); } \ wxColour(const wxString &colourName) { Set(colourName); } \
wxColour(const char *colourName) { Init(); Set(colourName); } \ wxColour(const wxChar *colourName) { Set(colourName); }
wxColour(const wchar_t *colourName) { Init(); Set(colourName); }
// flags for wxColour -> wxString conversion (see wxColour::GetAsString) // flags for wxColour -> wxString conversion (see wxColour::GetAsString)
enum { #define wxC2S_NAME 1 // return colour name, when possible
wxC2S_NAME = 1, // return colour name, when possible #define wxC2S_CSS_SYNTAX 2 // return colour in rgb(r,g,b) syntax
wxC2S_CSS_SYNTAX = 2, // return colour in rgb(r,g,b) syntax #define wxC2S_HTML_SYNTAX 4 // return colour in #rrggbb syntax
wxC2S_HTML_SYNTAX = 4 // return colour in #rrggbb syntax
};
const unsigned char wxALPHA_TRANSPARENT = 0; const unsigned char wxALPHA_TRANSPARENT = 0;
const unsigned char wxALPHA_OPAQUE = 0xff; 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 // wxVariant support
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
#if wxUSE_VARIANT #if wxUSE_VARIANT
#include "wx/variant.h" #include "wx/variant.h"
DECLARE_VARIANT_OBJECT_EXPORTED(wxColour,WXDLLIMPEXP_CORE) DECLARE_VARIANT_OBJECT_EXPORTED(wxColour,WXDLLEXPORT)
#endif #endif
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -61,22 +54,7 @@ DECLARE_VARIANT_OBJECT_EXPORTED(wxColour,WXDLLIMPEXP_CORE)
// code redundancy in all native wxColour implementations // code redundancy in all native wxColour implementations
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
/* Transition from wxGDIObject to wxObject is incomplete. If your port does class WXDLLEXPORT wxColourBase : public wxGDIObject
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
{ {
public: public:
// type of a single colour component // type of a single colour component
@ -96,6 +74,9 @@ public:
{ InitRGBA(red,green,blue, alpha); } { InitRGBA(red,green,blue, alpha); }
// implemented in colourcmn.cpp // implemented in colourcmn.cpp
bool Set(const wxChar *str)
{ return FromString(str); }
bool Set(const wxString &str) bool Set(const wxString &str)
{ return FromString(str); } { return FromString(str); }
@ -113,6 +94,9 @@ public:
// accessors // accessors
// --------- // ---------
virtual bool Ok() const { return IsOk(); }
virtual bool IsOk() const = 0;
virtual ChannelType Red() const = 0; virtual ChannelType Red() const = 0;
virtual ChannelType Green() const = 0; virtual ChannelType Green() const = 0;
virtual ChannelType Blue() const = 0; virtual ChannelType Blue() const = 0;
@ -122,98 +106,28 @@ public:
// implemented in colourcmn.cpp // implemented in colourcmn.cpp
virtual wxString GetAsString(long flags = wxC2S_NAME | wxC2S_CSS_SYNTAX) const; 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 // old, deprecated
// --------------- // ---------------
#if WXWIN_COMPATIBILITY_2_6 #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) ); wxDEPRECATED( void InitFromName(const wxString& col) );
#endif #endif
protected: 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 virtual void
InitRGBA(ChannelType r, ChannelType g, ChannelType b, ChannelType a) = 0; InitRGBA(ChannelType r, ChannelType g, ChannelType b, ChannelType a) = 0;
virtual bool FromString(const wxString& s); virtual bool FromString(const wxChar *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
}; };
// 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(__WXPALMOS__)
#include "wx/generic/colour.h"
#if defined(__WXMSW__) #elif defined(__WXMSW__)
#include "wx/msw/colour.h" #include "wx/msw/colour.h"
#elif defined(__WXMOTIF__) #elif defined(__WXMOTIF__)
#include "wx/motif/colour.h" #include "wx/motif/colour.h"
@ -221,12 +135,14 @@ WXDLLIMPEXP_CORE bool wxFromString(const wxString& str, wxColourBase* col);
#include "wx/gtk/colour.h" #include "wx/gtk/colour.h"
#elif defined(__WXGTK__) #elif defined(__WXGTK__)
#include "wx/gtk1/colour.h" #include "wx/gtk1/colour.h"
#elif defined(__WXMGL__)
#include "wx/generic/colour.h"
#elif defined(__WXDFB__) #elif defined(__WXDFB__)
#include "wx/generic/colour.h" #include "wx/generic/colour.h"
#elif defined(__WXX11__) #elif defined(__WXX11__)
#include "wx/x11/colour.h" #include "wx/x11/colour.h"
#elif defined(__WXMAC__) #elif defined(__WXMAC__)
#include "wx/osx/colour.h" #include "wx/mac/colour.h"
#elif defined(__WXCOCOA__) #elif defined(__WXCOCOA__)
#include "wx/cocoa/colour.h" #include "wx/cocoa/colour.h"
#elif defined(__WXPM__) #elif defined(__WXPM__)

View File

@ -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_

View File

@ -4,6 +4,7 @@
// Author: Jaakko Salli // Author: Jaakko Salli
// Modified by: // Modified by:
// Created: Apr-30-2006 // Created: Apr-30-2006
// RCS-ID: $Id: combo.h 64412 2010-05-27 15:11:58Z JMS $
// Copyright: (c) Jaakko Salli // Copyright: (c) Jaakko Salli
// Licence: wxWindows licence // Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
@ -44,7 +45,6 @@
#include "wx/control.h" #include "wx/control.h"
#include "wx/renderer.h" // this is needed for wxCONTROL_XXX flags #include "wx/renderer.h" // this is needed for wxCONTROL_XXX flags
#include "wx/bitmap.h" // wxBitmap used by-value #include "wx/bitmap.h" // wxBitmap used by-value
#include "wx/textentry.h"
class WXDLLIMPEXP_FWD_CORE wxTextCtrl; class WXDLLIMPEXP_FWD_CORE wxTextCtrl;
class WXDLLIMPEXP_FWD_CORE wxComboPopup; class WXDLLIMPEXP_FWD_CORE wxComboPopup;
@ -86,8 +86,8 @@ enum
wxCC_IFLAG_CREATED = 0x0100, wxCC_IFLAG_CREATED = 0x0100,
// Internal use: really put button outside // Internal use: really put button outside
wxCC_IFLAG_BUTTON_OUTSIDE = 0x0200, wxCC_IFLAG_BUTTON_OUTSIDE = 0x0200,
// Internal use: SetMargins has been successfully called // Internal use: SetTextIndent has been called
wxCC_IFLAG_LEFT_MARGIN_SET = 0x0400, wxCC_IFLAG_INDENT_SET = 0x0400,
// Internal use: Set wxTAB_TRAVERSAL to parent when popup is dismissed // Internal use: Set wxTAB_TRAVERSAL to parent when popup is dismissed
wxCC_IFLAG_PARENT_TAB_TRAVERSAL = 0x0800, wxCC_IFLAG_PARENT_TAB_TRAVERSAL = 0x0800,
// Internal use: Secondary popup window type should be used (if available). // 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 BitmapButton = 0x0002, // Button may be replaced with bitmap
ButtonSpacing = 0x0004, // Button can have spacing from the edge ButtonSpacing = 0x0004, // Button can have spacing from the edge
// of the control // of the control
TextIndent = 0x0008, // SetMargins can be used to control TextIndent = 0x0008, // SetTextIndent can be used
// left margin.
PaintControl = 0x0010, // Combo control itself can be custom painted PaintControl = 0x0010, // Combo control itself can be custom painted
PaintWritable = 0x0020, // A variable-width area in front of writable PaintWritable = 0x0020, // A variable-width area in front of writable
// combo control's textctrl can be custom // combo control's textctrl can be custom
@ -139,14 +138,12 @@ struct wxComboCtrlFeatures
}; };
class WXDLLIMPEXP_CORE wxComboCtrlBase : public wxControl, class WXDLLEXPORT wxComboCtrlBase : public wxControl
public wxTextEntry
{ {
friend class wxComboPopup; friend class wxComboPopup;
friend class wxComboPopupEvtHandler;
public: public:
// ctors and such // ctors and such
wxComboCtrlBase() : wxControl(), wxTextEntry() { Init(); } wxComboCtrlBase() : wxControl() { Init(); }
bool Create(wxWindow *parent, bool Create(wxWindow *parent,
wxWindowID id, wxWindowID id,
@ -159,19 +156,9 @@ public:
virtual ~wxComboCtrlBase(); virtual ~wxComboCtrlBase();
// Show/hide popup window (wxComboBox-compatible methods) // show/hide popup window
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.
virtual void ShowPopup(); virtual void ShowPopup();
virtual void HidePopup(bool generateEvent=false); virtual void HidePopup();
// Override for totally custom combo action // Override for totally custom combo action
virtual void OnButtonClick(); virtual void OnButtonClick();
@ -207,56 +194,26 @@ public:
virtual bool Enable(bool enable = true); virtual bool Enable(bool enable = true);
virtual bool Show(bool show = true); virtual bool Show(bool show = true);
virtual bool SetFont(const wxFont& font); virtual bool SetFont(const wxFont& font);
#if wxUSE_VALIDATORS
virtual void SetValidator(const wxValidator &validator);
virtual wxValidator *GetValidator();
#endif // wxUSE_VALIDATORS
// // wxTextCtrl methods - for readonly combo they should return
// wxTextEntry methods // without errors.
// virtual wxString GetValue() const;
// NB: We basically need to override all of them because there is virtual void SetValue(const wxString& value);
// 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);
virtual void Copy(); virtual void Copy();
virtual void Cut(); virtual void Cut();
virtual void Paste(); virtual void Paste();
virtual void Undo();
virtual void Redo();
virtual bool CanUndo() const;
virtual bool CanRedo() const;
virtual void SetInsertionPoint(long pos); virtual void SetInsertionPoint(long pos);
virtual void SetInsertionPointEnd();
virtual long GetInsertionPoint() const; virtual long GetInsertionPoint() const;
virtual long GetLastPosition() 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 SetSelection(long from, long to);
virtual void GetSelection(long *from, long *to) const; virtual void Undo();
virtual bool IsEditable() const;
virtual void SetEditable(bool editable);
virtual bool SetHint(const wxString& hint);
virtual wxString GetHint() const;
// This method sets the text without affecting list selection // This method sets the text without affecting list selection
// (ie. wxComboPopup::SetStringValue doesn't get called). // (ie. wxComboPopup::SetStringValue doesn't get called).
@ -264,13 +221,7 @@ public:
// This method sets value and also optionally sends EVT_TEXT // This method sets value and also optionally sends EVT_TEXT
// (needed by combo popups) // (needed by combo popups)
wxDEPRECATED( void SetValueWithEvent(const wxString& value, void SetValueWithEvent(const wxString& value, bool withEvent = true);
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);
// //
// Popup customization methods // Popup customization methods
@ -352,18 +303,19 @@ public:
const wxBitmap& bmpHover = wxNullBitmap, const wxBitmap& bmpHover = wxNullBitmap,
const wxBitmap& bmpDisabled = 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 // 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. // text, regardless whether control is read-only (ie. no wxTextCtrl) or not.
// Platform-specific default can be set with value-1. // Platform-specific default can be set with value-1.
// Remarks // Remarks
// * This method may do nothing on some native implementations. // * This method may do nothing on some native implementations.
wxDEPRECATED( void SetTextIndent( int indent ) ); void SetTextIndent( int indent );
// Returns actual indentation in pixels. // Returns actual indentation in pixels.
wxDEPRECATED( wxCoord GetTextIndent() const ); wxCoord GetTextIndent() const
#endif {
return m_absIndent;
}
// Returns area covered by the text field. // Returns area covered by the text field.
const wxRect& GetTextRect() const const wxRect& GetTextRect() const
@ -434,21 +386,14 @@ public:
const wxBitmap& GetBitmapHover() const { return m_bmpHover; } const wxBitmap& GetBitmapHover() const { return m_bmpHover; }
const wxBitmap& GetBitmapDisabled() const { return m_bmpDisabled; } 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 // Return internal flags
wxUint32 GetInternalFlags() const { return m_iFlags; } wxUint32 GetInternalFlags() const { return m_iFlags; }
// Return true if Create has finished // Return true if Create has finished
bool IsCreated() const { return m_iFlags & wxCC_IFLAG_CREATED ? true : false; } 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 // common code to be called on popup hide/dismiss
void OnPopupDismiss(bool generateEvent); void OnPopupDismiss();
// PopupShown states // PopupShown states
enum enum
@ -466,26 +411,8 @@ public:
// Set value returned by GetMainWindowOfCompositeControl // Set value returned by GetMainWindowOfCompositeControl
void SetCtrlMainWnd( wxWindow* wnd ) { m_mainCtrlWnd = wnd; } 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: 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 // Override these for customization purposes
// //
@ -493,8 +420,7 @@ protected:
// called from wxSizeEvent handler // called from wxSizeEvent handler
virtual void OnResize() = 0; virtual void OnResize() = 0;
// Return native text identation // Return native text identation (for pure text, not textctrl)
// (i.e. text margin, for pure text, not textctrl)
virtual wxCoord GetNativeTextIndent() const; virtual wxCoord GetNativeTextIndent() const;
// Called in syscolourchanged handler and base create // Called in syscolourchanged handler and base create
@ -502,25 +428,20 @@ protected:
// Creates wxTextCtrl. // Creates wxTextCtrl.
// extraStyle: Extra style parameters // extraStyle: Extra style parameters
void CreateTextCtrl( int extraStyle ); void CreateTextCtrl( int extraStyle, const wxValidator& validator );
// Called when text was changed programmatically
// (e.g. from WriteText())
void OnSetValue(const wxString& value);
// Installs standard input handler to combo (and optionally to the textctrl) // Installs standard input handler to combo (and optionally to the textctrl)
void InstallInputHandlers(); void InstallInputHandlers();
// Flags for DrawButton // flags for DrawButton()
enum enum
{ {
Button_PaintBackground = 0x0001, // Paints control background below the button Draw_PaintBg = 1,
Button_BitmapOnly = 0x0002 // Only paints the bitmap Draw_BitmapOnly = 2
}; };
// Draws dropbutton. Using wxRenderer or bitmaps, as appropriate. // Draws dropbutton. Using wxRenderer or bitmaps, as appropriate.
// Flags are defined above. void DrawButton( wxDC& dc, const wxRect& rect, int flags = Draw_PaintBg );
virtual void DrawButton( wxDC& dc, const wxRect& rect, int flags = Button_PaintBackground );
// Call if cursor is on button area or mouse is captured for the button. // Call if cursor is on button area or mouse is captured for the button.
//bool HandleButtonMouseEvent( wxMouseEvent& event, bool isInside ); //bool HandleButtonMouseEvent( wxMouseEvent& event, bool isInside );
@ -544,10 +465,7 @@ protected:
void DestroyPopup(); void DestroyPopup();
// override the base class virtuals involved in geometry calculations // 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 DoGetBestSize() const;
virtual wxSize DoGetSizeFromTextSize(int xlen, int ylen = -1) const;
// NULL popup can be used to indicate default in a derived class // NULL popup can be used to indicate default in a derived class
virtual void DoSetPopupControl(wxComboPopup* popup); virtual void DoSetPopupControl(wxComboPopup* popup);
@ -560,10 +478,9 @@ protected:
// just recalculate. // just recalculate.
void CalculateAreas( int btnWidth = 0 ); 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. // textctrl coordinate adjustment.
virtual void PositionTextCtrl( int textCtrlXAdjust = 0, void PositionTextCtrl( int textCtrlXAdjust, int textCtrlYAdjust );
int textCtrlYAdjust = 0);
// event handlers // event handlers
void OnSizeEvent( wxSizeEvent& event ); void OnSizeEvent( wxSizeEvent& event );
@ -572,7 +489,6 @@ protected:
void OnTextCtrlEvent(wxCommandEvent& event); void OnTextCtrlEvent(wxCommandEvent& event);
void OnSysColourChanged(wxSysColourChangedEvent& event); void OnSysColourChanged(wxSysColourChangedEvent& event);
void OnKeyEvent(wxKeyEvent& event); void OnKeyEvent(wxKeyEvent& event);
void OnCharEvent(wxKeyEvent& event);
// Set customization flags (directs how wxComboCtrlBase helpers behave) // Set customization flags (directs how wxComboCtrlBase helpers behave)
void Customize( wxUint32 flags ) { m_iFlags |= flags; } void Customize( wxUint32 flags ) { m_iFlags |= flags; }
@ -601,21 +517,12 @@ protected:
virtual void DoSetToolTip( wxToolTip *tip ); virtual void DoSetToolTip( wxToolTip *tip );
#endif #endif
// protected wxTextEntry methods virtual wxWindow *GetMainWindowOfCompositeControl()
virtual void DoSetValue(const wxString& value, int flags); { return m_mainCtrlWnd; }
virtual wxString DoGetValue() const;
virtual wxWindow *GetEditableWindow() { return this; }
// margins functions
virtual bool DoSetMargins(const wxPoint& pt);
virtual wxPoint DoGetMargins() const;
// This is used when m_text is hidden (readonly). // This is used when m_text is hidden (readonly).
wxString m_valueString; 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 // the text control and button we show all the time
wxTextCtrl* m_text; wxTextCtrl* m_text;
wxWindow* m_btn; wxWindow* m_btn;
@ -636,7 +543,7 @@ protected:
wxEvtHandler* m_toplevEvtHandler; wxEvtHandler* m_toplevEvtHandler;
// this is for the control in popup // this is for the control in popup
wxEvtHandler* m_popupEvtHandler; wxEvtHandler* m_popupExtraHandler;
// this is for the popup window // this is for the popup window
wxEvtHandler* m_popupWinEvtHandler; wxEvtHandler* m_popupWinEvtHandler;
@ -664,8 +571,8 @@ protected:
// selection indicator. // selection indicator.
wxCoord m_widthCustomPaint; wxCoord m_widthCustomPaint;
// left margin, in pixels // absolute text indentation, in pixels
wxCoord m_marginLeft; wxCoord m_absIndent;
// side on which the popup is aligned // side on which the popup is aligned
int m_anchorSide; int m_anchorSide;
@ -677,9 +584,6 @@ protected:
wxRect m_tcArea; wxRect m_tcArea;
wxRect m_btnArea; wxRect m_btnArea;
// Colour of the text area, in case m_text is NULL
wxColour m_tcBgCol;
// current button state (uses renderer flags) // current button state (uses renderer flags)
int m_btnState; int m_btnState;
@ -701,12 +605,9 @@ protected:
// area used by the button // area used by the button
wxSize m_btnSize; wxSize m_btnSize;
// platform-dependent customization and other flags // platform-dependant customization and other flags
wxUint32 m_iFlags; wxUint32 m_iFlags;
// custom style for m_text
int m_textCtrlStyle;
// draw blank button background under bitmap? // draw blank button background under bitmap?
bool m_blankButtonBg; bool m_blankButtonBg;
@ -716,9 +617,6 @@ protected:
// should the focus be reset to the textctrl in idle time? // should the focus be reset to the textctrl in idle time?
bool m_resetFocus; bool m_resetFocus;
// is the text-area background colour overridden?
bool m_hasTcBgCol;
private: private:
void Init(); void Init();
@ -745,16 +643,14 @@ enum
wxCP_IFLAG_CREATED = 0x0001 // Set by wxComboCtrlBase after Create is called wxCP_IFLAG_CREATED = 0x0001 // Set by wxComboCtrlBase after Create is called
}; };
class WXDLLIMPEXP_FWD_CORE wxComboCtrl;
class WXDLLEXPORT wxComboPopup
class WXDLLIMPEXP_CORE wxComboPopup
{ {
friend class wxComboCtrlBase; friend class wxComboCtrlBase;
public: public:
wxComboPopup() wxComboPopup()
{ {
m_combo = NULL; m_combo = (wxComboCtrlBase*) NULL;
m_iFlags = 0; m_iFlags = 0;
} }
@ -770,13 +666,6 @@ public:
// Return true for success. // Return true for success.
virtual bool Create(wxWindow* parent) = 0; 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. // We must have an associated control which is subclassed by the combobox.
virtual wxWindow *GetControl() = 0; virtual wxWindow *GetControl() = 0;
@ -793,25 +682,14 @@ public:
// Gets displayed string representation of the value. // Gets displayed string representation of the value.
virtual wxString GetStringValue() const = 0; 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). // This is called to custom paint in the combo control itself (ie. not the popup).
// Default implementation draws value as string. // Default implementation draws value as string.
virtual void PaintComboControl( wxDC& dc, const wxRect& rect ); 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. // Events not handled should be skipped, as usual.
virtual void OnComboKeyEvent( wxKeyEvent& event ); 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 // Implement if you need to support special action when user
// double-clicks on the parent wxComboCtrl. // double-clicks on the parent wxComboCtrl.
virtual void OnComboDoubleClick(); virtual void OnComboDoubleClick();
@ -842,9 +720,6 @@ public:
return (m_iFlags & wxCP_IFLAG_CREATED) ? true : false; return (m_iFlags & wxCP_IFLAG_CREATED) ? true : false;
} }
// Returns pointer to the associated parent wxComboCtrl.
wxComboCtrl* GetComboCtrl() const;
// Default PaintComboControl behaviour // Default PaintComboControl behaviour
static void DefaultPaintComboControl( wxComboCtrlBase* combo, static void DefaultPaintComboControl( wxComboCtrlBase* combo,
wxDC& dc, wxDC& dc,

View File

@ -4,6 +4,7 @@
// Author: Vadim Zeitlin // Author: Vadim Zeitlin
// Modified by: // Modified by:
// Created: 24.12.00 // Created: 24.12.00
// RCS-ID: $Id: combobox.h 42727 2006-10-30 16:04:27Z VZ $
// Copyright: (c) 1996-2000 wxWidgets team // Copyright: (c) 1996-2000 wxWidgets team
// Licence: wxWindows licence // Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
@ -15,54 +16,57 @@
#if wxUSE_COMBOBOX #if wxUSE_COMBOBOX
// For compatibility with 2.8 include this header to allow using wxTE_XXX extern WXDLLEXPORT_DATA(const wxChar) wxComboBoxNameStr[];
// styles with wxComboBox without explicitly including it in the user code.
#include "wx/textctrl.h"
extern WXDLLIMPEXP_DATA_CORE(const char) wxComboBoxNameStr[];
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// wxComboBoxBase: this interface defines the methods wxComboBox must implement // wxComboBoxBase: this interface defines the methods wxComboBox must implement
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
#include "wx/textctrl.h"
#include "wx/ctrlsub.h" #include "wx/ctrlsub.h"
#include "wx/textentry.h"
class WXDLLIMPEXP_CORE wxComboBoxBase : public wxItemContainer, class WXDLLEXPORT wxComboBoxBase : public wxItemContainer
public wxTextEntry
{ {
public: public:
// override these methods to disambiguate between two base classes versions // wxTextCtrl-like methods wxComboBox must implement
virtual void Clear() virtual wxString GetValue() const = 0;
{ virtual void SetValue(const wxString& value) = 0;
wxTextEntry::Clear();
wxItemContainer::Clear();
}
// IsEmpty() is ambiguous because we inherit it from both wxItemContainer virtual void Copy() = 0;
// and wxTextEntry, and even if defined it here to help the compiler with virtual void Cut() = 0;
// choosing one of them, it would still be confusing for the human users of virtual void Paste() = 0;
// this class. So instead define the clearly named methods below and leave virtual void SetInsertionPoint(long pos) = 0;
// IsEmpty() ambiguous to trigger a compilation error if it's used. virtual long GetInsertionPoint() const = 0;
bool IsListEmpty() const { return wxItemContainer::IsEmpty(); } virtual wxTextPos GetLastPosition() const = 0;
bool IsTextEmpty() const { return wxTextEntry::IsEmpty(); } 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 virtual void SetInsertionPointEnd()
// { SetInsertionPoint(GetLastPosition()); }
// NB: GetSelection(from, to) could be already implemented in wxTextEntry virtual void Remove(long from, long to)
// but still make it pure virtual because for some platforms it's not { Replace(from, to, wxEmptyString); }
// 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 Popup() { wxFAIL_MSG( wxT("Not implemented") ); } virtual bool IsEditable() const = 0;
virtual void Dismiss() { wxFAIL_MSG( wxT("Not implemented") ); }
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 // may return value different from GetSelection() when the combobox
// dropdown is shown and the user selected, but not yet accepted, a value // dropdown is shown and the user selected, but not yet accepted, a value
// different from the old one in it // different from the old one in it
virtual int GetCurrentSelection() const { return GetSelection(); } 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__) #elif defined(__WXGTK__)
#include "wx/gtk1/combobox.h" #include "wx/gtk1/combobox.h"
#elif defined(__WXMAC__) #elif defined(__WXMAC__)
#include "wx/osx/combobox.h" #include "wx/mac/combobox.h"
#elif defined(__WXCOCOA__) #elif defined(__WXCOCOA__)
#include "wx/cocoa/combobox.h" #include "wx/cocoa/combobox.h"
#elif defined(__WXPM__) #elif defined(__WXPM__)
@ -89,4 +93,5 @@ public:
#endif // wxUSE_COMBOBOX #endif // wxUSE_COMBOBOX
#endif // _WX_COMBOBOX_H_BASE_ #endif
// _WX_COMBOBOX_H_BASE_

View File

@ -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_

View File

@ -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 <vadim@wxwidgets.org>
* 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_

View File

@ -1,229 +0,0 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/compositewin.h
// Purpose: wxCompositeWindow<> declaration
// Author: Vadim Zeitlin
// Created: 2011-01-02
// Copyright: (c) 2011 Vadim Zeitlin <vadim@wxwidgets.org>
// 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 W>
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 <class T>
void SetForAllParts(bool (wxWindowBase::*func)(const T&), const T& arg)
{
DoSetForAllParts<const T&>(func, arg);
}
template <class T>
void SetForAllParts(bool (wxWindowBase::*func)(T*), T* arg)
{
DoSetForAllParts<T*>(func, arg);
}
template <class T>
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_

View File

@ -1,10 +1,11 @@
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// Name: wx/confbase.h // Name: confbase.h
// Purpose: declaration of the base class of all config implementations // Purpose: declaration of the base class of all config implementations
// (see also: fileconf.h and msw/regconf.h and iniconf.h) // (see also: fileconf.h and msw/regconf.h and iniconf.h)
// Author: Karsten Ballueder & Vadim Zeitlin // Author: Karsten Ballueder & Vadim Zeitlin
// Modified by: // Modified by:
// Created: 07.04.98 (adapted from appconf.h) // 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 // Copyright: (c) 1997 Karsten Ballueder Ballueder@usa.net
// Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr> // Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
// Licence: wxWindows licence // Licence: wxWindows licence
@ -15,8 +16,6 @@
#include "wx/defs.h" #include "wx/defs.h"
#include "wx/string.h" #include "wx/string.h"
#include "wx/object.h"
#include "wx/base64.h"
class WXDLLIMPEXP_FWD_BASE wxArrayString; class WXDLLIMPEXP_FWD_BASE wxArrayString;
@ -42,6 +41,8 @@ class WXDLLIMPEXP_FWD_BASE wxArrayString;
#if wxUSE_CONFIG #if wxUSE_CONFIG
#include "wx/string.h"
/// should we use registry instead of configuration files under Windows? /// should we use registry instead of configuration files under Windows?
// (i.e. whether wxConfigBase::Create() will create a wxFileConfig (if it's // (i.e. whether wxConfigBase::Create() will create a wxFileConfig (if it's
// false) or wxRegConfig (if it's true and we're under Win32)) // 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 #define wxUSE_CONFIG_NATIVE 1
#endif #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 // Style flags for constructor style parameter
enum enum
{ {
@ -72,7 +64,7 @@ enum
// abstract base class wxConfigBase which defines the interface for derived // abstract base class wxConfigBase which defines the interface for derived
// classes // 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). // Unix/Dos filesystem). There are groups (directories) and keys (files).
// There is always one current group given by the current path. // 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). // (long) type (TODO doubles and other types such as wxDate coming soon).
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
class WXDLLIMPEXP_BASE wxConfigBase : public wxObject class WXDLLIMPEXP_BASE wxConfigBase
{ {
public: public:
// constants // constants
@ -172,7 +164,7 @@ public:
bool Read(const wxString& key, long *pl) const; bool Read(const wxString& key, long *pl) const;
bool Read(const wxString& key, long *pl, long defVal) 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) const;
bool Read(const wxString& key, int *pi, int defVal) const; bool Read(const wxString& key, int *pi, int defVal) const;
@ -180,75 +172,18 @@ public:
bool Read(const wxString& key, double* val) const; bool Read(const wxString& key, double* val) const;
bool Read(const wxString& key, double* val, double defVal) 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 // read a bool
bool Read(const wxString& key, bool* val) const; bool Read(const wxString& key, bool* val) const;
bool Read(const wxString& key, bool* val, bool defVal) const; bool Read(const wxString& key, bool* val, bool defVal) const;
#if wxUSE_BASE64 // convenience functions returning directly the value (we don't have them for
// read a binary data block // int/double/bool as there would be ambiguities with the long one then)
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 <typename T>
bool Read(const wxString& key, T* value) const
{
wxString s;
if ( !Read(key, &s) )
return false;
return wxFromString(s, value);
}
template <typename T>
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
wxString Read(const wxString& key, wxString Read(const wxString& key,
const wxString& defVal = wxEmptyString) const const wxString& defVal = wxEmptyString) const
{ wxString s; (void)Read(key, &s, defVal); return s; } { 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 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 <typename T>
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 long Read(const wxString& key, long defVal) const
{ return ReadLong(key, defVal); } { long l; (void)Read(key, &l, defVal); return l; }
// write the value (return true on success) // write the value (return true on success)
bool Write(const wxString& key, const wxString& value) bool Write(const wxString& key, const wxString& value)
@ -257,61 +192,19 @@ public:
bool Write(const wxString& key, long value) bool Write(const wxString& key, long value)
{ return DoWriteLong(key, value); } { return DoWriteLong(key, value); }
bool Write(const wxString& key, int value)
{ return DoWriteInt(key, value); }
bool Write(const wxString& key, double value) bool Write(const wxString& key, double value)
{ return DoWriteDouble(key, value); } { return DoWriteDouble(key, value); }
bool Write(const wxString& key, bool value) bool Write(const wxString& key, bool value)
{ return DoWriteBool(key, 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 // we have to provide a separate version for C strings as otherwise they
// would be converted to bool and not to wxString as expected! // 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)); } { 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 <typename T>
bool Write(const wxString& key, T const& value)
{ return Write(key, wxToString(value)); }
#endif
// permanently writes all changes // permanently writes all changes
virtual bool Flush(bool bCurrentOnly = false) = 0; virtual bool Flush(bool bCurrentOnly = false) = 0;
@ -372,19 +265,15 @@ protected:
// do read/write the values of different types // do read/write the values of different types
virtual bool DoReadString(const wxString& key, wxString *pStr) const = 0; virtual bool DoReadString(const wxString& key, wxString *pStr) const = 0;
virtual bool DoReadLong(const wxString& key, long *pl) 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 DoReadDouble(const wxString& key, double* val) const;
virtual bool DoReadBool(const wxString& key, bool* 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 DoWriteString(const wxString& key, const wxString& value) = 0;
virtual bool DoWriteLong(const wxString& key, long 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 DoWriteDouble(const wxString& key, double value);
virtual bool DoWriteBool(const wxString& key, bool 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: private:
// are we doing automatic environment variable expansion? // are we doing automatic environment variable expansion?
@ -402,8 +291,6 @@ private:
// Style flag // Style flag
long m_style; long m_style;
DECLARE_ABSTRACT_CLASS(wxConfigBase)
}; };
// a handy little class which changes current path to the path of given entry // a handy little class which changes current path to the path of given entry
@ -435,10 +322,22 @@ private:
m_strOldPath; // saved path m_strOldPath; // saved path
bool m_bChanged; // was the path changed? 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 #endif // wxUSE_CONFIG
/* /*
@ -452,7 +351,9 @@ WXDLLIMPEXP_BASE wxString wxExpandEnvVars(const wxString &sz);
/* /*
Split path into parts removing '..' in progress 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_

View File

@ -1,10 +1,11 @@
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// Name: wx/config.h // Name: config.h
// Purpose: wxConfig base header // Purpose: wxConfig base header
// Author: Julian Smart // Author: Julian Smart
// Modified by: // Modified by:
// Created: // Created:
// Copyright: (c) Julian Smart // Copyright: (c) Julian Smart
// RCS-ID: $Id: config.h 60524 2009-05-05 22:51:44Z PC $
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
@ -15,21 +16,16 @@
#if wxUSE_CONFIG #if wxUSE_CONFIG
// ---------------------------------------------------------------------------- #if defined(__WXMSW__) && wxUSE_CONFIG_NATIVE
// define the native wxConfigBase implementation # ifdef __WIN32__
// ----------------------------------------------------------------------------
// 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" # include "wx/msw/regconf.h"
#define wxConfig wxRegConfig # else
#elif defined(__WXOS2__) && wxUSE_CONFIG_NATIVE # include "wx/msw/iniconf.h"
#include "wx/os2/iniconf.h" # endif
#define wxConfig wxIniConfig #elif defined(__WXPALMOS__) && wxUSE_CONFIG_NATIVE
#else // either we're under Unix or wish to always use config files # include "wx/palmos/prefconf.h"
#else
# include "wx/fileconf.h" # include "wx/fileconf.h"
#define wxConfig wxFileConfig
#endif #endif
#endif // wxUSE_CONFIG #endif // wxUSE_CONFIG

View File

@ -1,105 +1,62 @@
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// Name: wx/containr.h // 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 // Author: Vadim Zeitlin
// Modified by: // Modified by:
// Created: 06.08.01 // Created: 06.08.01
// Copyright: (c) 2001, 2011 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr> // RCS-ID: $Id: containr.h 50863 2007-12-20 18:32:55Z VS $
// Copyright: (c) 2001 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
// Licence: wxWindows licence // Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_CONTAINR_H_ #ifndef _WX_CONTAINR_H_
#define _WX_CONTAINR_H_ #define _WX_CONTAINR_H_
#include "wx/defs.h" class WXDLLIMPEXP_FWD_CORE wxFocusEvent;
class WXDLLIMPEXP_FWD_CORE wxNavigationKeyEvent;
#ifndef wxHAS_NATIVE_TAB_TRAVERSAL
// We need wxEVT_XXX declarations in this case.
#include "wx/event.h"
#endif
class WXDLLIMPEXP_FWD_CORE wxWindow; class WXDLLIMPEXP_FWD_CORE wxWindow;
class WXDLLIMPEXP_FWD_CORE wxWindowBase; class WXDLLIMPEXP_FWD_CORE wxWindowBase;
/* /*
This header declares wxControlContainer class however it's not a real Implementation note: wxControlContainer is not a real mix-in but rather
container of controls but rather just a helper used to implement TAB a class meant to be agregated with (and not inherited from). Although
navigation among the window children. You should rarely need to use it logically it should be a mix-in, doing it like this has no advantage from
directly, derive from the documented public wxNavigationEnabled<> class to the point of view of the existing code but does have some problems (we'd
implement TAB navigation in a custom composite window. 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: public:
// default ctor, SetContainerWindow() must be called later // ctors and such
wxControlContainerBase() wxControlContainer(wxWindow *winParent = NULL);
{ void SetContainerWindow(wxWindow *winParent) { m_winParent = winParent; }
m_winParent = NULL;
// By default, we accept focus ourselves. // the methods to be called from the window event handlers
m_acceptsFocusSelf = true; void HandleOnNavigationKey(wxNavigationKeyEvent& event);
void HandleOnFocus(wxFocusEvent& event);
// But we don't have any children accepting it yet. void HandleOnWindowDestroy(wxWindowBase *child);
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(); }
// should be called from SetFocus(), returns false if we did nothing with // should be called from SetFocus(), returns false if we did nothing with
// the focus and the default processing should take place // the focus and the default processing should take place
bool DoSetFocus(); bool DoSetFocus();
// returns whether we should accept focus ourselves or not // can our child get the focus?
bool AcceptsFocus() const; bool AcceptsFocus() const;
// Returns whether we or one of our children accepts focus. // called from OnChildFocus() handler, i.e. when one of our (grand)
bool AcceptsFocusRecursively() const // children gets the focus
{ return AcceptsFocus() || void SetLastFocus(wxWindow *win);
(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();
protected: protected:
// set the focus to the child which had it the last time // set the focus to the child which had it the last time
virtual bool SetFocusToChild(); 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;
// the parent window we manage the children for // the parent window we manage the children for
wxWindow *m_winParent; wxWindow *m_winParent;
@ -107,265 +64,33 @@ protected:
// the child which had the focus last time this panel was activated // the child which had the focus last time this panel was activated
wxWindow *m_winLastFocused; 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 // a guard against infinite recursion
bool m_inSetFocus; 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 // 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 // macros which may be used by the classes wishing to implement TAB navigation
// among window children in a wxWindow-derived class. The details of this class // among their children
// don't matter, you just need to derive from it to make navigation work.
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// The template parameter W must be a wxWindow-derived class.
template <class W>
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 // declare the methods to be forwarded
#define WX_DECLARE_CONTROL_CONTAINER() \ #define WX_DECLARE_CONTROL_CONTAINER() \
WX_DECLARE_CONTROL_CONTAINER_BASE(); \
\
public: \ public: \
void OnNavigationKey(wxNavigationKeyEvent& event); \ void OnNavigationKey(wxNavigationKeyEvent& event); \
void OnFocus(wxFocusEvent& event); \ void OnFocus(wxFocusEvent& event); \
virtual void OnChildFocus(wxChildFocusEvent& 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 // implement the event table entries for wxControlContainer
#define WX_EVENT_TABLE_CONTROL_CONTAINER(classname) \ #define WX_EVENT_TABLE_CONTROL_CONTAINER(classname) \
@ -375,20 +100,22 @@ public: \
// implement the methods forwarding to the wxControlContainer // implement the methods forwarding to the wxControlContainer
#define WX_DELEGATE_TO_CONTROL_CONTAINER(classname, basename) \ #define WX_DELEGATE_TO_CONTROL_CONTAINER(classname, basename) \
WX_DELEGATE_TO_CONTROL_CONTAINER_BASE(classname, basename) \ void classname::OnNavigationKey( wxNavigationKeyEvent& event ) \
{ \
m_container.HandleOnNavigationKey(event); \
} \
\ \
void classname::RemoveChild(wxWindowBase *child) \ void classname::RemoveChild(wxWindowBase *child) \
{ \ { \
m_container.HandleOnWindowDestroy(child); \ m_container.HandleOnWindowDestroy(child); \
\ \
basename::RemoveChild(child); \ basename::RemoveChild(child); \
\
m_container.UpdateCanFocusChildren(); \
} \ } \
\ \
void classname::OnNavigationKey( wxNavigationKeyEvent& event ) \ void classname::SetFocus() \
{ \ { \
m_container.HandleOnNavigationKey(event); \ if ( !m_container.DoSetFocus() ) \
basename::SetFocus(); \
} \ } \
\ \
void classname::SetFocusIgnoringChildren() \ void classname::SetFocusIgnoringChildren() \
@ -405,10 +132,11 @@ public: \
void classname::OnFocus(wxFocusEvent& event) \ void classname::OnFocus(wxFocusEvent& event) \
{ \ { \
m_container.HandleOnFocus(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_ #endif // _WX_CONTAINR_H_

View File

@ -4,6 +4,7 @@
// Author: Vadim Zeitlin // Author: Vadim Zeitlin
// Modified by: // Modified by:
// Created: 26.07.99 // Created: 26.07.99
// RCS-ID: $Id: control.h 42816 2006-10-31 08:50:17Z RD $
// Copyright: (c) wxWidgets team // Copyright: (c) wxWidgets team
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
@ -21,38 +22,13 @@
#include "wx/window.h" // base class #include "wx/window.h" // base class
extern WXDLLIMPEXP_DATA_CORE(const char) wxControlNameStr[]; extern WXDLLEXPORT_DATA(const wxChar) 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
};
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// wxControl is the base class for all controls // wxControl is the base class for all controls
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxControlBase : public wxWindow class WXDLLEXPORT wxControlBase : public wxWindow
{ {
public: public:
wxControlBase() { } wxControlBase() { }
@ -70,51 +46,11 @@ public:
// get the control alignment (left/right/centre, top/bottom/centre) // get the control alignment (left/right/centre, top/bottom/centre)
int GetAlignment() const { return m_windowStyle & wxALIGN_MASK; } int GetAlignment() const { return m_windowStyle & wxALIGN_MASK; }
// set label with mnemonics // get the string without mnemonic characters ('&')
virtual void SetLabel(const wxString& label) static wxString GetLabelText(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 just the text of the label, without mnemonic characters ('&') // get just the text of the label, without mnemonic characters ('&')
virtual wxString GetLabelText() const { return GetLabelText(GetLabel()); } 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 <b>, <i> and <span>. 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 "&lt;" 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 "&amp;" 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
// controls by default inherit the colours of their parents, if a // controls by default inherit the colours of their parents, if a
// particular control class doesn't want to do it, it can override // particular control class doesn't want to do it, it can override
@ -128,56 +64,13 @@ public:
// if the button was clicked) // if the button was clicked)
virtual void Command(wxCommandEvent &event); virtual void Command(wxCommandEvent &event);
virtual void SetLabel( const wxString &label );
virtual bool SetFont(const wxFont& font); virtual bool SetFont(const wxFont& font);
// wxControl-specific processing after processing the update event // wxControl-specific processing after processing the update event
virtual void DoUpdateWindowUI(wxUpdateUIEvent& 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: protected:
// choose the default border for this window
virtual wxBorder GetDefaultBorder() const;
// creates the control (calls wxWindowBase::CreateBase inside) and adds it // creates the control (calls wxWindowBase::CreateBase inside) and adds it
// to the list of parents children // to the list of parents children
bool CreateControl(wxWindowBase *parent, bool CreateControl(wxWindowBase *parent,
@ -188,36 +81,10 @@ protected:
const wxValidator& validator, const wxValidator& validator,
const wxString& name); 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 // initialize the common fields of wxCommandEvent
void InitCommandEvent(wxCommandEvent& event) const; void InitCommandEvent(wxCommandEvent& event) const;
// Ellipsize() helper: DECLARE_NO_COPY_CLASS(wxControlBase)
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);
}; };
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@ -226,6 +93,8 @@ protected:
#if defined(__WXUNIVERSAL__) #if defined(__WXUNIVERSAL__)
#include "wx/univ/control.h" #include "wx/univ/control.h"
#elif defined(__WXPALMOS__)
#include "wx/palmos/control.h"
#elif defined(__WXMSW__) #elif defined(__WXMSW__)
#include "wx/msw/control.h" #include "wx/msw/control.h"
#elif defined(__WXMOTIF__) #elif defined(__WXMOTIF__)
@ -235,7 +104,7 @@ protected:
#elif defined(__WXGTK__) #elif defined(__WXGTK__)
#include "wx/gtk1/control.h" #include "wx/gtk1/control.h"
#elif defined(__WXMAC__) #elif defined(__WXMAC__)
#include "wx/osx/control.h" #include "wx/mac/control.h"
#elif defined(__WXCOCOA__) #elif defined(__WXCOCOA__)
#include "wx/cocoa/control.h" #include "wx/cocoa/control.h"
#elif defined(__WXPM__) #elif defined(__WXPM__)

View File

@ -3,6 +3,7 @@
// Purpose: wxConvAuto class declaration // Purpose: wxConvAuto class declaration
// Author: Vadim Zeitlin // Author: Vadim Zeitlin
// Created: 2006-04-03 // Created: 2006-04-03
// RCS-ID: $Id: convauto.h 45893 2007-05-08 20:05:16Z VZ $
// Copyright: (c) 2006 Vadim Zeitlin // Copyright: (c) 2006 Vadim Zeitlin
// Licence: wxWindows licence // Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
@ -11,63 +12,24 @@
#define _WX_CONVAUTO_H_ #define _WX_CONVAUTO_H_
#include "wx/strconv.h" #include "wx/strconv.h"
#include "wx/fontenc.h"
#if wxUSE_WCHAR_T
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// wxConvAuto: uses BOM to automatically detect input encoding // 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 class WXDLLIMPEXP_BASE wxConvAuto : public wxMBConv
{ {
public: public:
// default ctor, the real conversion will be created on demand // default ctor, the real conversion will be created on demand
wxConvAuto(wxFontEncoding enc = wxFONTENCODING_DEFAULT) wxConvAuto() { m_conv = NULL; /* the rest will be initialized later */ }
{
Init();
m_encDefault = enc;
}
// copy ctor doesn't initialize anything neither as conversion can only be // copy ctor doesn't initialize anything neither as conversion can only be
// deduced on first use // deduced on first use
wxConvAuto(const wxConvAuto& other) : wxMBConv() wxConvAuto(const wxConvAuto& WXUNUSED(other)) : wxMBConv() { m_conv = NULL; }
{
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);
}
virtual ~wxConvAuto() { if ( m_conv && m_ownsConv ) delete m_conv; }
// override the base class virtual function(s) to use our m_conv // override the base class virtual function(s) to use our m_conv
virtual size_t ToWChar(wchar_t *dst, size_t dstLen, virtual size_t ToWChar(wchar_t *dst, size_t dstLen,
@ -80,64 +42,46 @@ public:
virtual wxMBConv *Clone() const { return new wxConvAuto(*this); } 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: private:
// common part of all ctors // all currently recognized BOM values
void Init() enum BOMType
{ {
// We don't initialize m_encDefault here as different ctors do it BOM_None,
// differently. BOM_UTF32BE,
m_conv = NULL; BOM_UTF32LE,
m_bomType = wxBOM_Unknown; BOM_UTF16BE,
m_ownsConv = false; BOM_UTF16LE,
m_consumedBOM = false; BOM_UTF8
} };
// initialize m_conv with the UTF-8 conversion // return the BOM type of this buffer
void InitWithUTF8() 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_conv = &wxConvUTF8;
m_ownsConv = false; m_ownsConv = false;
} }
// create the correct conversion object for the given BOM type // 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 // create the correct conversion object for the BOM present in the
// beginning of the buffer // beginning of the buffer; adjust the buffer to skip the BOM if found
// void InitFromInput(const char **src, size_t *len);
// 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);
// adjust src and len to skip over the BOM (identified by m_bomType) at the // adjust src and len to skip over the BOM (identified by m_bomType) at the
// start of the buffer // start of the buffer
void SkipBOM(const char **src, size_t *len) const; 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 // conversion object which we really use, NULL until the first call to
// either ToWChar() or FromWChar() // either ToWChar() or FromWChar()
wxMBConv *m_conv; wxMBConv *m_conv;
// the multibyte encoding to use by default if input isn't Unicode
wxFontEncoding m_encDefault;
// our BOM type // our BOM type
wxBOM m_bomType; BOMType m_bomType;
// true if we allocated m_conv ourselves, false if we just use an existing // true if we allocated m_conv ourselves, false if we just use an existing
// global conversion // global conversion
@ -148,8 +92,17 @@ private:
bool m_consumedBOM; 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_ #endif // _WX_CONVAUTO_H_

View File

@ -3,6 +3,7 @@
* Purpose: Various preprocessor helpers * Purpose: Various preprocessor helpers
* Author: Vadim Zeitlin * Author: Vadim Zeitlin
* Created: 2006-09-30 * Created: 2006-09-30
* RCS-ID: $Id: cpp.h 42993 2006-11-03 21:06:57Z VZ $
* Copyright: (c) 2006 Vadim Zeitlin <vadim@wxwindows.org> * Copyright: (c) 2006 Vadim Zeitlin <vadim@wxwindows.org>
* Licence: wxWindows licence * Licence: wxWindows licence
*/ */
@ -12,27 +13,9 @@
#ifndef _WX_CPP_H_ #ifndef _WX_CPP_H_
#define _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 */ /* wxCONCAT works like preprocessor ## operator but also works with macros */
#define wxCONCAT_HELPER(text, line) text ## line #define wxCONCAT_HELPER(text, line) text ## line
#define wxCONCAT(text, line) wxCONCAT_HELPER(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)
/* wxSTRINGIZE works as the preprocessor # operator but also works with macros */ /* wxSTRINGIZE works as the preprocessor # operator but also works with macros */
#define wxSTRINGIZE_HELPER(x) #x #define wxSTRINGIZE_HELPER(x) #x
@ -41,16 +24,6 @@
/* a Unicode-friendly version of wxSTRINGIZE_T */ /* a Unicode-friendly version of wxSTRINGIZE_T */
#define wxSTRINGIZE_T(x) wxAPPLY_T(wxSTRINGIZE(x)) #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 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 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 */ #define wxEMPTY_PARAMETER_VALUE /* Fake macro parameter value */
/* #endif // _WX_CPP_H_
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_ */

View File

@ -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 <cppunit/extensions/TestFactoryRegistry.h>
#include <cppunit/ui/text/TestRunner.h>
#include <cppunit/TestCase.h>
#include <cppunit/extensions/HelperMacros.h>
#include <cppunit/CompilerOutputter.h>
#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<T1>::equal(expected,actual) ) \
{ \
Asserter::failNotEqual( assertion_traits<T1>::toString(expected), \
assertion_traits<T2>::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<char>::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 <iostream>
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_

View File

@ -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_

View File

@ -4,6 +4,7 @@
// Author: Julian Smart, Vadim Zeitlin // Author: Julian Smart, Vadim Zeitlin
// Modified by: // Modified by:
// Created: 08/09/2000 // Created: 08/09/2000
// RCS-ID: $Id: cshelp.h 61872 2009-09-09 22:37:05Z VZ $
// Copyright: (c) 2000 Julian Smart, Vadim Zeitlin // Copyright: (c) 2000 Julian Smart, Vadim Zeitlin
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
@ -35,7 +36,7 @@
* window for the application to display help for. * window for the application to display help for.
*/ */
class WXDLLIMPEXP_CORE wxContextHelp : public wxObject class WXDLLEXPORT wxContextHelp : public wxObject
{ {
public: public:
wxContextHelp(wxWindow* win = NULL, bool beginHelp = true); wxContextHelp(wxWindow* win = NULL, bool beginHelp = true);
@ -64,7 +65,7 @@ private:
* to put the application into context help mode. * to put the application into context help mode.
*/ */
class WXDLLIMPEXP_CORE wxContextHelpButton : public wxBitmapButton class WXDLLEXPORT wxContextHelpButton : public wxBitmapButton
{ {
public: public:
wxContextHelpButton(wxWindow* parent, wxContextHelpButton(wxWindow* parent,
@ -105,7 +106,7 @@ private:
// and overriding ShowHelp() but calling the base class version wouldn't work // 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 // any more, which forces us to use a rather ugly hack and pass the extra
// parameters of ShowHelpAtPoint() to ShowHelp() via member variables. // parameters of ShowHelpAtPoint() to ShowHelp() via member variables.
class WXDLLIMPEXP_CORE wxHelpProvider class WXDLLEXPORT wxHelpProvider
{ {
public: public:
// get/set the current (application-global) help provider (Set() returns // 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 // wxSimpleHelpProvider is an implementation of wxHelpProvider which supports
// only plain text help strings and shows the string associated with the // only plain text help strings and shows the string associated with the
// control (if any) in a tooltip // control (if any) in a tooltip
class WXDLLIMPEXP_CORE wxSimpleHelpProvider : public wxHelpProvider class WXDLLEXPORT wxSimpleHelpProvider : public wxHelpProvider
{ {
public: public:
// implement wxHelpProvider methods // implement wxHelpProvider methods
@ -211,12 +212,12 @@ protected:
// both context identifiers and plain text help strings. If the help text is an integer, // 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 // it is passed to wxHelpController::DisplayContextPopup. Otherwise, it shows the string
// in a tooltip as per wxSimpleHelpProvider. // in a tooltip as per wxSimpleHelpProvider.
class WXDLLIMPEXP_CORE wxHelpControllerHelpProvider : public wxSimpleHelpProvider class WXDLLEXPORT wxHelpControllerHelpProvider : public wxSimpleHelpProvider
{ {
public: public:
// Note that it doesn't own the help controller. The help controller // Note that it doesn't own the help controller. The help controller
// should be deleted separately. // should be deleted separately.
wxHelpControllerHelpProvider(wxHelpControllerBase* hc = NULL); wxHelpControllerHelpProvider(wxHelpControllerBase* hc = (wxHelpControllerBase*) NULL);
// implement wxHelpProvider methods // implement wxHelpProvider methods
@ -231,11 +232,11 @@ public:
protected: protected:
wxHelpControllerBase* m_helpController; wxHelpControllerBase* m_helpController;
wxDECLARE_NO_COPY_CLASS(wxHelpControllerHelpProvider); DECLARE_NO_COPY_CLASS(wxHelpControllerHelpProvider)
}; };
// Convenience function for turning context id into wxString // Convenience function for turning context id into wxString
WXDLLIMPEXP_CORE wxString wxContextId(int id); WXDLLEXPORT wxString wxContextId(int id);
#endif // wxUSE_HELP #endif // wxUSE_HELP

View File

@ -4,6 +4,7 @@
// Author: Vadim Zeitlin // Author: Vadim Zeitlin
// Modified by: // Modified by:
// Created: 22.10.99 // Created: 22.10.99
// RCS-ID: $Id: ctrlsub.h 42816 2006-10-31 08:50:17Z RD $
// Copyright: (c) wxWidgets team // Copyright: (c) wxWidgets team
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
@ -15,7 +16,6 @@
#if wxUSE_CONTROLS #if wxUSE_CONTROLS
#include "wx/arrstr.h"
#include "wx/control.h" // base class #include "wx/control.h" // base class
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@ -29,7 +29,7 @@
// implements an extended interface deriving from this one) // implements an extended interface deriving from this one)
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxItemContainerImmutable class WXDLLEXPORT wxItemContainerImmutable
{ {
public: public:
wxItemContainerImmutable() { } wxItemContainerImmutable() { }
@ -72,7 +72,7 @@ public:
bool SetStringSelection(const wxString& s); bool SetStringSelection(const wxString& s);
// return the selected string or empty string if none // 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 // this is the same as SetSelection( for single-selection controls but
// reads better for multi-selection ones // reads better for multi-selection ones
@ -80,109 +80,14 @@ public:
protected: protected:
// check that the index is valid // check that the index is valid
bool IsValid(unsigned int n) const { return n < GetCount(); } inline bool IsValid(unsigned int n) const { return n < GetCount(); }
bool IsValidInsert(unsigned int n) const { return n <= GetCount(); } inline bool IsValidInsert(unsigned int n) const { return n <= GetCount(); }
}; };
// ---------------------------------------------------------------------------- class WXDLLEXPORT wxItemContainer : public wxItemContainerImmutable
// 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
{ {
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<void **>(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<void **>(clientData),
wxClientData_Object);
}
public: public:
wxItemContainer() { m_clientDataItemsType = wxClientData_None; } wxItemContainer() { m_clientDataItemsType = wxClientData_None; }
virtual ~wxItemContainer(); virtual ~wxItemContainer();
@ -190,262 +95,99 @@ public:
// adding items // 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) int Append(const wxString& item)
{ return AppendItems(item); } { return DoAppend(item); }
int Append(const wxString& item, void *clientData) 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) 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 // only for rtti needs (separate name)
// 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) void AppendString( const wxString& item)
{ Append( 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) int Insert(const wxString& item, unsigned int pos)
{ return InsertItems(item, pos); } { return DoInsert(item, pos); }
int Insert(const wxString& item, unsigned int pos, void *clientData) 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);
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); }
// deleting items // deleting items
// -------------- // --------------
void Clear(); virtual void Clear() = 0;
void Delete(unsigned int pos); virtual void Delete(unsigned int n) = 0;
// 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; }
// misc
// ----
// client data stuff // client data stuff
// -----------------
void SetClientData(unsigned int n, void* clientData); void SetClientData(unsigned int n, void* clientData);
void* GetClientData(unsigned int n) const; 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); void SetClientObject(unsigned int n, wxClientData* clientData);
wxClientData* GetClientObject(unsigned int n) const; 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 bool HasClientObjectData() const
{ return GetClientDataType() == wxClientData_Object; } { return m_clientDataItemsType == wxClientData_Object; }
bool HasClientUntypedData() const bool HasClientUntypedData() const
{ return GetClientDataType() == wxClientData_Void; } { return m_clientDataItemsType == wxClientData_Void; }
protected: protected:
// there is usually no need to override this method but you can do it if it virtual int DoAppend(const wxString& item) = 0;
// is more convenient to only do "real" insertions in DoInsertItems() and virtual int DoInsert(const wxString& item, unsigned int pos) = 0;
// 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);
}
// 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 DoSetItemClientData(unsigned int n, void* clientData) = 0;
virtual void* DoGetItemClientData(unsigned int n) const = 0; virtual void* DoGetItemClientData(unsigned int n) const = 0;
virtual void DoSetItemClientObject(unsigned int n, wxClientData* clientData) = 0;
virtual void DoClear() = 0; virtual wxClientData* DoGetItemClientObject(unsigned int n) const = 0;
virtual void DoDeleteOneItem(unsigned int pos) = 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 // the type of the client data for the items
wxClientDataType m_clientDataItemsType; wxClientDataType m_clientDataItemsType;
}; };
// Inheriting directly from a wxWindow-derived class and wxItemContainer // this macro must (unfortunately) be used in any class deriving from both
// unfortunately introduces an ambiguity for all GetClientXXX() methods as they // wxItemContainer and wxControl because otherwise there is ambiguity when
// are inherited twice: the "global" versions from wxWindow and the per-item // calling GetClientXXX() functions -- the compiler can't choose between the
// versions taking the index from wxItemContainer. // two versions
// #define wxCONTROL_ITEMCONTAINER_CLIENTDATAOBJECT_RECAST \
// So we need to explicitly resolve them and this helper template class is void SetClientData(void *data) \
// provided to do it. To use it, simply inherit from wxWindowWithItems<Window, { wxEvtHandler::SetClientData(data); } \
// Container> instead of Window and Container interface directly. void *GetClientData() const \
template <class W, class C> { return wxEvtHandler::GetClientData(); } \
class wxWindowWithItems : public W, public C void SetClientObject(wxClientData *data) \
{ { wxEvtHandler::SetClientObject(data); } \
public: wxClientData *GetClientObject() const \
typedef W BaseWindowClass; { return wxEvtHandler::GetClientObject(); } \
typedef C BaseContainerInterface; void SetClientData(unsigned int n, void* clientData) \
{ wxItemContainer::SetClientData(n, clientData); } \
wxWindowWithItems() { } void* GetClientData(unsigned int n) const \
{ return wxItemContainer::GetClientData(n); } \
void SetClientData(void *data) void SetClientObject(unsigned int n, wxClientData* clientData) \
{ BaseWindowClass::SetClientData(data); } { wxItemContainer::SetClientObject(n, clientData); } \
void *GetClientData() const wxClientData* GetClientObject(unsigned int n) 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
{ return wxItemContainer::GetClientObject(n); } { return wxItemContainer::GetClientObject(n); }
};
class WXDLLIMPEXP_CORE wxControlWithItemsBase : class WXDLLEXPORT wxControlWithItems : public wxControl, public wxItemContainer
public wxWindowWithItems<wxControl, wxItemContainer>
{ {
public: 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 // usually the controls like list/combo boxes have their own background
// colour // colour
virtual bool ShouldInheritColours() const { return false; } 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: protected:
// fill in the client object or data field of the event as appropriate // fill in the client object or data field of the event as appropriate
// //
@ -453,26 +195,15 @@ protected:
// item client data // item client data
void InitCommandEventWithItems(wxCommandEvent& event, int n); void InitCommandEventWithItems(wxCommandEvent& event, int n);
private:
wxDECLARE_NO_COPY_CLASS(wxControlWithItemsBase);
};
// 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: private:
DECLARE_ABSTRACT_CLASS(wxControlWithItems) DECLARE_ABSTRACT_CLASS(wxControlWithItems)
wxDECLARE_NO_COPY_CLASS(wxControlWithItems); DECLARE_NO_COPY_CLASS(wxControlWithItems)
}; };
#endif
// ----------------------------------------------------------------------------
// inline functions
// ----------------------------------------------------------------------------
#endif // wxUSE_CONTROLS #endif // wxUSE_CONTROLS

View File

@ -5,6 +5,7 @@
// Modified by: // Modified by:
// Created: // Created:
// Copyright: (c) Julian Smart // Copyright: (c) Julian Smart
// RCS-ID: $Id: cursor.h 40865 2006-08-27 09:42:42Z VS $
// Licence: wxWindows Licence // Licence: wxWindows Licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
@ -13,56 +14,27 @@
#include "wx/defs.h" #include "wx/defs.h"
/* #if defined(__WXPALMOS__)
wxCursor classes should have the following public API: #include "wx/palmos/cursor.h"
#elif defined(__WXMSW__)
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
#include "wx/msw/cursor.h" #include "wx/msw/cursor.h"
#elif defined(__WXMOTIF__) #elif defined(__WXMOTIF__)
#define wxCURSOR_DEFAULT_TYPE wxBITMAP_TYPE_XBM
#include "wx/motif/cursor.h" #include "wx/motif/cursor.h"
#elif defined(__WXGTK20__) #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" #include "wx/gtk/cursor.h"
#elif defined(__WXGTK__) #elif defined(__WXGTK__)
#define wxCURSOR_DEFAULT_TYPE wxBITMAP_TYPE_XPM
#include "wx/gtk1/cursor.h" #include "wx/gtk1/cursor.h"
#elif defined(__WXX11__) #elif defined(__WXX11__)
#define wxCURSOR_DEFAULT_TYPE wxBITMAP_TYPE_XPM
#include "wx/x11/cursor.h" #include "wx/x11/cursor.h"
#elif defined(__WXMGL__)
#include "wx/mgl/cursor.h"
#elif defined(__WXDFB__) #elif defined(__WXDFB__)
#define wxCURSOR_DEFAULT_TYPE wxBITMAP_TYPE_CUR_RESOURCE
#include "wx/dfb/cursor.h" #include "wx/dfb/cursor.h"
#elif defined(__WXMAC__) #elif defined(__WXMAC__)
#define wxCURSOR_DEFAULT_TYPE wxBITMAP_TYPE_MACCURSOR_RESOURCE #include "wx/mac/cursor.h"
#include "wx/osx/cursor.h"
#elif defined(__WXCOCOA__) #elif defined(__WXCOCOA__)
#define wxCURSOR_DEFAULT_TYPE wxBITMAP_TYPE_MACCURSOR_RESOURCE
#include "wx/cocoa/cursor.h" #include "wx/cocoa/cursor.h"
#elif defined(__WXPM__) #elif defined(__WXPM__)
#define wxCURSOR_DEFAULT_TYPE wxBITMAP_TYPE_CUR_RESOURCE
#include "wx/os2/cursor.h" #include "wx/os2/cursor.h"
#endif #endif

View File

@ -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 <vadim@wxwidgets.org>
// 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_

View File

@ -4,6 +4,7 @@
// Author: Vadim Zeitlin, Robert Roebling // Author: Vadim Zeitlin, Robert Roebling
// Modified by: // Modified by:
// Created: 26.05.99 // Created: 26.05.99
// RCS-ID: $Id: dataobj.h 40772 2006-08-23 13:38:45Z VZ $
// Copyright: (c) wxWidgets Team // Copyright: (c) wxWidgets Team
// Licence: wxWindows licence // Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
@ -54,7 +55,7 @@ public:
typedef <integral type> NativeFormat; typedef <integral type> NativeFormat;
wxDataFormat(NativeFormat format = wxDF_INVALID); wxDataFormat(NativeFormat format = wxDF_INVALID);
wxDataFormat(const wxString& format); wxDataFormat(const wxChar *format);
wxDataFormat& operator=(NativeFormat format); wxDataFormat& operator=(NativeFormat format);
wxDataFormat& operator=(const wxDataFormat& format); wxDataFormat& operator=(const wxDataFormat& format);
@ -66,7 +67,7 @@ public:
NativeFormat GetType() const; NativeFormat GetType() const;
wxString GetId() const; wxString GetId() const;
void SetId(const wxString& format); void SetId(const wxChar *format);
}; };
*/ */
@ -82,7 +83,7 @@ public:
#elif defined(__WXX11__) #elif defined(__WXX11__)
#include "wx/x11/dataform.h" #include "wx/x11/dataform.h"
#elif defined(__WXMAC__) #elif defined(__WXMAC__)
#include "wx/osx/dataform.h" #include "wx/mac/dataform.h"
#elif defined(__WXCOCOA__) #elif defined(__WXCOCOA__)
#include "wx/cocoa/dataform.h" #include "wx/cocoa/dataform.h"
#elif defined(__WXPM__) #elif defined(__WXPM__)
@ -91,7 +92,7 @@ public:
// the value for default argument to some functions (corresponds to // the value for default argument to some functions (corresponds to
// wxDF_INVALID) // wxDF_INVALID)
extern WXDLLIMPEXP_CORE const wxDataFormat& wxFormatInvalid; extern WXDLLEXPORT const wxDataFormat& wxFormatInvalid;
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// wxDataObject represents a piece of data which knows which formats it // 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(). // to be supported by SetData() or GetDataHere().
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxDataObjectBase class WXDLLEXPORT wxDataObjectBase
{ {
public: public:
enum Direction enum Direction
@ -170,7 +171,7 @@ public:
#elif defined(__WXGTK__) #elif defined(__WXGTK__)
#include "wx/gtk1/dataobj.h" #include "wx/gtk1/dataobj.h"
#elif defined(__WXMAC__) #elif defined(__WXMAC__)
#include "wx/osx/dataobj.h" #include "wx/mac/dataobj.h"
#elif defined(__WXCOCOA__) #elif defined(__WXCOCOA__)
#include "wx/cocoa/dataobj.h" #include "wx/cocoa/dataobj.h"
#elif defined(__WXPM__) #elif defined(__WXPM__)
@ -193,7 +194,7 @@ public:
// Otherwise, you should use wxDataObjectComposite or wxDataObject directly. // Otherwise, you should use wxDataObjectComposite or wxDataObject directly.
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxDataObjectSimple : public wxDataObject class WXDLLEXPORT wxDataObjectSimple : public wxDataObject
{ {
public: public:
// ctor takes the format we support, but it can also be set later with // 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 // the one and only format we support
wxDataFormat m_format; wxDataFormat m_format;
wxDECLARE_NO_COPY_CLASS(wxDataObjectSimple); DECLARE_NO_COPY_CLASS(wxDataObjectSimple)
}; };
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@ -260,7 +261,7 @@ private:
WX_DECLARE_EXPORTED_LIST(wxDataObjectSimple, wxSimpleDataObjectList); WX_DECLARE_EXPORTED_LIST(wxDataObjectSimple, wxSimpleDataObjectList);
class WXDLLIMPEXP_CORE wxDataObjectComposite : public wxDataObject class WXDLLEXPORT wxDataObjectComposite : public wxDataObject
{ {
public: public:
// ctor // ctor
@ -273,17 +274,11 @@ public:
void Add(wxDataObjectSimple *dataObject, bool preferred = false); void Add(wxDataObjectSimple *dataObject, bool preferred = false);
// Report the format passed to the SetData method. This should be the // 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 // 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; 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 // implement base class pure virtuals
// ---------------------------------- // ----------------------------------
virtual wxDataFormat GetPreferredFormat(wxDataObjectBase::Direction dir = Get) const; virtual wxDataFormat GetPreferredFormat(wxDataObjectBase::Direction dir = Get) const;
@ -300,6 +295,10 @@ public:
virtual size_t GetBufferOffset( const wxDataFormat& format ); virtual size_t GetBufferOffset( const wxDataFormat& format );
#endif #endif
protected:
// returns the pointer to the object which supports this format or NULL
wxDataObjectSimple *GetObject(const wxDataFormat& format) const;
private: private:
// the list of all (simple) data objects whose formats we support // the list of all (simple) data objects whose formats we support
wxSimpleDataObjectList m_dataObjects; wxSimpleDataObjectList m_dataObjects;
@ -310,7 +309,7 @@ private:
wxDataFormat m_receivedFormat; wxDataFormat m_receivedFormat;
wxDECLARE_NO_COPY_CLASS(wxDataObjectComposite); DECLARE_NO_COPY_CLASS(wxDataObjectComposite)
}; };
// ============================================================================ // ============================================================================
@ -325,54 +324,7 @@ private:
// wxTextDataObject contains text data // wxTextDataObject contains text data
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
#if wxUSE_UNICODE class WXDLLEXPORT wxTextDataObject : public wxDataObjectSimple
#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
{ {
public: public:
// ctor: you can specify the text here or in SetText(), or override // 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 // 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 size_t GetFormatCount(Direction WXUNUSED(dir) = Get) const { return 2; }
virtual void GetAllFormats(wxDataFormat *formats, virtual void GetAllFormats(wxDataFormat *formats,
wxDataObjectBase::Direction WXUNUSED(dir) = Get) const; wxDataObjectBase::Direction WXUNUSED(dir) = Get) const;
@ -411,7 +363,7 @@ public:
size_t GetDataSize(const wxDataFormat& format) const; size_t GetDataSize(const wxDataFormat& format) const;
bool GetDataHere(const wxDataFormat& format, void *pBuf) const; bool GetDataHere(const wxDataFormat& format, void *pBuf) const;
bool SetData(const wxDataFormat& format, size_t nLen, const void* pBuf); 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 size_t GetDataSize() const;
virtual bool GetDataHere(void *buf) const; virtual bool GetDataHere(void *buf) const;
virtual bool SetData(size_t len, const void *buf); virtual bool SetData(size_t len, const void *buf);
@ -428,19 +380,19 @@ public:
{ {
return SetData(len, buf); return SetData(len, buf);
} }
#endif // different wxTextDataObject implementations #endif
private: private:
wxString m_text; wxString m_text;
wxDECLARE_NO_COPY_CLASS(wxTextDataObject); DECLARE_NO_COPY_CLASS(wxTextDataObject)
}; };
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// wxBitmapDataObject contains a bitmap // wxBitmapDataObject contains a bitmap
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxBitmapDataObjectBase : public wxDataObjectSimple class WXDLLEXPORT wxBitmapDataObjectBase : public wxDataObjectSimple
{ {
public: public:
// ctor: you can specify the bitmap here or in SetBitmap(), or override // ctor: you can specify the bitmap here or in SetBitmap(), or override
@ -458,7 +410,7 @@ public:
protected: protected:
wxBitmap m_bitmap; wxBitmap m_bitmap;
wxDECLARE_NO_COPY_CLASS(wxBitmapDataObjectBase); DECLARE_NO_COPY_CLASS(wxBitmapDataObjectBase)
}; };
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@ -468,7 +420,7 @@ protected:
// data from drag and drop operation. // data from drag and drop operation.
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxFileDataObjectBase : public wxDataObjectSimple class WXDLLEXPORT wxFileDataObjectBase : public wxDataObjectSimple
{ {
public: public:
// ctor: use AddFile() later to fill the array // ctor: use AddFile() later to fill the array
@ -480,7 +432,7 @@ public:
protected: protected:
wxArrayString m_filenames; 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. // It is understood that this data can be copied bitwise.
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxCustomDataObject : public wxDataObjectSimple class WXDLLEXPORT wxCustomDataObject : public wxDataObjectSimple
{ {
public: public:
// if you don't specify the format in the ctor, you can still use // if you don't specify the format in the ctor, you can still use
@ -541,7 +493,7 @@ private:
size_t m_size; size_t m_size;
void *m_data; void *m_data;
wxDECLARE_NO_COPY_CLASS(wxCustomDataObject); DECLARE_NO_COPY_CLASS(wxCustomDataObject)
}; };
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@ -550,20 +502,19 @@ private:
#if defined(__WXMSW__) #if defined(__WXMSW__)
#include "wx/msw/ole/dataobj2.h" #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 // wxURLDataObject defined in msw/ole/dataobj2.h
#if defined(__WXGTK__) #else // !__WXMSW__
#if defined(__WXGTK20__)
#include "wx/gtk/dataobj2.h"
#elif defined(__WXGTK__)
#include "wx/gtk1/dataobj2.h" #include "wx/gtk1/dataobj2.h"
#elif defined(__WXX11__) #elif defined(__WXX11__)
#include "wx/x11/dataobj2.h" #include "wx/x11/dataobj2.h"
#elif defined(__WXMOTIF__) #elif defined(__WXMOTIF__)
#include "wx/motif/dataobj2.h" #include "wx/motif/dataobj2.h"
#elif defined(__WXMAC__) #elif defined(__WXMAC__)
#include "wx/osx/dataobj2.h" #include "wx/mac/dataobj2.h"
#elif defined(__WXCOCOA__) #elif defined(__WXCOCOA__)
#include "wx/cocoa/dataobj2.h" #include "wx/cocoa/dataobj2.h"
#elif defined(__WXPM__) #elif defined(__WXPM__)
@ -571,7 +522,7 @@ private:
#endif #endif
// wxURLDataObject is simply wxTextDataObject with a different name // wxURLDataObject is simply wxTextDataObject with a different name
class WXDLLIMPEXP_CORE wxURLDataObject : public wxTextDataObject class WXDLLEXPORT wxURLDataObject : public wxTextDataObject
{ {
public: public:
wxURLDataObject(const wxString& url = wxEmptyString) wxURLDataObject(const wxString& url = wxEmptyString)
@ -582,7 +533,7 @@ private:
wxString GetURL() const { return GetText(); } wxString GetURL() const { return GetText(); }
void SetURL(const wxString& url) { SetText(url); } void SetURL(const wxString& url) { SetText(url); }
}; };
#endif #endif // __WXMSW__/!__WXMSW__
#endif // wxUSE_DATAOBJ #endif // wxUSE_DATAOBJ

File diff suppressed because it is too large Load Diff

View File

@ -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 <vadim@wxwindows.org>
// 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_

View File

@ -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 <vadim@wxwindows.org>
// 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_

View File

@ -5,6 +5,7 @@
// Author: Vadim Zeitlin // Author: Vadim Zeitlin
// Modified by: // Modified by:
// Created: 10.02.99 // Created: 10.02.99
// RCS-ID: $Id: datetime.h 61872 2009-09-09 22:37:05Z VZ $
// Copyright: (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr> // Copyright: (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
@ -16,23 +17,19 @@
#if wxUSE_DATETIME #if wxUSE_DATETIME
#ifdef __WXWINCE__ #ifndef __WXWINCE__
#include "wx/msw/wince/time.h"
#else
#include <time.h> #include <time.h>
#endif // OS #else
#include "wx/msw/wince/time.h"
#endif
#include <limits.h> // for INT_MIN #include <limits.h> // for INT_MIN
#include "wx/longlong.h" #include "wx/longlong.h"
#include "wx/anystr.h"
class WXDLLIMPEXP_FWD_BASE wxDateTime; class WXDLLIMPEXP_FWD_BASE wxDateTime;
class WXDLLIMPEXP_FWD_BASE wxTimeSpan; class WXDLLIMPEXP_FWD_BASE wxTimeSpan;
class WXDLLIMPEXP_FWD_BASE wxDateSpan; class WXDLLIMPEXP_FWD_BASE wxDateSpan;
#ifdef __WINDOWS__
struct _SYSTEMTIME;
#endif
#include "wx/dynarray.h" #include "wx/dynarray.h"
@ -40,8 +37,11 @@ struct _SYSTEMTIME;
// set this to the corresponding value in seconds 1/1/1970 has on your // set this to the corresponding value in seconds 1/1/1970 has on your
// systems c-runtime // systems c-runtime
#if defined(__WXMAC__) && !defined(__DARWIN__) && __MSL__ < 0x6000
#define WX_TIME_BASE_OFFSET ( 2082844800L + 126144000L )
#else
#define WX_TIME_BASE_OFFSET 0 #define WX_TIME_BASE_OFFSET 0
#endif
/* /*
* TODO * TODO
* *
@ -52,6 +52,27 @@ struct _SYSTEMTIME;
* 5. wxDateTimeHolidayAuthority for Easter and other christian feasts * 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: The three (main) classes declared in this header represent:
@ -106,25 +127,12 @@ struct _SYSTEMTIME;
// wxInvalidDateTime) // wxInvalidDateTime)
class WXDLLIMPEXP_FWD_BASE wxDateTime; class WXDLLIMPEXP_FWD_BASE wxDateTime;
extern WXDLLIMPEXP_DATA_BASE(const char) wxDefaultDateTimeFormat[]; extern WXDLLIMPEXP_DATA_BASE(const wxChar*) wxDefaultDateTimeFormat;
extern WXDLLIMPEXP_DATA_BASE(const char) wxDefaultTimeSpanFormat[]; extern WXDLLIMPEXP_DATA_BASE(const wxChar*) wxDefaultTimeSpanFormat;
extern WXDLLIMPEXP_DATA_BASE(const wxDateTime) wxDefaultDateTime; extern WXDLLIMPEXP_DATA_BASE(const wxDateTime) wxDefaultDateTime;
#define wxInvalidDateTime 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 // wxDateTime represents an absolute moment in the time
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@ -151,7 +159,7 @@ public:
// the time in the current time zone // the time in the current time zone
Local, 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 // consequent numbers, so writing something like `GMT0 + offset' is
// safe if abs(offset) <= 12 // safe if abs(offset) <= 12
@ -221,6 +229,124 @@ public:
// TODO Hebrew, Chinese, Maya, ... (just kidding) (or then may be not?) // 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 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 // the end of DST period and for deciding whether the date is a work
// day or not // day or not
@ -289,22 +415,26 @@ public:
// helper classes // 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 // (in seconds) from GMT
class WXDLLIMPEXP_BASE TimeZone class WXDLLIMPEXP_BASE TimeZone
{ {
public: public:
TimeZone(TZ tz); TimeZone(TZ tz);
// create time zone object with the given offset // don't use this ctor, it doesn't work for negative offsets (but can't
TimeZone(long offset = 0) { m_offset = offset; } // 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) static TimeZone Make(long offset)
{ {
TimeZone tz; TimeZone tz;
tz.m_offset = offset; tz.m_offset = offset;
return tz; return tz;
} }
#endif // wxABI 2.8.8+
long GetOffset() const { return m_offset; } long GetOffset() const { return m_offset; }
@ -322,9 +452,7 @@ public:
// instead of modifying the member fields directly! // instead of modifying the member fields directly!
struct WXDLLIMPEXP_BASE Tm struct WXDLLIMPEXP_BASE Tm
{ {
wxDateTime_t msec, sec, min, hour, wxDateTime_t msec, sec, min, hour, mday;
mday, // Day of the month in 1..31 range.
yday; // Day of the year in 0..365 range.
Month mon; Month mon;
int year; int year;
@ -359,10 +487,9 @@ public:
// the timezone we correspond to // the timezone we correspond to
TimeZone m_tz; TimeZone m_tz;
// This value can only be accessed via GetWeekDay() and not directly // these values can't be accessed directly because they're not always
// because it's not always computed when creating this object and may // computed and we calculate them on demand
// need to be calculated on demand. wxDateTime_t wday, yday;
wxDateTime_t wday;
}; };
// static methods // static methods
@ -405,25 +532,16 @@ public:
int year = Inv_Year, int year = Inv_Year,
Calendar cal = Gregorian); Calendar cal = Gregorian);
// get the full (default) or abbreviated month name in the current // get the full (default) or abbreviated month name in the current
// locale, returns empty string on error // locale, returns empty string on error
static wxString GetMonthName(Month month, static wxString GetMonthName(Month month,
NameFlags flags = Name_Full); 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 // get the full (default) or abbreviated weekday name in the current
// locale, returns empty string on error // locale, returns empty string on error
static wxString GetWeekDayName(WeekDay weekday, static wxString GetWeekDayName(WeekDay weekday,
NameFlags flags = Name_Full); 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) // get the AM and PM strings in the current locale (may be empty)
static void GetAmPmStrings(wxString *am, wxString *pm); static void GetAmPmStrings(wxString *am, wxString *pm);
@ -459,7 +577,7 @@ public:
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
// default ctor does not initialize the object, use Set()! // 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) // from time_t: seconds since the Epoch 00:00:00 UTC, Jan 1, 1970)
#if (!(defined(__VISAGECPP__) && __IBMCPP__ >= 400)) #if (!(defined(__VISAGECPP__) && __IBMCPP__ >= 400))
@ -487,12 +605,6 @@ public:
wxDateTime_t minute = 0, wxDateTime_t minute = 0,
wxDateTime_t second = 0, wxDateTime_t second = 0,
wxDateTime_t millisec = 0); wxDateTime_t millisec = 0);
#ifdef __WINDOWS__
wxDateTime(const struct _SYSTEMTIME& st)
{
SetFromMSWSysTime(st);
}
#endif
// default copy ctor ok // default copy ctor ok
@ -540,9 +652,11 @@ public:
// resets time to 00:00:00, doesn't change the date // resets time to 00:00:00, doesn't change the date
wxDateTime& ResetTime(); wxDateTime& ResetTime();
#if wxABI_VERSION >= 20802
// get the date part of this object only, i.e. the object which has the // 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 // same date as this one but time of 00:00:00
wxDateTime GetDateOnly() const; wxDateTime GetDateOnly() const;
#endif // wxABI 2.8.1+
// the following functions don't change the values of the other // the following functions don't change the values of the other
// fields, i.e. SetMinute() won't change either hour or seconds value // fields, i.e. SetMinute() won't change either hour or seconds value
@ -574,7 +688,7 @@ public:
// default assignment operator is ok // default assignment operator is ok
// calendar calculations (functions which set the date only leave the time // 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. // object itself, GetXXX() ones return a new object.
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
@ -592,7 +706,7 @@ public:
wxDateTime& SetToPrevWeekDay(WeekDay weekday); wxDateTime& SetToPrevWeekDay(WeekDay weekday);
inline wxDateTime GetPrevWeekDay(WeekDay weekday) const; 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 // 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 // failure. n may be positive (1..5) or negative to count from the end
// of the month (see helper function SetToLastWeekDay()) // of the month (see helper function SetToLastWeekDay())
@ -790,6 +904,14 @@ public:
// because the holidays are different in different countries // because the holidays are different in different countries
bool IsWorkDay(Country country = Country_Default) const; 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 // dos date and time format
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
@ -799,20 +921,6 @@ public:
// pack the date in DOS format // pack the date in DOS format
unsigned long GetAsDOS() const; 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) // comparison (see also functions below for operator versions)
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
@ -936,195 +1044,46 @@ public:
inline wxTimeSpan Subtract(const wxDateTime& dt) const; inline wxTimeSpan Subtract(const wxDateTime& dt) const;
inline wxTimeSpan operator-(const wxDateTime& dt2) const; inline wxTimeSpan operator-(const wxDateTime& dt2) const;
wxDateSpan DiffAsDateSpan(const wxDateTime& dt) const; // conversion to/from text: all conversions from text return the pointer to
// the next character following the date specification (i.e. the one where
// conversion to/from text // 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 // 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") // having the form "Wed, 10 Feb 1999 19:07:07 +0100")
bool ParseRfc822Date(const wxString& date, const wxChar *ParseRfc822Date(const wxChar* date);
wxString::const_iterator *end);
// parse a date/time in the given format (see strptime(3)), fill in // 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 // 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, they will not change if they had valid values or will
// default to Today() otherwise) // default to Today() otherwise)
bool ParseFormat(const wxString& date, const wxChar *ParseFormat(const wxChar *date,
const wxString& format, const wxChar *format = wxDefaultDateTimeFormat,
const wxDateTime& dateDef, const wxDateTime& dateDef = wxDefaultDateTime);
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();
}
// parse a string containing the date/time in "free" format, this // parse a string containing the date/time in "free" format, this
// function will try to make an educated guess at the string contents // function will try to make an educated guess at the string contents
bool ParseDateTime(const wxString& datetime, const wxChar *ParseDateTime(const wxChar *datetime);
wxString::const_iterator *end);
// parse a string containing the date only in "free" format (less // parse a string containing the date only in "free" format (less
// flexible than ParseDateTime) // flexible than ParseDateTime)
bool ParseDate(const wxString& date, const wxChar *ParseDate(const wxChar *date);
wxString::const_iterator *end);
// parse a string containing the time only in "free" format // parse a string containing the time only in "free" format
bool ParseTime(const wxString& time, const wxChar *ParseTime(const wxChar *time);
wxString::const_iterator *end);
// this function accepts strftime()-like format string (default // this function accepts strftime()-like format string (default
// argument corresponds to the preferred date and time representation // argument corresponds to the preferred date and time representation
// for the current locale) and returns the string containing the // for the current locale) and returns the string containing the
// resulting text representation // resulting text representation
wxString Format(const wxString& format = wxDefaultDateTimeFormat, wxString Format(const wxChar *format = wxDefaultDateTimeFormat,
const TimeZone& tz = Local) const; const TimeZone& tz = Local) const;
// preferred date representation for the current locale // 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 // 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 // returns the string representing the date in ISO 8601 format
// (YYYY-MM-DD) // (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 // returns the string representing the time in ISO 8601 format
// (HH:MM:SS) // (HH:MM:SS)
wxString FormatISOTime() const { return Format(wxS("%H:%M:%S")); } wxString FormatISOTime() const { return Format(wxT("%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);
// implementation // implementation
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
@ -1136,7 +1095,7 @@ public:
inline wxLongLong GetValue() const; inline wxLongLong GetValue() const;
// a helper function to get the current time_t // 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 // another one to get the current time broken down
static struct tm *GetTmNow() static struct tm *GetTmNow()
@ -1293,7 +1252,7 @@ public:
// compare two timestamps: works with the absolute values, i.e. 1 // compare two timestamps: works with the absolute values, i.e. 1
// hour is shorter than -2 hours. Also, it will return false if the // hour is shorter than -2 hours. Also, it will return false if the
// timespans are equal in absolute value. // 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 inline bool operator<(const wxTimeSpan &ts) const
{ {
@ -1350,7 +1309,7 @@ public:
// resulting text representation. Notice that only some of format // resulting text representation. Notice that only some of format
// specifiers valid for wxDateTime are valid for wxTimeSpan: hours, // specifiers valid for wxDateTime are valid for wxTimeSpan: hours,
// minutes and seconds make sense, but not "PM/AM" string for example. // 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 // implementation
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
@ -1452,8 +1411,6 @@ public:
int GetYears() const { return m_years; } int GetYears() const { return m_years; }
// get number of months // get number of months
int GetMonths() const { return m_months; } int GetMonths() const { return m_months; }
// returns 12*GetYears() + GetMonths()
int GetTotalMonths() const { return 12*m_years + m_months; }
// get number of weeks // get number of weeks
int GetWeeks() const { return m_weeks; } int GetWeeks() const { return m_weeks; }
// get number of days // get number of days
@ -1630,9 +1587,7 @@ protected:
inline bool wxDateTime::IsInStdRange() const inline bool wxDateTime::IsInStdRange() const
{ {
// currently we don't know what is the real type of time_t so prefer to err return m_time >= 0l && (m_time / TIME_T_FACTOR) < LONG_MAX;
// 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;
} }
/* static */ /* static */
@ -1653,17 +1608,10 @@ inline wxDateTime wxDateTime::Today()
#if (!(defined(__VISAGECPP__) && __IBMCPP__ >= 400)) #if (!(defined(__VISAGECPP__) && __IBMCPP__ >= 400))
inline wxDateTime& wxDateTime::Set(time_t timet) 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! // assign first to avoid long multiplication overflow!
m_time = timet - WX_TIME_BASE_OFFSET ; m_time = timet - WX_TIME_BASE_OFFSET ;
m_time *= TIME_T_FACTOR; m_time *= TIME_T_FACTOR;
}
return *this; return *this;
} }
@ -1999,9 +1947,9 @@ inline wxLongLong wxTimeSpan::GetSeconds() const
inline int wxTimeSpan::GetMinutes() const inline int wxTimeSpan::GetMinutes() const
{ {
// For compatibility, this method (and the other accessors) return int, // explicit cast to int suppresses a warning with CodeWarrior and possibly
// even though GetLo() actually returns unsigned long with greater range. // others (changing the return type to long from int is impossible in 2.8)
return static_cast<int>((GetSeconds() / 60l).GetLo()); return (int)((GetSeconds() / 60l).GetLo());
} }
inline int wxTimeSpan::GetHours() const inline int wxTimeSpan::GetHours() const
@ -2074,11 +2022,6 @@ inline bool wxTimeSpan::IsLongerThan(const wxTimeSpan& ts) const
return GetValue().Abs() > ts.GetValue().Abs(); return GetValue().Abs() > ts.GetValue().Abs();
} }
inline bool wxTimeSpan::IsShorterThan(const wxTimeSpan& ts) const
{
return GetValue().Abs() < ts.GetValue().Abs();
}
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// wxDateSpan // wxDateSpan
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------

View File

@ -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 <vadim@wxwidgets.org>
// 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_

View File

@ -1,9 +1,10 @@
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// Name: wx/datstrm.h // Name: datstrm.h
// Purpose: Data stream classes // Purpose: Data stream classes
// Author: Guilhem Lavaux // Author: Guilhem Lavaux
// Modified by: Mickael Gilabert // Modified by: Mickael Gilabert
// Created: 28/06/1998 // Created: 28/06/1998
// RCS-ID: $Id: datstrm.h 38576 2006-04-05 16:10:08Z VZ $
// Copyright: (c) Guilhem Lavaux // Copyright: (c) Guilhem Lavaux
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
@ -17,64 +18,15 @@
#if wxUSE_STREAMS #if wxUSE_STREAMS
// Common wxDataInputStream and wxDataOutputStream parameters. class WXDLLIMPEXP_BASE wxDataInputStream
class WXDLLIMPEXP_BASE wxDataStreamBase
{ {
public: 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 #if wxUSE_UNICODE
void SetConv( const wxMBConv &conv ); wxDataInputStream(wxInputStream& s, const wxMBConv& conv = wxConvAuto());
wxMBConv *GetConv() const { return m_conv; } #else
wxDataInputStream(wxInputStream& s);
#endif #endif
~wxDataInputStream();
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);
bool IsOk() { return m_input->IsOk(); } bool IsOk() { return m_input->IsOk(); }
@ -88,7 +40,6 @@ public:
wxUint16 Read16(); wxUint16 Read16();
wxUint8 Read8(); wxUint8 Read8();
double ReadDouble(); double ReadDouble();
float ReadFloat();
wxString ReadString(); wxString ReadString();
#if wxHAS_INT64 #if wxHAS_INT64
@ -107,7 +58,6 @@ public:
void Read16(wxUint16 *buffer, size_t size); void Read16(wxUint16 *buffer, size_t size);
void Read8(wxUint8 *buffer, size_t size); void Read8(wxUint8 *buffer, size_t size);
void ReadDouble(double *buffer, size_t size); void ReadDouble(double *buffer, size_t size);
void ReadFloat(float *buffer, size_t size);
wxDataInputStream& operator>>(wxString& s); wxDataInputStream& operator>>(wxString& s);
wxDataInputStream& operator>>(wxInt8& c); wxDataInputStream& operator>>(wxInt8& c);
@ -124,19 +74,30 @@ public:
wxDataInputStream& operator>>(wxULongLong& i); wxDataInputStream& operator>>(wxULongLong& i);
wxDataInputStream& operator>>(wxLongLong& i); wxDataInputStream& operator>>(wxLongLong& i);
#endif #endif
wxDataInputStream& operator>>(double& d); wxDataInputStream& operator>>(double& i);
wxDataInputStream& operator>>(float& f); wxDataInputStream& operator>>(float& f);
void BigEndianOrdered(bool be_order) { m_be_order = be_order; }
protected: protected:
wxInputStream *m_input; 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: 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(); } bool IsOk() { return m_output->IsOk(); }
@ -152,7 +113,6 @@ public:
void Write16(wxUint16 i); void Write16(wxUint16 i);
void Write8(wxUint8 i); void Write8(wxUint8 i);
void WriteDouble(double d); void WriteDouble(double d);
void WriteFloat(float f);
void WriteString(const wxString& string); void WriteString(const wxString& string);
#if wxHAS_INT64 #if wxHAS_INT64
@ -171,8 +131,8 @@ public:
void Write16(const wxUint16 *buffer, size_t size); void Write16(const wxUint16 *buffer, size_t size);
void Write8(const wxUint8 *buffer, size_t size); void Write8(const wxUint8 *buffer, size_t size);
void WriteDouble(const double *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<<(const wxString& string);
wxDataOutputStream& operator<<(wxInt8 c); wxDataOutputStream& operator<<(wxInt8 c);
wxDataOutputStream& operator<<(wxInt16 i); wxDataOutputStream& operator<<(wxInt16 i);
@ -188,13 +148,19 @@ public:
wxDataOutputStream& operator<<(const wxULongLong &i); wxDataOutputStream& operator<<(const wxULongLong &i);
wxDataOutputStream& operator<<(const wxLongLong &i); wxDataOutputStream& operator<<(const wxLongLong &i);
#endif #endif
wxDataOutputStream& operator<<(double d); wxDataOutputStream& operator<<(double f);
wxDataOutputStream& operator<<(float f); wxDataOutputStream& operator<<(float f);
void BigEndianOrdered(bool be_order) { m_be_order = be_order; }
protected: protected:
wxOutputStream *m_output; 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 #endif

File diff suppressed because it is too large Load Diff

View File

@ -4,6 +4,7 @@
// Author: Ron Lee <ron@debian.org> // Author: Ron Lee <ron@debian.org>
// Modified by: Vadim Zeitlin (refactored, added bg preservation) // Modified by: Vadim Zeitlin (refactored, added bg preservation)
// Created: 16/03/02 // Created: 16/03/02
// RCS-ID: $Id: dcbuffer.h 61872 2009-09-09 22:37:05Z VZ $
// Copyright: (c) Ron Lee // Copyright: (c) Ron Lee
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
@ -36,11 +37,7 @@
// does not prepare the window DC // does not prepare the window DC
#define wxBUFFER_CLIENT_AREA 0x02 #define wxBUFFER_CLIENT_AREA 0x02
// Set when not using specific buffer bitmap. Note that this class WXDLLEXPORT wxBufferedDC : public wxMemoryDC
// is private style and not returned by GetStyle.
#define wxBUFFER_USES_SHARED_BUFFER 0x04
class WXDLLIMPEXP_CORE wxBufferedDC : public wxMemoryDC
{ {
public: public:
// Default ctor, must subsequently call Init for two stage construction. // 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 // 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 // BufferedDC must blit before the derived class (which may own the dc it's
// blitting to) is destroyed. // 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 // Set and get the style
void SetStyle(int style) { m_style = 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: private:
// common part of Init()s // common part of Init()s
@ -115,6 +126,10 @@ private:
m_dc = dc; m_dc = dc;
m_style = style; 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 // check that the bitmap is valid and use it
@ -133,10 +148,8 @@ private:
// the buffering style // the buffering style
int m_style; int m_style;
wxSize m_area;
DECLARE_DYNAMIC_CLASS(wxBufferedDC) 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 // Creates a double buffered wxPaintDC, optionally allowing the
// user to specify their own buffer to use. // user to specify their own buffer to use.
class WXDLLIMPEXP_CORE wxBufferedPaintDC : public wxBufferedDC class WXDLLEXPORT wxBufferedPaintDC : public wxBufferedDC
{ {
public: public:
// If no bitmap is supplied by the user, a temporary one will be created. // If no bitmap is supplied by the user, a temporary one will be created.
@ -196,7 +209,7 @@ private:
wxPaintDC m_paintdc; wxPaintDC m_paintdc;
DECLARE_ABSTRACT_CLASS(wxBufferedPaintDC) DECLARE_ABSTRACT_CLASS(wxBufferedPaintDC)
wxDECLARE_NO_COPY_CLASS(wxBufferedPaintDC); DECLARE_NO_COPY_CLASS(wxBufferedPaintDC)
}; };
@ -213,25 +226,40 @@ private:
#define wxAutoBufferedPaintDCBase wxBufferedPaintDC #define wxAutoBufferedPaintDCBase wxBufferedPaintDC
#endif #endif
class WXDLLIMPEXP_CORE wxAutoBufferedPaintDC : public wxAutoBufferedPaintDCBase
#ifdef __WXDEBUG__
class wxAutoBufferedPaintDC : public wxAutoBufferedPaintDCBase
{ {
public: public:
wxAutoBufferedPaintDC(wxWindow* win) wxAutoBufferedPaintDC(wxWindow* win)
: wxAutoBufferedPaintDCBase(win) : wxAutoBufferedPaintDCBase(win)
{ {
wxASSERT_MSG( win->GetBackgroundStyle() == wxBG_STYLE_PAINT, TestWinStyle(win);
"You need to call SetBackgroundStyle(wxBG_STYLE_PAINT) in ctor, "
"and also, if needed, paint the background in wxEVT_PAINT handler."
);
} }
virtual ~wxAutoBufferedPaintDC() { } virtual ~wxAutoBufferedPaintDC() { }
private: 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 // Check if the window is natively double buffered and will return a wxPaintDC

View File

@ -2,61 +2,41 @@
// Name: wx/dcclient.h // Name: wx/dcclient.h
// Purpose: wxClientDC base header // Purpose: wxClientDC base header
// Author: Julian Smart // Author: Julian Smart
// Modified by:
// Created:
// Copyright: (c) Julian Smart // Copyright: (c) Julian Smart
// RCS-ID: $Id: dcclient.h 40865 2006-08-27 09:42:42Z VS $
// Licence: wxWindows Licence // Licence: wxWindows Licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#ifndef _WX_DCCLIENT_H_BASE_ #ifndef _WX_DCCLIENT_H_BASE_
#define _WX_DCCLIENT_H_BASE_ #define _WX_DCCLIENT_H_BASE_
#include "wx/dc.h" #include "wx/defs.h"
//----------------------------------------------------------------------------- #if defined(__WXPALMOS__)
// wxWindowDC #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 #endif
{ // _WX_DCCLIENT_H_BASE_
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_

View File

@ -1,10 +1,11 @@
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// Name: wx/dcgraph.h // Name: wx/graphdc.h
// Purpose: graphics context device bridge header // Purpose: graphics context device bridge header
// Author: Stefan Csomor // Author: Stefan Csomor
// Modified by: // Modified by:
// Created: // Created:
// Copyright: (c) Stefan Csomor // Copyright: (c) Stefan Csomor
// RCS-ID: $Id: dcgraph.h 53390 2008-04-28 04:19:15Z KO $
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
@ -13,59 +14,36 @@
#if wxUSE_GRAPHICS_CONTEXT #if wxUSE_GRAPHICS_CONTEXT
#include "wx/dc.h"
#include "wx/geometry.h" #include "wx/geometry.h"
#include "wx/dynarray.h"
#include "wx/graphics.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: public:
wxGCDC(const wxWindowDC& dc); wxGCDC(const wxWindowDC& dc);
#ifdef __WXMSW__
wxGCDC( const wxMemoryDC& dc); wxGCDC( const wxMemoryDC& dc);
#if wxUSE_PRINTING_ARCHITECTURE
wxGCDC( const wxPrinterDC& dc );
#endif #endif
#if defined(__WXMSW__) && wxUSE_ENH_METAFILE
wxGCDC( const wxEnhMetaFileDC& dc );
#endif
wxGCDC(wxGraphicsContext* context);
wxGCDC(); wxGCDC();
virtual ~wxGCDC(); virtual ~wxGCDC();
wxGraphicsContext* GetGraphicsContext() const; void Init();
void SetGraphicsContext( wxGraphicsContext* ctx );
#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 // implement base class pure virtuals
// ---------------------------------- // ----------------------------------
@ -78,8 +56,9 @@ public:
virtual void StartPage(); virtual void StartPage();
virtual void EndPage(); virtual void EndPage();
// to be virtualized on next major
// flushing the content of this dc immediately onto screen // flushing the content of this dc immediately onto screen
virtual void Flush(); void Flush();
virtual void SetFont(const wxFont& font); virtual void SetFont(const wxFont& font);
virtual void SetPen(const wxPen& pen); virtual void SetPen(const wxPen& pen);
@ -98,21 +77,27 @@ public:
virtual int GetDepth() const; virtual int GetDepth() const;
virtual wxSize GetPPI() 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 SetTextForeground(const wxColour& colour);
virtual void SetTextBackground(const wxColour& colour); virtual void SetTextBackground(const wxColour& colour);
virtual void ComputeScaleAndOrigin(); virtual void ComputeScaleAndOrigin();
wxGraphicsContext* GetGraphicsContext() const { return m_graphicContext; } wxGraphicsContext* GetGraphicsContext() { return m_graphicContext; }
virtual void SetGraphicsContext( wxGraphicsContext* ctx ); virtual void SetGraphicsContext( wxGraphicsContext* ctx );
virtual void* GetHandle() const; protected:
// the true implementations // the true implementations
virtual bool DoFloodFill(wxCoord x, wxCoord y, const wxColour& col, virtual bool DoFloodFill(wxCoord x, wxCoord y, const wxColour& col,
wxFloodFillStyle style = wxFLOOD_SURFACE); int style = wxFLOOD_SURFACE);
virtual void DoGradientFillLinear(const wxRect& rect, virtual void DoGradientFillLinear(const wxRect& rect,
const wxColour& initialColour, const wxColour& initialColour,
@ -129,7 +114,7 @@ public:
virtual void DoDrawPoint(wxCoord x, wxCoord y); virtual void DoDrawPoint(wxCoord x, wxCoord y);
#if wxUSE_SPLINES #if wxUSE_SPLINES
virtual void DoDrawSpline(const wxPointList *points); virtual void DoDrawSpline(wxList *points);
#endif #endif
virtual void DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2); virtual void DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2);
@ -162,30 +147,21 @@ public:
virtual bool DoBlit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height, virtual bool DoBlit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height,
wxDC *source, wxCoord xsrc, wxCoord ysrc, wxDC *source, wxCoord xsrc, wxCoord ysrc,
wxRasterOperationMode rop = wxCOPY, bool useMask = false, int rop = wxCOPY, bool useMask = false, wxCoord xsrcMask = -1, wxCoord ysrcMask = -1);
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);
virtual void DoGetSize(int *,int *) const; virtual void DoGetSize(int *,int *) const;
virtual void DoGetSizeMM(int* width, int* height) 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); wxCoord xoffset, wxCoord yoffset);
virtual void DoDrawPolygon(int n, const wxPoint points[], virtual void DoDrawPolygon(int n, wxPoint points[],
wxCoord xoffset, wxCoord yoffset, wxCoord xoffset, wxCoord yoffset,
wxPolygonFillMode fillStyle = wxODDEVEN_RULE); int fillStyle = wxODDEVEN_RULE);
virtual void DoDrawPolyPolygon(int n, const int count[], const wxPoint points[], virtual void DoDrawPolyPolygon(int n, int count[], wxPoint points[],
wxCoord xoffset, wxCoord yoffset, wxCoord xoffset, wxCoord yoffset,
wxPolygonFillMode fillStyle); int fillStyle);
virtual void DoSetDeviceClippingRegion(const wxRegion& region); virtual void DoSetClippingRegionAsRegion(const wxRegion& region);
virtual void DoSetClippingRegion(wxCoord x, wxCoord y, virtual void DoSetClippingRegion(wxCoord x, wxCoord y,
wxCoord width, wxCoord height); wxCoord width, wxCoord height);
@ -193,34 +169,22 @@ public:
wxCoord *x, wxCoord *y, wxCoord *x, wxCoord *y,
wxCoord *descent = NULL, wxCoord *descent = NULL,
wxCoord *externalLeading = NULL, wxCoord *externalLeading = NULL,
const wxFont *theFont = NULL) const; wxFont *theFont = NULL) const;
virtual bool DoGetPartialTextExtents(const wxString& text, wxArrayInt& widths) const; virtual bool DoGetPartialTextExtents(const wxString& text, wxArrayInt& widths) const;
#ifdef __WXMSW__
virtual wxRect MSWApplyGDIPlusTransform(const wxRect& r) const;
#endif // __WXMSW__
protected: 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 // scaling variables
bool m_logicalFunctionSupported; bool m_logicalFunctionSupported;
double m_mm_to_pix_x, m_mm_to_pix_y;
wxGraphicsMatrix m_matrixOriginal; wxGraphicsMatrix m_matrixOriginal;
wxGraphicsMatrix m_matrixCurrent; wxGraphicsMatrix m_matrixCurrent;
double m_formerScaleX, m_formerScaleY; double m_formerScaleX, m_formerScaleY;
wxGraphicsContext* m_graphicContext; 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_ #endif // _WX_GRAPHICS_DC_H_

View File

@ -5,40 +5,72 @@
// Modified by: // Modified by:
// Created: // Created:
// Copyright: (c) Julian Smart // Copyright: (c) Julian Smart
// RCS-ID: $Id: dcmemory.h 43843 2006-12-07 05:44:44Z PC $
// Licence: wxWindows Licence // Licence: wxWindows Licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#ifndef _WX_DCMEMORY_H_BASE_ #ifndef _WX_DCMEMORY_H_BASE_
#define _WX_DCMEMORY_H_BASE_ #define _WX_DCMEMORY_H_BASE_
#include "wx/dc.h"
#include "wx/bitmap.h" #include "wx/bitmap.h"
//----------------------------------------------------------------------------- // NOTE: different native implementations of wxMemoryDC will derive from
// wxMemoryDC // 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 WXDLLIMPEXP_CORE wxMemoryDC: public wxDC class WXDLLEXPORT wxMemoryDCBase
{ {
public: public:
wxMemoryDC(); wxMemoryDCBase() { }
wxMemoryDC( wxBitmap& bitmap );
wxMemoryDC( wxDC *dc ); // avoid warnings about having virtual functions but non virtual dtor
virtual ~wxMemoryDCBase() { }
// select the given bitmap to draw on it // 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 // select the given bitmap for read-only
void SelectObjectAsSource(const wxBitmap& bmp); virtual void SelectObjectAsSource(const wxBitmap& bmp)
{
DoSelect(bmp);
}
// get selected bitmap protected:
const wxBitmap& GetSelectedBitmap() const; virtual void DoSelect(const wxBitmap& bmp) = 0;
wxBitmap& GetSelectedBitmap();
private:
DECLARE_DYNAMIC_CLASS(wxMemoryDC)
}; };
#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 #endif
// _WX_DCMEMORY_H_BASE_ // _WX_DCMEMORY_H_BASE_

View File

@ -4,6 +4,7 @@
// Author: Vadim Zeitlin // Author: Vadim Zeitlin
// Modified by: // Modified by:
// Created: 21.07.2003 // Created: 21.07.2003
// RCS-ID: $Id: dcmirror.h 61872 2009-09-09 22:37:05Z VZ $
// Copyright: (c) 2003 Vadim Zeitlin <vadim@wxwidgets.org> // Copyright: (c) 2003 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence: wxWindows licence // Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
@ -17,7 +18,7 @@
// wxMirrorDC allows to write the same code for horz/vertical layout // wxMirrorDC allows to write the same code for horz/vertical layout
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxMirrorDCImpl : public wxDCImpl class WXDLLEXPORT wxMirrorDC : public wxDC
{ {
public: public:
// constructs a mirror DC associated with the given real DC // 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 // if mirror parameter is true, all vertical and horizontal coordinates are
// exchanged, otherwise this class behaves in exactly the same way as a // exchanged, otherwise this class behaves in exactly the same way as a
// plain DC // plain DC
wxMirrorDCImpl(wxDC *owner, wxDCImpl& dc, bool mirror) //
: wxDCImpl(owner), // the cast to wxMirrorDC is a dirty hack done to allow us to call the
m_dc(dc) // 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
m_mirror = mirror; // make any sense in this particular situation)
} wxMirrorDC(wxDC& dc, bool mirror) : m_dc((wxMirrorDC&)dc)
{ m_mirror = mirror; }
// wxDCBase operations // wxDCBase operations
virtual void Clear() { m_dc.Clear(); } virtual void Clear() { m_dc.Clear(); }
@ -51,8 +53,9 @@ public:
virtual bool CanGetTextExtent() const { return m_dc.CanGetTextExtent(); } virtual bool CanGetTextExtent() const { return m_dc.CanGetTextExtent(); }
virtual int GetDepth() const { return m_dc.GetDepth(); } virtual int GetDepth() const { return m_dc.GetDepth(); }
virtual wxSize GetPPI() const { return m_dc.GetPPI(); } virtual wxSize GetPPI() const { return m_dc.GetPPI(); }
virtual bool IsOk() const { return m_dc.IsOk(); } virtual bool Ok() const { return IsOk(); }
virtual void SetMapMode(wxMappingMode mode) { m_dc.SetMapMode(mode); } virtual bool IsOk() const { return m_dc.Ok(); }
virtual void SetMapMode(int mode) { m_dc.SetMapMode(mode); }
virtual void SetUserScale(double x, double y) virtual void SetUserScale(double x, double y)
{ m_dc.SetUserScale(GetX(x, y), GetY(x, y)); } { m_dc.SetUserScale(GetX(x, y), GetY(x, y)); }
virtual void SetLogicalOrigin(wxCoord x, wxCoord y) virtual void SetLogicalOrigin(wxCoord x, wxCoord y)
@ -62,11 +65,14 @@ public:
virtual void SetAxisOrientation(bool xLeftRight, bool yBottomUp) virtual void SetAxisOrientation(bool xLeftRight, bool yBottomUp)
{ m_dc.SetAxisOrientation(GetX(xLeftRight, yBottomUp), { m_dc.SetAxisOrientation(GetX(xLeftRight, yBottomUp),
GetY(xLeftRight, yBottomUp)); } GetY(xLeftRight, yBottomUp)); }
virtual void SetLogicalFunction(wxRasterOperationMode function) virtual void SetLogicalFunction(int function)
{ m_dc.SetLogicalFunction(function); } { m_dc.SetLogicalFunction(function); }
virtual void* GetHandle() const // helper functions which may be useful for the users of this class
{ return m_dc.GetHandle(); } wxSize Reflect(const wxSize& sizeOrig)
{
return m_mirror ? wxSize(sizeOrig.y, sizeOrig.x) : sizeOrig;
}
protected: protected:
// returns x and y if not mirroring or y and x if mirroring // 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 *GetX(wxCoord *x, wxCoord *y) const { return m_mirror ? y : x; }
wxCoord *GetY(wxCoord *x, wxCoord *y) const { return m_mirror ? x : y; } 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 // exchange x and y unconditionally
wxPoint* Mirror(int n, const wxPoint*& points) const 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 ) if ( m_mirror )
{ {
points_alloc = new wxPoint[n];
for ( int i = 0; i < n; i++ ) for ( int i = 0; i < n; i++ )
{ {
points_alloc[i].x = points[i].y; Swap(points[i].x, points[i].y);
points_alloc[i].y = points[i].x;
} }
points = points_alloc;
} }
return points_alloc;
} }
// wxDCBase functions // wxDCBase functions
virtual bool DoFloodFill(wxCoord x, wxCoord y, const wxColour& col, 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); return m_dc.DoFloodFill(GetX(x, y), GetY(x, y), col, style);
} }
@ -200,8 +210,7 @@ protected:
virtual bool DoBlit(wxCoord xdest, wxCoord ydest, virtual bool DoBlit(wxCoord xdest, wxCoord ydest,
wxCoord w, wxCoord h, wxCoord w, wxCoord h,
wxDC *source, wxCoord xsrc, wxCoord ysrc, wxDC *source, wxCoord xsrc, wxCoord ysrc,
wxRasterOperationMode rop = wxCOPY, int rop = wxCOPY, bool useMask = false,
bool useMask = false,
wxCoord xsrcMask = wxDefaultCoord, wxCoord ysrcMask = wxDefaultCoord) wxCoord xsrcMask = wxDefaultCoord, wxCoord ysrcMask = wxDefaultCoord)
{ {
return m_dc.DoBlit(GetX(xdest, ydest), GetY(xdest, ydest), return m_dc.DoBlit(GetX(xdest, ydest), GetY(xdest, ydest),
@ -221,31 +230,31 @@ protected:
m_dc.DoGetSizeMM(GetX(w, h), GetY(w, h)); 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) wxCoord xoffset, wxCoord yoffset)
{ {
wxPoint* points_alloc = Mirror(n, points); Mirror(n, points);
m_dc.DoDrawLines(n, points, m_dc.DoDrawLines(n, points,
GetX(xoffset, yoffset), GetY(xoffset, yoffset)); 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, 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, m_dc.DoDrawPolygon(n, points,
GetX(xoffset, yoffset), GetY(xoffset, yoffset), GetX(xoffset, yoffset), GetY(xoffset, yoffset),
fillStyle); 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") ); wxFAIL_MSG( wxT("not implemented") );
} }
@ -260,39 +269,18 @@ protected:
wxCoord *x, wxCoord *y, wxCoord *x, wxCoord *y,
wxCoord *descent = NULL, wxCoord *descent = NULL,
wxCoord *externalLeading = NULL, wxCoord *externalLeading = NULL,
const wxFont *theFont = NULL) const wxFont *theFont = NULL) const
{ {
// never mirrored // never mirrored
m_dc.DoGetTextExtent(string, x, y, descent, externalLeading, theFont); m_dc.DoGetTextExtent(string, x, y, descent, externalLeading, theFont);
} }
private: private:
wxDCImpl& m_dc; wxMirrorDC& m_dc;
bool m_mirror; bool m_mirror;
wxDECLARE_NO_COPY_CLASS(wxMirrorDCImpl); DECLARE_NO_COPY_CLASS(wxMirrorDC)
};
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);
}; };
#endif // _WX_DCMIRROR_H_ #endif // _WX_DCMIRROR_H_

View File

@ -5,6 +5,7 @@
// Modified by: // Modified by:
// Created: // Created:
// Copyright: (c) Julian Smart // Copyright: (c) Julian Smart
// RCS-ID: $Id: dcprint.h 41240 2006-09-15 16:45:48Z PC $
// Licence: wxWindows Licence // Licence: wxWindows Licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
@ -15,28 +16,18 @@
#if wxUSE_PRINTING_ARCHITECTURE #if wxUSE_PRINTING_ARCHITECTURE
#include "wx/dc.h" #if defined(__WXPALMOS__)
#include "wx/palmos/dcprint.h"
//----------------------------------------------------------------------------- #elif defined(__WXMSW__)
// wxPrinterDC #include "wx/msw/dcprint.h"
//----------------------------------------------------------------------------- #endif
#if defined(__WXPM__)
class WXDLLIMPEXP_CORE wxPrinterDC : public wxDC #include "wx/os2/dcprint.h"
{ #endif
public: #if defined(__WXMAC__)
wxPrinterDC(); #include "wx/mac/dcprint.h"
wxPrinterDC(const wxPrintData& data); #endif
wxRect GetPaperRect() const;
int GetResolution() const;
protected:
wxPrinterDC(wxDCImpl *impl) : wxDC(impl) { }
private:
DECLARE_DYNAMIC_CLASS(wxPrinterDC)
};
#endif // wxUSE_PRINTING_ARCHITECTURE #endif // wxUSE_PRINTING_ARCHITECTURE
#endif
#endif // _WX_DCPRINT_H_BASE_ // _WX_DCPRINT_H_BASE_

View File

@ -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

View File

@ -5,6 +5,7 @@
// Modified by: // Modified by:
// Created: // Created:
// Copyright: (c) Julian Smart // Copyright: (c) Julian Smart
// RCS-ID: $Id: dcscreen.h 40865 2006-08-27 09:42:42Z VS $
// Licence: wxWindows Licence // Licence: wxWindows Licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
@ -12,24 +13,30 @@
#define _WX_DCSCREEN_H_BASE_ #define _WX_DCSCREEN_H_BASE_
#include "wx/defs.h" #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 #endif
// _WX_DCSCREEN_H_BASE_ // _WX_DCSCREEN_H_BASE_

View File

@ -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 <g> 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_

View File

@ -5,6 +5,7 @@
// Modified by: // Modified by:
// Created: // Created:
// Copyright: (c) Julian Smart // Copyright: (c) Julian Smart
// RCS-ID: $Id: dde.h 53135 2008-04-12 02:31:04Z VZ $
// Licence: wxWindows Licence // 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(wxDDEServer, wxDDEServerList, WXDLLIMPEXP_BASE);
WX_DECLARE_USER_EXPORTED_LIST(wxDDEConnection, wxDDEConnectionList, WXDLLIMPEXP_BASE); WX_DECLARE_USER_EXPORTED_LIST(wxDDEConnection, wxDDEConnectionList, WXDLLIMPEXP_BASE);
#if defined(__WINDOWS__) #if defined(__WXMSW__)
#include "wx/msw/dde.h" #include "wx/msw/dde.h"
#else #else
#error DDE is only supported under Windows #error DDE is only supported on MSW
#endif #endif
#endif #endif

View File

@ -1,350 +1,208 @@
///////////////////////////////////////////////////////////////////////////// /**
// Name: wx/debug.h * Name: wx/debug.h
// Purpose: Misc debug functions and macros * Purpose: Misc debug functions and macros
// Author: Vadim Zeitlin * Author: Vadim Zeitlin
// Created: 29/01/98 * Modified by: Ryan Norton (Converted to C)
// Copyright: (c) 1998-2009 Vadim Zeitlin <vadim@wxwidgets.org> * Created: 29/01/98
// Licence: wxWindows licence * RCS-ID: $Id: debug.h 61872 2009-09-09 22:37:05Z VZ $
///////////////////////////////////////////////////////////////////////////// * Copyright: (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
* Licence: wxWindows licence
*/
/* THIS IS A C FILE, DON'T USE C++ FEATURES (IN PARTICULAR COMMENTS) IN IT */
#ifndef _WX_DEBUG_H_ #ifndef _WX_DEBUG_H_
#define _WX_DEBUG_H_ #define _WX_DEBUG_H_
#if !defined(__WXWINCE__) #ifndef __WXWINCE__
#include <assert.h> #include <assert.h>
#endif // systems without assert.h #endif
#include <limits.h> /* for CHAR_BIT used below */
#include <limits.h> // for CHAR_BIT used below #include "wx/wxchar.h" /* for __TFILE__ and wxChar */
#include "wx/chartype.h" // for __TFILE__ and wxChar /* ---------------------------------------------------------------------------- */
#include "wx/cpp.h" // for __WXFUNCTION__ /* Defines controlling the debugging macros */
#include "wx/dlimpexp.h" // for WXDLLIMPEXP_FWD_BASE /* ---------------------------------------------------------------------------- */
class WXDLLIMPEXP_FWD_BASE wxString; /* if _DEBUG is defined (MS VC++ and others use it in debug builds), define */
class WXDLLIMPEXP_FWD_BASE wxCStrData; /* __WXDEBUG__ too */
#ifdef _DEBUG
// ----------------------------------------------------------------------------
// 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
#ifndef __WXDEBUG__ #ifndef __WXDEBUG__
#define __WXDEBUG__ #define __WXDEBUG__
#endif #endif /* !__WXDEBUG__ */
#else #endif /* _DEBUG */
#undef __WXDEBUG__
#endif
// Finally there is also a very old WXDEBUG macro not used anywhere at all, it /* if NDEBUG is defined (<assert.h> uses it), undef __WXDEBUG__ and WXDEBUG */
// is only defined for compatibility. #ifdef NDEBUG
#undef __WXDEBUG__
#undef WXDEBUG
#endif /* NDEBUG */
/* if __WXDEBUG__ is defined, make sure that WXDEBUG is defined and >= 1 */
#ifdef __WXDEBUG__ #ifdef __WXDEBUG__
#if !defined(WXDEBUG) || !WXDEBUG #if !defined(WXDEBUG) || !WXDEBUG
#undef WXDEBUG #undef WXDEBUG
#define WXDEBUG 1 #define WXDEBUG 1
#endif // !WXDEBUG #endif /* !WXDEBUG */
#endif // __WXDEBUG__ #endif /* __WXDEBUG__ */
// ----------------------------------------------------------------------------
// Handling assertion failures
// ----------------------------------------------------------------------------
#ifndef __WXFUNCTION__
/* TODO: add more compilers supporting __FUNCTION__ */
#if defined(__DMC__)
/* /*
Type for the function called in case of assert failure, see __FUNCTION__ happens to be not defined within class members
wxSetAssertHandler(). http://www.digitalmars.com/drn-bin/wwwnews?c%2B%2B.beta/485
*/ */
typedef void (*wxAssertHandler_t)(const wxString& file, #define __WXFUNCTION__ (NULL)
int line, #elif defined(__GNUC__) || \
const wxString& func, (defined(_MSC_VER) && _MSC_VER >= 1300) || \
const wxString& cond, defined(__FUNCTION__)
const wxString& msg); #define __WXFUNCTION__ __FUNCTION__
#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 #else
#define wxDISABLE_ASSERTS_IN_RELEASE_BUILD() /* still define __WXFUNCTION__ to avoid #ifdefs elsewhere */
#define __WXFUNCTION__ (NULL)
#endif
#endif /* __WXFUNCTION__ already defined */
/* ---------------------------------------------------------------------------- */
/* 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. */
/* ---------------------------------------------------------------------------- */
/* 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) \
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 #endif
#if wxDEBUG_LEVEL /* special form of assert: always triggers it (in debug mode) */
#define wxFAIL wxFAIL_MSG(NULL)
/* /* FAIL with some message */
wxOnAssert() is used by the debugging macros defined below. Different #define wxFAIL_MSG(msg) wxFAIL_COND_MSG("wxAssertFailure", msg)
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 /* FAIL with some message and a condition */
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()
#else
extern WXDLLIMPEXP_BASE void wxTrap();
#endif // Win VisualC
// 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;
// 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.
#define wxASSERT_MSG(cond, msg) \
wxSTATEMENT_MACRO_BEGIN \
if ( wxTheAssertHandler && !(cond) && \
(wxOnAssert(__FILE__, __LINE__, __WXFUNCTION__, \
#cond, msg), wxTrapInAssert) ) \
{ \
wxTrapInAssert = false; \
wxTrap(); \
} \
wxSTATEMENT_MACRO_END
// 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)
// 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) \ #define wxFAIL_COND_MSG(cond, msg) \
wxSTATEMENT_MACRO_BEGIN \ wxOnAssert(__TFILE__, __LINE__, __WXFUNCTION__, wxT(cond), msg)
if ( wxTheAssertHandler && \
(wxOnAssert(__FILE__, __LINE__, __WXFUNCTION__, \
cond, msg), wxTrapInAssert) ) \
{ \
wxTrapInAssert = false; \
wxTrap(); \
} \
wxSTATEMENT_MACRO_END
#define wxFAIL_MSG(msg) wxFAIL_COND_MSG("Assert failure", msg) /* An assert helper used to avoid warning when testing constant expressions, */
#define wxFAIL wxFAIL_MSG((const char*)NULL) /* i.e. wxASSERT( sizeof(int) == 4 ) can generate a compiler warning about */
#else // !wxDEBUG_LEVEL /* 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() #define wxTrap()
/* nothing to do in release mode (hopefully at this moment there are */
/* no more bugs ;-) */
#define wxASSERT(cond) #define wxASSERT(cond)
#define wxASSERT_MSG(cond, msg) #define wxASSERT_MSG(cond, msg)
#define wxFAIL #define wxFAIL
#define wxFAIL_MSG(msg) #define wxFAIL_MSG(msg)
#define wxFAIL_COND_MSG(cond, msg) #define wxFAIL_COND_MSG(cond, msg)
#endif // wxDEBUG_LEVEL #endif /* __WXDEBUG__ */
#if wxDEBUG_LEVEL >= 2 #ifdef __cplusplus
#define wxASSERT_LEVEL_2_MSG(cond, msg) wxASSERT_MSG(cond, msg) /* Use of wxFalse instead of false suppresses compiler warnings about testing */
#define wxASSERT_LEVEL_2(cond) wxASSERT(cond) /* constant expression */
#else // wxDEBUG_LEVEL < 2 extern WXDLLIMPEXP_DATA_BASE(const bool) wxFalse;
#define wxASSERT_LEVEL_2_MSG(cond, msg)
#define wxASSERT_LEVEL_2(cond)
#endif #endif
// This is simply a wrapper for the standard abort() which is not available #define wxAssertFailure wxFalse
// under all platforms.
// /* NB: the following macros also work in release mode! */
// 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();
/* /*
wxCHECK macros always check their conditions, setting debug level to 0 only These macros must be used only in invalid situation: for example, an
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 invalid parameter (e.g. a NULL pointer) is passed to a function. Instead of
dereferencing it and causing core dump the function might use dereferencing it and causing core dump the function might try using
CHECK( p != NULL ) or CHECK( p != NULL, return LogError("p is NULL!!") )
wxCHECK_RET( p != NULL, "pointer can't be NULL" )
*/ */
// the generic macro: takes the condition to check, the statement to be executed /* check that expression is true, "return" if not (also FAILs in debug mode) */
// in case the condition is false and the message to pass to the assert handler #define wxCHECK(cond, rc) wxCHECK_MSG(cond, rc, NULL)
/* 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, perform op if not */
#define wxCHECK2(cond, op) wxCHECK2_MSG(cond, op, NULL)
/* as wxCHECK2 but with a message explaining why we fail */
#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) \ #define wxCHECK2_MSG(cond, op, msg) \
if ( cond ) \ if ( cond ) \
{} \ {} \
@ -354,35 +212,36 @@ extern void WXDLLIMPEXP_BASE wxAbort();
op; \ op; \
} \ } \
struct wxDummyCheckStruct /* just to force a semicolon */ 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
// check which returns with the specified return code if the condition fails /* special form of wxCHECK2: as wxCHECK, but for use in void functions */
#define wxCHECK_MSG(cond, rc, msg) wxCHECK2_MSG(cond, return rc, msg) /* */
/* NB: there is only one form (with msg parameter) and it's intentional: */
// check that expression is true, "return" if not (also FAILs in debug mode) /* there is no other way to tell the caller what exactly went wrong */
#define wxCHECK(cond, rc) wxCHECK_MSG(cond, rc, (const char*)NULL) /* from the void function (of course, the function shouldn't be void */
/* to begin with...) */
// check that expression is true, perform op if not
#define wxCHECK2(cond, op) wxCHECK2_MSG(cond, op, (const char*)NULL)
// 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) #define wxCHECK_RET(cond, msg) wxCHECK2_MSG(cond, return, msg)
/* ---------------------------------------------------------------------------- */
// ---------------------------------------------------------------------------- /* Compile time asserts */
// Compile time asserts /* */
// /* Unlike the normal assert and related macros above which are checked during */
// 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 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 */
// the condition they check is false. This is usually used to check the /* expressions containing sizeof()s which cannot be tested with 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 */
// preprocessor. If you can use the #if's, do use them as you can give a more /* detailed error message then. */
// detailed error message then. /* ---------------------------------------------------------------------------- */
// ----------------------------------------------------------------------------
/* /*
How this works (you don't have to understand it to be able to use the 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. 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 */ /* avoid "unused symbol" warning */
#define wxCOMPILE_TIME_ASSERT(expr, msg) \ #define wxCOMPILE_TIME_ASSERT(expr, msg) \
class wxMAKE_UNIQUE_ASSERT_NAME { \ class wxMAKE_UNIQUE_ASSERT_NAME { \
unsigned int msg: expr; \ unsigned int msg: expr; \
wxMAKE_UNIQUE_ASSERT_NAME() { wxUnusedVar(msg); } \ wxMAKE_UNIQUE_ASSERT_NAME() { wxUnusedVar(msg); } \
} }
#elif defined( __VMS )
namespace wxdebug{
// HP aCC cannot deal with missing names for template value parameters
template <bool x> struct STATIC_ASSERTION_FAILURE;
template <> struct STATIC_ASSERTION_FAILURE<true> { enum { value = 1 }; };
// HP aCC cannot deal with missing names for template value parameters
template<int x> 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 #else
#define wxCOMPILE_TIME_ASSERT(expr, msg) \ #define wxCOMPILE_TIME_ASSERT(expr, msg) \
struct wxMAKE_UNIQUE_ASSERT_NAME { unsigned int msg: expr; } struct wxMAKE_UNIQUE_ASSERT_NAME { unsigned int msg: expr; }
@ -444,53 +285,32 @@ template<int x> struct static_assert_test{};
#define wxCOMPILE_TIME_ASSERT2(expr, msg, text) \ #define wxCOMPILE_TIME_ASSERT2(expr, msg, text) \
struct wxMAKE_UNIQUE_ASSERT_NAME2(text) { unsigned int msg: expr; } 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 #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 /* a special case of compile time assert: check that the size of the given type */
// is at least the given number of bits /* is at least the given number of bits */
#define wxASSERT_MIN_BITSIZE(type, size) \ #define wxASSERT_MIN_BITSIZE(type, size) \
wxCOMPILE_TIME_ASSERT(sizeof(type) * CHAR_BIT >= size, \ wxCOMPILE_TIME_ASSERT(sizeof(type) * CHAR_BIT >= size, \
wxMAKE_BITSIZE_MSG(type, size)) wxMAKE_BITSIZE_MSG(type, size))
/* ---------------------------------------------------------------------------- */
// ---------------------------------------------------------------------------- /* other miscellaneous debugger-related functions */
// other miscellaneous debugger-related functions /* ---------------------------------------------------------------------------- */
// ----------------------------------------------------------------------------
/* /*
Return true if we're running under debugger. 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__) #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(); extern bool WXDLLIMPEXP_BASE wxIsDebuggerRunning();
#else // !Mac #else /* !Mac */
inline bool wxIsDebuggerRunning() { return false; } inline bool wxIsDebuggerRunning() { return false; }
#endif // Mac/!Mac #endif /* Mac/!Mac */
#endif /* __cplusplus */
// An assert helper used to avoid warning when testing constant expressions, #endif /* _WX_DEBUG_H_ */
// 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_

View File

@ -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 <vadim@wxwindows.org>
// 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_

File diff suppressed because it is too large Load Diff

View File

@ -4,6 +4,7 @@
// Author: Vadim Zeitlin // Author: Vadim Zeitlin
// Modified by: // Modified by:
// Created: 29.06.99 // Created: 29.06.99
// RCS-ID: $Id: dialog.h 49804 2007-11-10 01:09:42Z VZ $
// Copyright: (c) Vadim Zeitlin // Copyright: (c) Vadim Zeitlin
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
@ -11,22 +12,14 @@
#ifndef _WX_DIALOG_H_BASE_ #ifndef _WX_DIALOG_H_BASE_
#define _WX_DIALOG_H_BASE_ #define _WX_DIALOG_H_BASE_
#include "wx/toplevel.h" #include "wx/defs.h"
#include "wx/containr.h" #include "wx/containr.h"
#include "wx/sharedptr.h" #include "wx/toplevel.h"
class WXDLLIMPEXP_FWD_CORE wxSizer; class WXDLLIMPEXP_FWD_CORE wxSizer;
class WXDLLIMPEXP_FWD_CORE wxStdDialogButtonSizer; 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 0x0001 // Don't make owned by apps top window
#define wxDIALOG_NO_PARENT 0x00000020 // Don't make owned by apps top window
#ifdef __WXWINCE__ #ifdef __WXWINCE__
#define wxDEFAULT_DIALOG_STYLE (wxCAPTION | wxMAXIMIZE | wxCLOSE_BOX | wxNO_BORDER) #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) #define wxDEFAULT_DIALOG_STYLE (wxCAPTION | wxSYSTEM_MENU | wxCLOSE_BOX)
#endif #endif
// Layout adaptation levels, for SetLayoutAdaptationLevel extern WXDLLEXPORT_DATA(const wxChar) wxDialogNameStr[];
// Don't do any layout adaptation class WXDLLEXPORT wxDialogBase : public wxTopLevelWindow
#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<wxTopLevelWindow>
{ {
public: public:
wxDialogBase(); enum
{
// all flags allowed in wxDialogBase::CreateButtonSizer()
ButtonSizerFlags = wxOK|wxCANCEL|wxYES|wxNO|wxHELP|wxNO_DEFAULT
};
wxDialogBase() { Init(); }
virtual ~wxDialogBase() { } virtual ~wxDialogBase() { }
// define public wxDialog methods to be implemented by the derived classes // define public wxDialog methods to be implemented by the derived classes
virtual int ShowModal() = 0; virtual int ShowModal() = 0;
virtual void EndModal(int retCode) = 0; virtual void EndModal(int retCode) = 0;
virtual bool IsModal() const = 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<typename Functor>
void ShowWindowModalThenDo(const Functor& onEndModal);
#endif // wxHAS_EVENT_BIND
// Modal dialogs have a return code - usually the id of the last // Modal dialogs have a return code - usually the id of the last
// pressed button // pressed button
@ -102,33 +64,10 @@ public:
void SetEscapeId(int escapeId); void SetEscapeId(int escapeId);
int GetEscapeId() const { return m_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 #if wxUSE_STATTEXT // && wxUSE_TEXTCTRL
// splits text up at newlines and places the lines into a vertical // splits text up at newlines and places the
// wxBoxSizer // lines into a vertical wxBoxSizer
wxSizer *CreateTextSizer( const wxString &message ); 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 );
#endif // wxUSE_STATTEXT // && wxUSE_TEXTCTRL #endif // wxUSE_STATTEXT // && wxUSE_TEXTCTRL
// returns a horizontal wxBoxSizer containing the given buttons // returns a horizontal wxBoxSizer containing the given buttons
@ -138,64 +77,15 @@ public:
// platforms which have hardware buttons replacing OK/Cancel and such) // platforms which have hardware buttons replacing OK/Cancel and such)
wxSizer *CreateButtonSizer(long flags); 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 // returns the sizer containing CreateButtonSizer() below a separating
// static line for the platforms which use static lines for items // static line for the platforms which use static lines for items
// separation (i.e. not Mac) // separation (i.e. not Mac)
//
// this is just a combination of CreateButtonSizer() and
// CreateSeparatedSizer()
wxSizer *CreateSeparatedButtonSizer(long flags); wxSizer *CreateSeparatedButtonSizer(long flags);
#if wxUSE_BUTTON #if wxUSE_BUTTON
wxStdDialogButtonSizer *CreateStdDialogButtonSizer( long flags ); wxStdDialogButtonSizer *CreateStdDialogButtonSizer( long flags );
#endif // wxUSE_BUTTON #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: protected:
// emulate click of a button with the given id if it's present in the dialog // 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 // wxID_OK return code
void AcceptAndClose(); void AcceptAndClose();
// The return code from modal dialog // The return code from modal dialog
int m_returnCode; int m_returnCode;
@ -227,36 +118,9 @@ protected:
// The identifier for cancel button (usually wxID_CANCEL) // The identifier for cancel button (usually wxID_CANCEL)
int m_escapeId; 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: private:
// helper of GetParentForModalDialog(): returns the passed in window if it // common part of all ctors
// can be used as our parent or NULL if it can't void Init();
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();
// handle Esc key presses // handle Esc key presses
void OnCharHook(wxKeyEvent& event); void OnCharHook(wxKeyEvent& event);
@ -271,88 +135,18 @@ private:
void OnSysColourChanged(wxSysColourChangedEvent& event); void OnSysColourChanged(wxSysColourChangedEvent& event);
wxDECLARE_NO_COPY_CLASS(wxDialogBase); DECLARE_NO_COPY_CLASS(wxDialogBase)
DECLARE_EVENT_TABLE() 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__) #if defined(__WXUNIVERSAL__) && !defined(__WXMICROWIN__)
#include "wx/univ/dialog.h" #include "wx/univ/dialog.h"
#else #else
#if defined(__WXMSW__) #if defined(__WXPALMOS__)
#include "wx/palmos/dialog.h"
#elif defined(__WXMSW__)
#include "wx/msw/dialog.h" #include "wx/msw/dialog.h"
#elif defined(__WXMOTIF__) #elif defined(__WXMOTIF__)
#include "wx/motif/dialog.h" #include "wx/motif/dialog.h"
@ -361,7 +155,7 @@ public:
#elif defined(__WXGTK__) #elif defined(__WXGTK__)
#include "wx/gtk1/dialog.h" #include "wx/gtk1/dialog.h"
#elif defined(__WXMAC__) #elif defined(__WXMAC__)
#include "wx/osx/dialog.h" #include "wx/mac/dialog.h"
#elif defined(__WXCOCOA__) #elif defined(__WXCOCOA__)
#include "wx/cocoa/dialog.h" #include "wx/cocoa/dialog.h"
#elif defined(__WXPM__) #elif defined(__WXPM__)
@ -369,73 +163,5 @@ public:
#endif #endif
#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<typename Functor>
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> functor(m_f);
m_f.reset();
(*functor)(event.GetReturnCode());
}
else // was already called once
{
event.Skip();
}
}
private:
wxSharedPtr<Functor> m_f;
};
template<typename Functor>
void wxDialogBase::ShowWindowModalThenDo(const Functor& onEndModal)
{
Bind(wxEVT_WINDOW_MODAL_DIALOG_CLOSED,
wxWindowModalDialogEventFunctor<Functor>(onEndModal));
ShowWindowModal();
}
#endif // wxHAS_EVENT_BIND
#endif #endif
// _WX_DIALOG_H_BASE_ // _WX_DIALOG_H_BASE_

View File

@ -4,6 +4,7 @@
// Author: Vadim Zeitlin // Author: Vadim Zeitlin
// Modified by: // Modified by:
// Created: 07.07.99 // Created: 07.07.99
// RCS-ID: $Id: dialup.h 49804 2007-11-10 01:09:42Z VZ $
// Copyright: (c) Vadim Zeitlin // Copyright: (c) Vadim Zeitlin
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
@ -42,7 +43,7 @@ class WXDLLIMPEXP_FWD_BASE wxArrayString;
* main thread? * main thread?
*/ */
class WXDLLIMPEXP_CORE wxDialUpManager class WXDLLEXPORT wxDialUpManager
{ {
public: public:
// this function should create and return the object of the // this function should create and return the object of the
@ -151,13 +152,13 @@ public:
// wxDialUpManager events // wxDialUpManager events
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
class WXDLLIMPEXP_FWD_CORE wxDialUpEvent; BEGIN_DECLARE_EVENT_TYPES()
DECLARE_EVENT_TYPE(wxEVT_DIALUP_CONNECTED, 450)
wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_DIALUP_CONNECTED, wxDialUpEvent ); DECLARE_EVENT_TYPE(wxEVT_DIALUP_DISCONNECTED, 451)
wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_DIALUP_DISCONNECTED, wxDialUpEvent ); END_DECLARE_EVENT_TYPES()
// the event class for the dialup events // the event class for the dialup events
class WXDLLIMPEXP_CORE wxDialUpEvent : public wxEvent class WXDLLEXPORT wxDialUpEvent : public wxEvent
{ {
public: public:
wxDialUpEvent(bool isConnected, bool isOwnEvent) : wxEvent(isOwnEvent) wxDialUpEvent(bool isConnected, bool isOwnEvent) : wxEvent(isOwnEvent)
@ -170,7 +171,7 @@ public:
bool IsConnectedEvent() const bool IsConnectedEvent() const
{ return GetEventType() == wxEVT_DIALUP_CONNECTED; } { 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 // process (i.e. does it result from our own attempt to establish the
// connection)? // connection)?
bool IsOwnEvent() const { return m_id != 0; } bool IsOwnEvent() const { return m_id != 0; }
@ -179,14 +180,14 @@ public:
virtual wxEvent *Clone() const { return new wxDialUpEvent(*this); } virtual wxEvent *Clone() const { return new wxDialUpEvent(*this); }
private: private:
wxDECLARE_NO_ASSIGN_CLASS(wxDialUpEvent); DECLARE_NO_ASSIGN_CLASS(wxDialUpEvent)
}; };
// the type of dialup event handler function // the type of dialup event handler function
typedef void (wxEvtHandler::*wxDialUpEventFunction)(wxDialUpEvent&); typedef void (wxEvtHandler::*wxDialUpEventFunction)(wxDialUpEvent&);
#define wxDialUpEventHandler(func) \ #define wxDialUpEventHandler(func) \
wxEVENT_HANDLER_CAST(wxDialUpEventFunction, func) (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxDialUpEventFunction, &func)
// macros to catch dialup events // macros to catch dialup events
#define EVT_DIALUP_CONNECTED(func) \ #define EVT_DIALUP_CONNECTED(func) \

View File

@ -4,6 +4,7 @@
// Author: Vadim Zeitlin // Author: Vadim Zeitlin
// Modified by: // Modified by:
// Created: 08.12.99 // Created: 08.12.99
// RCS-ID: $Id: dir.h 53135 2008-04-12 02:31:04Z VZ $
// Copyright: (c) 1999 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr> // Copyright: (c) 1999 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
@ -13,7 +14,6 @@
#include "wx/longlong.h" #include "wx/longlong.h"
#include "wx/string.h" #include "wx/string.h"
#include "wx/filefn.h" // for wxS_DIR_DEFAULT
class WXDLLIMPEXP_FWD_BASE wxArrayString; class WXDLLIMPEXP_FWD_BASE wxArrayString;
@ -21,17 +21,14 @@ class WXDLLIMPEXP_FWD_BASE wxArrayString;
// constants // constants
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// These flags affect the behaviour of GetFirst/GetNext() and Traverse(). // these flags define what kind of filenames is included in the list of files
// They define what types are included in the list of items they produce. // enumerated by GetFirst/GetNext
// Note that wxDIR_NO_FOLLOW is relevant only on Unix and ignored under systems enum
// not supporting symbolic links.
enum wxDirFlags
{ {
wxDIR_FILES = 0x0001, // include files wxDIR_FILES = 0x0001, // include files
wxDIR_DIRS = 0x0002, // include directories wxDIR_DIRS = 0x0002, // include directories
wxDIR_HIDDEN = 0x0004, // include hidden files wxDIR_HIDDEN = 0x0004, // include hidden files
wxDIR_DOTDOT = 0x0008, // include '.' and '..' wxDIR_DOTDOT = 0x0008, // include '.' and '..'
wxDIR_NO_FOLLOW = 0x0010, // don't dereference any symlink
// by default, enumerate everything except '.' and '..' // by default, enumerate everything except '.' and '..'
wxDIR_DEFAULT = wxDIR_FILES | wxDIR_DIRS | wxDIR_HIDDEN wxDIR_DEFAULT = wxDIR_FILES | wxDIR_DIRS | wxDIR_HIDDEN
@ -66,7 +63,7 @@ public:
virtual wxDirTraverseResult OnDir(const wxString& dirname) = 0; virtual wxDirTraverseResult OnDir(const wxString& dirname) = 0;
// called for each directory which we couldn't open during our traversal // 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 // this method can also return either wxDIR_STOP, wxDIR_IGNORE or
// wxDIR_CONTINUE but the latter is treated specially: it means to retry // 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 class WXDLLIMPEXP_BASE wxDir
{ {
public: public:
// test for existence of a directory with the given name
static bool Exists(const wxString& dir);
// ctors // ctors
// ----- // -----
@ -96,26 +95,18 @@ public:
// opens the directory for enumeration, use IsOpened() to test success // opens the directory for enumeration, use IsOpened() to test success
wxDir(const wxString& dir); wxDir(const wxString& dir);
// dtor calls Close() automatically // dtor cleans up the associated ressources
~wxDir() { Close(); } ~wxDir();
// open the directory for enumerating // open the directory for enumerating
bool Open(const wxString& dir); bool Open(const wxString& dir);
// close the directory, Open() can be called again later
void Close();
// returns true if the directory was successfully opened // returns true if the directory was successfully opened
bool IsOpened() const; bool IsOpened() const;
// get the full name of the directory (without '/' at the end) // get the full name of the directory (without '/' at the end)
wxString GetName() const; 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 // file enumeration routines
// ------------------------- // -------------------------
@ -129,10 +120,10 @@ public:
bool GetNext(wxString *filename) const; bool GetNext(wxString *filename) const;
// return true if this directory has any files in it // 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 // 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 // enumerate all files in this directory and its subdirectories
// //
@ -155,31 +146,15 @@ public:
const wxString& filespec, const wxString& filespec,
int flags = wxDIR_DEFAULT); int flags = wxDIR_DEFAULT);
#if wxUSE_LONGLONG
// returns the size of all directories recursively found in given path // returns the size of all directories recursively found in given path
static wxULongLong GetTotalSize(const wxString &dir, wxArrayString *filesSkipped = NULL); 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: private:
friend class wxDirData; friend class wxDirData;
wxDirData *m_data; wxDirData *m_data;
wxDECLARE_NO_COPY_CLASS(wxDir); DECLARE_NO_COPY_CLASS(wxDir)
}; };
#endif // _WX_DIR_H_ #endif // _WX_DIR_H_

View File

@ -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_

View File

@ -5,6 +5,7 @@
// Modified by: // Modified by:
// Created: // Created:
// Copyright: (c) Robert Roebling // Copyright: (c) Robert Roebling
// RCS-ID: $Id: dirdlg.h 44027 2006-12-21 19:26:48Z VZ $
// Licence: wxWindows Licence // Licence: wxWindows Licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
@ -19,9 +20,9 @@
// constants // constants
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
extern WXDLLIMPEXP_DATA_CORE(const char) wxDirDialogNameStr[]; extern WXDLLEXPORT_DATA(const wxChar) wxDirDialogNameStr[];
extern WXDLLIMPEXP_DATA_CORE(const char) wxDirDialogDefaultFolderStr[]; extern WXDLLEXPORT_DATA(const wxChar) wxDirDialogDefaultFolderStr[];
extern WXDLLIMPEXP_DATA_CORE(const char) wxDirSelectorPromptStr[]; extern WXDLLEXPORT_DATA(const wxChar) wxDirSelectorPromptStr[];
#define wxDD_CHANGE_DIR 0x0100 #define wxDD_CHANGE_DIR 0x0100
#define wxDD_DIR_MUST_EXIST 0x0200 #define wxDD_DIR_MUST_EXIST 0x0200
@ -39,7 +40,7 @@ extern WXDLLIMPEXP_DATA_CORE(const char) wxDirSelectorPromptStr[];
// wxDirDialogBase // wxDirDialogBase
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxDirDialogBase : public wxDialog class WXDLLEXPORT wxDirDialogBase : public wxDialog
{ {
public: public:
wxDirDialogBase() {} wxDirDialogBase() {}
@ -95,7 +96,8 @@ protected:
#if defined(__WXUNIVERSAL__) #if defined(__WXUNIVERSAL__)
#include "wx/generic/dirdlgg.h" #include "wx/generic/dirdlgg.h"
#define wxDirDialog wxGenericDirDialog #define wxDirDialog wxGenericDirDialog
#elif defined(__WXMSW__) && (!wxUSE_OLE || \ #elif defined(__WXMSW__) && (defined(__SALFORDC__) || \
!wxUSE_OLE || \
(defined (__GNUWIN32__) && !wxUSE_NORLANDER_HEADERS)) (defined (__GNUWIN32__) && !wxUSE_NORLANDER_HEADERS))
#include "wx/generic/dirdlgg.h" #include "wx/generic/dirdlgg.h"
#define wxDirDialog wxGenericDirDialog #define wxDirDialog wxGenericDirDialog
@ -104,17 +106,18 @@ protected:
#define wxDirDialog wxGenericDirDialog #define wxDirDialog wxGenericDirDialog
#elif defined(__WXMSW__) #elif defined(__WXMSW__)
#include "wx/msw/dirdlg.h" // Native MSW #include "wx/msw/dirdlg.h" // Native MSW
#elif defined(__WXGTK20__) #elif defined(__WXGTK24__)
#include "wx/gtk/dirdlg.h" // Native GTK for gtk2.4 #include "wx/gtk/dirdlg.h" // Native GTK for gtk2.4
#elif defined(__WXGTK__) #elif defined(__WXGTK__)
#include "wx/generic/dirdlgg.h" #include "wx/generic/dirdlgg.h"
#define wxDirDialog wxGenericDirDialog #define wxDirDialog wxGenericDirDialog
#elif defined(__WXMAC__) #elif defined(__WXMAC__)
#include "wx/osx/dirdlg.h" // Native Mac #include "wx/mac/dirdlg.h" // Native Mac
#elif defined(__WXCOCOA__) #elif defined(__WXCOCOA__)
#include "wx/cocoa/dirdlg.h" // Native Cocoa #include "wx/cocoa/dirdlg.h" // Native Cocoa
#elif defined(__WXMOTIF__) || \ #elif defined(__WXMOTIF__) || \
defined(__WXX11__) || \ defined(__WXX11__) || \
defined(__WXMGL__) || \
defined(__WXCOCOA__) || \ defined(__WXCOCOA__) || \
defined(__WXPM__) defined(__WXPM__)
#include "wx/generic/dirdlgg.h" // Other ports use generic implementation #include "wx/generic/dirdlgg.h" // Other ports use generic implementation
@ -125,7 +128,7 @@ protected:
// common ::wxDirSelector() function // common ::wxDirSelector() function
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
WXDLLIMPEXP_CORE wxString WXDLLEXPORT wxString
wxDirSelector(const wxString& message = wxDirSelectorPromptStr, wxDirSelector(const wxString& message = wxDirSelectorPromptStr,
const wxString& defaultPath = wxEmptyString, const wxString& defaultPath = wxEmptyString,
long style = wxDD_DEFAULT_STYLE, long style = wxDD_DEFAULT_STYLE,

View File

@ -3,6 +3,7 @@
// Purpose: wxDisplay class // Purpose: wxDisplay class
// Author: Royce Mitchell III, Vadim Zeitlin // Author: Royce Mitchell III, Vadim Zeitlin
// Created: 06/21/02 // Created: 06/21/02
// RCS-ID: $Id: display.h 49804 2007-11-10 01:09:42Z VZ $
// Copyright: (c) 2002-2006 wxWidgets team // Copyright: (c) 2002-2006 wxWidgets team
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
@ -21,7 +22,7 @@
WX_DECLARE_EXPORTED_OBJARRAY(wxVideoMode, wxArrayVideoModes); WX_DECLARE_EXPORTED_OBJARRAY(wxVideoMode, wxArrayVideoModes);
// default, uninitialized, video mode object // default, uninitialized, video mode object
extern WXDLLIMPEXP_DATA_CORE(const wxVideoMode) wxDefaultVideoMode; extern WXDLLEXPORT_DATA(const wxVideoMode) wxDefaultVideoMode;
#endif // wxUSE_DISPLAY #endif // wxUSE_DISPLAY
class WXDLLIMPEXP_FWD_CORE wxWindow; class WXDLLIMPEXP_FWD_CORE wxWindow;
@ -36,7 +37,7 @@ class WXDLLIMPEXP_FWD_CORE wxDisplayImpl;
// wxDisplay: represents a display/monitor attached to the system // wxDisplay: represents a display/monitor attached to the system
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxDisplay class WXDLLEXPORT wxDisplay
{ {
public: public:
// initialize the object containing all information about the given // 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 // find the display where the given window lies, return wxNOT_FOUND if it
// is not shown at all // is not shown at all
static int GetFromWindow(const wxWindow *window); static int GetFromWindow(wxWindow *window);
// return true if the object was initialized successfully // return true if the object was initialized successfully
@ -121,7 +122,7 @@ private:
wxDisplayImpl *m_impl; wxDisplayImpl *m_impl;
wxDECLARE_NO_COPY_CLASS(wxDisplay); DECLARE_NO_COPY_CLASS(wxDisplay)
}; };
#endif // _WX_DISPLAY_H_BASE_ #endif // _WX_DISPLAY_H_BASE_

Some files were not shown because too many files have changed in this diff Show More