Compare commits
1 Commits
wxPython-2
...
BEFORE_FON
Author | SHA1 | Date | |
---|---|---|---|
|
6964b31048 |
2
user/wxLayout/.cvsignore
Normal file
@@ -0,0 +1,2 @@
|
||||
Linux
|
||||
linux-gnu
|
1
user/wxLayout/Makefile
Normal file
@@ -0,0 +1 @@
|
||||
include ../../setup/general/makeapp
|
26
user/wxLayout/Makefile.in
Normal file
@@ -0,0 +1,26 @@
|
||||
# WXXT base directory
|
||||
WXBASEDIR=@WXBASEDIR@
|
||||
|
||||
# set the OS type for compilation
|
||||
OS=@OS@
|
||||
# compile a library only
|
||||
RULE=bin
|
||||
|
||||
# define library name
|
||||
BIN_TARGET=wxLayout
|
||||
# define library sources
|
||||
BIN_SRC=\
|
||||
wxLayout.cpp kbList.cpp wxlist.cpp wxlwindow.cpp wxlparser.cpp
|
||||
|
||||
#define library objects
|
||||
BIN_OBJ=\
|
||||
wxLayout.o kbList.o wxllist.o wxlwindow.o wxlparser.o
|
||||
|
||||
# additional things needed to link
|
||||
BIN_LINK=
|
||||
|
||||
# additional things needed to compile
|
||||
ADD_COMPILE=
|
||||
|
||||
# include the definitions now
|
||||
include ../../../template.mak
|
309
user/wxLayout/Micon.xpm
Normal file
@@ -0,0 +1,309 @@
|
||||
/* XPM */
|
||||
static char *Micon_xpm[] = {
|
||||
/* width height num_colors chars_per_pixel */
|
||||
" 64 48 254 2",
|
||||
/* colors */
|
||||
".. c #040207",
|
||||
".# c #6482b4",
|
||||
".a c #2a4471",
|
||||
".b c #9cc2d4",
|
||||
".c c #4c627f",
|
||||
".d c #94918e",
|
||||
".e c #0c243e",
|
||||
".f c #4c4a4a",
|
||||
".g c #3c63a8",
|
||||
".h c #7ca2ac",
|
||||
".i c #24447e",
|
||||
".j c #2c2c2c",
|
||||
".k c #5482cc",
|
||||
".l c #d4d0d0",
|
||||
".m c #99aab7",
|
||||
".n c #5c74b1",
|
||||
".o c #2c5287",
|
||||
".p c #1a2a4d",
|
||||
".q c #acdefc",
|
||||
".r c #646362",
|
||||
".s c #7491d0",
|
||||
".t c #bcc4bf",
|
||||
".u c #5273aa",
|
||||
".v c #b4b1aa",
|
||||
".w c #3d5583",
|
||||
".x c #828482",
|
||||
".y c #8c9490",
|
||||
".z c #6f7369",
|
||||
".A c #1c365c",
|
||||
".B c #041220",
|
||||
".C c #2c325c",
|
||||
".D c #94b6e4",
|
||||
".E c #3e4242",
|
||||
".F c #648edc",
|
||||
".G c #d4f2fc",
|
||||
".H c #cbd3d1",
|
||||
".I c #3c54a1",
|
||||
".J c #243244",
|
||||
".K c #4c69aa",
|
||||
".L c #7c8ba2",
|
||||
".M c #4c5d84",
|
||||
".N c #34497f",
|
||||
".O c #1c2228",
|
||||
".P c #6484c5",
|
||||
".Q c #6a7788",
|
||||
".R c #9ba09b",
|
||||
".S c #2c3634",
|
||||
".T c #acb6b4",
|
||||
".U c #141517",
|
||||
".V c #a0c4e8",
|
||||
".W c #515753",
|
||||
".X c #5c76cc",
|
||||
".Y c #1b2f51",
|
||||
".Z c #4472c4",
|
||||
".0 c #7c8a88",
|
||||
".1 c #5a6262",
|
||||
".2 c #a4aba6",
|
||||
".3 c #bcc8d5",
|
||||
".4 c #7494df",
|
||||
".5 c #84b2d4",
|
||||
".6 c #6784d9",
|
||||
".7 c #acd3e4",
|
||||
".8 c #304b72",
|
||||
".9 c #2c4c81",
|
||||
"#. c #3c5b93",
|
||||
"## c #5468bc",
|
||||
"#a c #b5bbb0",
|
||||
"#b c #1c3765",
|
||||
"#c c #444e44",
|
||||
"#d c #ecece8",
|
||||
"#e c #7ca3dc",
|
||||
"#f c #d4deda",
|
||||
"#g c #345495",
|
||||
"#h c #1c2641",
|
||||
"#i c #94a6cc",
|
||||
"#j c #243252",
|
||||
"#k c #a7acb5",
|
||||
"#l c #5c7ab3",
|
||||
"#m c #0a152d",
|
||||
"#n c #c4def0",
|
||||
"#o c #686e84",
|
||||
"#p c #a4a19e",
|
||||
"#q c #3e3c3a",
|
||||
"#r c #84aaee",
|
||||
"#s c #040a09",
|
||||
"#t c #3c6294",
|
||||
"#u c #7c929c",
|
||||
"#v c #3c5c9d",
|
||||
"#w c #4e6ead",
|
||||
"#x c #344458",
|
||||
"#y c #446bae",
|
||||
"#z c #696b6a",
|
||||
"#A c #547cbc",
|
||||
"#B c #789ae3",
|
||||
"#C c #112a44",
|
||||
"#D c #4f504b",
|
||||
"#E c #2c3140",
|
||||
"#F c #8c8688",
|
||||
"#G c #5e5c5c",
|
||||
"#H c #8c8c80",
|
||||
"#I c #cccccc",
|
||||
"#J c #4c6398",
|
||||
"#K c #c7cbc4",
|
||||
"#L c #5174b8",
|
||||
"#M c #3d558e",
|
||||
"#N c #2c3c5f",
|
||||
"#O c #acbad4",
|
||||
"#P c #3f495a",
|
||||
"#Q c #354e82",
|
||||
"#R c #6a8ac7",
|
||||
"#S c #767c84",
|
||||
"#T c #30374b",
|
||||
"#U c #b1c9e7",
|
||||
"#V c #1b315d",
|
||||
"#W c #537bcb",
|
||||
"#X c #c4bec0",
|
||||
"#Y c #243e6a",
|
||||
"#Z c #969892",
|
||||
"#0 c #7e858e",
|
||||
"#1 c #94b3f1",
|
||||
"#2 c #c2d4e8",
|
||||
"#3 c #141e35",
|
||||
"#4 c #acb2ac",
|
||||
"#5 c #c4ced0",
|
||||
"#6 c #2b4d8e",
|
||||
"#7 c #445ca2",
|
||||
"#8 c #2c3e6f",
|
||||
"#9 c #14243e",
|
||||
"a. c #f1fdfa",
|
||||
"a# c #8c9abc",
|
||||
"aa c #d7f9f9",
|
||||
"ab c #5a697e",
|
||||
"ac c #c7ebf7",
|
||||
"ad c #bceefc",
|
||||
"ae c #b4c2b4",
|
||||
"af c #889cf0",
|
||||
"ag c #d8d6c8",
|
||||
"ah c #748598",
|
||||
"ai c #b4d2fc",
|
||||
"aj c #4c5eb0",
|
||||
"ak c #3f4f64",
|
||||
"al c #8492bc",
|
||||
"am c #161d1e",
|
||||
"an c #5d7dcf",
|
||||
"ao c #5c86d6",
|
||||
"ap c #9cacc8",
|
||||
"aq c #6c92e6",
|
||||
"ar c #e4ecec",
|
||||
"as c #89b7ef",
|
||||
"at c #a6d0f8",
|
||||
"au c #e4e2e0",
|
||||
"av c #8c98a4",
|
||||
"aw c #ccdaec",
|
||||
"ax c #94bee4",
|
||||
"ay c #232b2b",
|
||||
"az c #1c2b43",
|
||||
"aA c #0c1c33",
|
||||
"aB c #99bcf7",
|
||||
"aC c #6c72bc",
|
||||
"aD c #7c766c",
|
||||
"aE c #a4a2b4",
|
||||
"aF c #6c7eac",
|
||||
"aG c #e4d6dc",
|
||||
"aH c #e4fefc",
|
||||
"aI c #84aeb4",
|
||||
"aJ c #b4b6bf",
|
||||
"aK c #345b9b",
|
||||
"aL c #bce2ef",
|
||||
"aM c #ccc6bc",
|
||||
"aN c #82a3ef",
|
||||
"aO c #7c7b77",
|
||||
"aP c #040c1e",
|
||||
"aQ c #6c7e94",
|
||||
"aR c #9ca69c",
|
||||
"aS c #acbebc",
|
||||
"aT c #a2cafa",
|
||||
"aU c #545e5f",
|
||||
"aV c #5c6a74",
|
||||
"aW c #cae6ee",
|
||||
"aX c #5c6e7c",
|
||||
"aY c #5474c6",
|
||||
"aZ c #fcfaf4",
|
||||
"a0 c #344672",
|
||||
"a1 c #446ec4",
|
||||
"a2 c #b4c4d4",
|
||||
"a3 c #313231",
|
||||
"a4 c #9cb2b4",
|
||||
"a5 c #345a8c",
|
||||
"a6 c #7496d4",
|
||||
"a7 c #0c1a24",
|
||||
"a8 c #444a47",
|
||||
"a9 c #343e3c",
|
||||
"b. c #dce6e4",
|
||||
"b# c #a9b2bc",
|
||||
"ba c #a6a6a3",
|
||||
"bb c #446a9c",
|
||||
"bc c #c4f2f8",
|
||||
"bd c #445667",
|
||||
"be c #727475",
|
||||
"bf c #6a7896",
|
||||
"bg c #9aa0a7",
|
||||
"bh c #9ec4fa",
|
||||
"bi c #545a61",
|
||||
"bj c #6474e0",
|
||||
"bk c #546674",
|
||||
"bl c #b8bcbd",
|
||||
"bm c #5d7cbf",
|
||||
"bn c #515255",
|
||||
"bo c #979a9f",
|
||||
"bp c #849cd0",
|
||||
"bq c #546a8f",
|
||||
"br c #d7d8d5",
|
||||
"bs c #688ada",
|
||||
"bt c #4f6ebe",
|
||||
"bu c #343e4c",
|
||||
"bv c #dafefc",
|
||||
"bw c #acd6fc",
|
||||
"bx c #b4b6b0",
|
||||
"by c #8c9a94",
|
||||
"bz c #203a44",
|
||||
"bA c #a4b6c8",
|
||||
"bB c #4c6a98",
|
||||
"bC c #040214",
|
||||
"bD c #5c74be",
|
||||
"bE c #4c5c98",
|
||||
"bF c #24325c",
|
||||
"bG c #8c8c8f",
|
||||
"bH c #4464a7",
|
||||
"bI c #2c457e",
|
||||
"bJ c #5c83c7",
|
||||
"bK c #34538a",
|
||||
"bL c #b4dff1",
|
||||
"bM c #7c92d4",
|
||||
"bN c #c4c4c0",
|
||||
"bO c #243759",
|
||||
"bP c #0c151e",
|
||||
"bQ c #9cb2d4",
|
||||
"bR c #6c8fd3",
|
||||
"bS c #546aab",
|
||||
"bT c #848c9f",
|
||||
"bU c #242420",
|
||||
"bV c #6c83c0",
|
||||
"bW c #343935",
|
||||
"bX c #848b89",
|
||||
"bY c #acaca6",
|
||||
"bZ c #c4cad0",
|
||||
"b0 c #445c90",
|
||||
"b1 c #243865",
|
||||
"b2 c #dce0dc",
|
||||
"b3 c #747b76",
|
||||
"b4 c #8cacee",
|
||||
"b5 c #0c0c08",
|
||||
"b6 c #446299",
|
||||
"b7 c #8493a4",
|
||||
/* pixels */
|
||||
"................................................................................................................................",
|
||||
"..................................bC....bC....bC..bC....bC..bCbCbCbC..bCbC..bC..bC..bC..bCbC..bC..bC....bC....bC................",
|
||||
"..#9#C#h#C.p.Y.Y.Y#j.Y.Y.Y#V#V#Vb1bFb1b1#8#Y.a.a#Q#Q.a.N#Q.abI.i.9bI#Q#MbK#M.wb0#M.9.N.N.N.9.abI.a#Y#Yb1b1#b#bb1b1b1#V#V#V#Vaz..",
|
||||
"..#h#C.p.p#9.Y.Y#j.AbObO.A.AbO.Ab1#Y#Y#8.a.aa0.N.8.w.w#QbK.w.ibI.9#6#Q#.#Mb0b0#J#MbK#M.NbK.N.9.NbI.N#YbIb1#Y#8#8bOb1bO#j#V#Caz..",
|
||||
"..#9.e#h#C.p.p.Y.YbO.A#b#N.a#8#Y#bb1#8#Y.Na0.9.8#Q.w.Mb0#Q#MbK.9bK#g#6.Kb6#J#J#wb0#M#MbKbK#Q#M.9bI.N.N.a.N.a.a.ab1b1#V.Y#V.Y.Y..",
|
||||
"..#9#C.p#h.p.p.p.Y#VbO#b.a.ia0.9#Q.N#YbI.a.N.N.N.w#Q.wb6b6b0b6#.#g#v#M.K#w#L.n.n#vbH#.bH.Ib6aK#MbK.9#Q#Q#Q#Q.a#Yb1.AbF#VbO.Y#j..",
|
||||
"..#h#h.p.p.p.Y.p#bbF#bb1#Y.a.8.N#Q#M#M#Q.N.9#QbK#M#Mb0b0.ubB.K.K#..K#v#w.nbmbV.nbHbS#w#7#w#vb0#.#M#Mb0#M#Q.9#Y#Yb1#Yb1b1.Y.Y.Y..",
|
||||
"..#h#9.p.p.p#V#V#b#b#Y#Y.a.ibI.N.w#Mb0b6#7#M#Q#QbK#.b6b6bq#l.n#LbHbH#y#L#R.s.4#AaY#w#w#L.K.KbH.g.KbH#v#M.9bI.i.8.a#Yb1.A.A.A#j..",
|
||||
"..#h#C.p.p.Y#V#V#bb1.abIbI#6.o.o#g.oaK#tbH.K.KbH#M.Iaj.K#w.n#R.P#Rbt#W#W.4bpb4aoanbsaobm#La1#L#A#L.ga5bK#g#g#Q.8#Y#bb1b1bOb1bO..",
|
||||
"...p.p.Y#V.Y#V.Ab1#YbI.9#Q#Q#M#M#7#7#M#v.M#J.K.K.nbS#MbH.nbm.#b4.s#Baq#Wb4aB#1aqaq#R.P.##l#RbmbD.K#7#J#J#.#Q.9.i.N.a#Y#Yb1.Aaz..",
|
||||
"..az#C#V#j#V.A#N#8.N.N.ibObz#T.J#E.J#T#Tbu.Y.8#..K.nbVbD#wbm.4a6aTb4aoaNaTaiasaNa6.n.m.3bZ#2bN.3aR#2#2.3#J#Q#MbK.8.a#8#b.AbO#j..",
|
||||
"..#h.p.p.Y.Yb1bO.ibI#g#Mbd#hambU.jbW.Sa3aybP.Y.9bHbH.ubm#BbM.P#rbhbc.qasbL.G.VbhaBbpbZaJbobxbl#I#a#abXbP#V.9#6.NbI#8#8#bbF#V#j..",
|
||||
"..az#C.Y.Y.Y#bb1.abI#Q.oaj#Pa3a3aya3a3bW.Eayb0.K.g#y.K#LanbRbhaTaxbLbvbLbvbvaLadaTai.mbobYba#Xbl.H#I#P#m#.#M#QbIbI#Y#Yb1#b#V#j..",
|
||||
"..az.p.p#VbObO#Y.a.N#g#g.I#xbW.j.ja3.E.Ebnbib0bmananbm#wanbs.4asacbLbvaHa.aHbvbc.7aIbY#p#pblbl#Kbe#F#k#9#..I#g#6.i#8#8b1b1.A#j..",
|
||||
"..#h#C.p.YbO#bb1a0bIbKbK#7#xaya3.jaya3#q.Wbn.J.wbD#Lbm.X#Bb4bhat.b#na.a.a.aZaHaHaW#k#a.vagbNaObl#I.vb3#3#w.K#7#v#M#QbIa0#Y#N#N..",
|
||||
"..#haz.p#V.YbO#Y#Y.N.9#g#7#P.EbUa8#q#D.f.f.fbi#hbB#LaY.n.P#R#e.5.7aLa.a.aZaZa.a.aS#5#p.d#p.t.l.HbYaObo.Y#w.Kb6#.#M.Na0.a#8#NbO..",
|
||||
"..#h#C.YbO#V#N#Y.8#Q#g#t##ak.j.W.f.Wbn#Gbe#zbnaU.M#Ra6#eaNb4bh.7bLaWa.aZaZaZa.br.H.2ba.H.T#fau.H.H#p.x#3#w.K#tb0#Q#Q.a#8#Nb1bO..",
|
||||
"..az#j#j.Ab1#N.a.8#Q#.bb##ak.Ebnbn.1.Ua8.zaO#z.xbubqbsbR.saqaN#1bw.7aaaHa.b.a.a4bZ#k#dbgbP.H#IbG#4bY#o#9#w.K#7b0#Q.8.a#8#NbObO..",
|
||||
"..az#j.Y.YbO#8.a.8#Q#7#t##bd.r#D#D.rbPaV#G#z.x.y#z.p.u#W.6#B#r#eaTaTaLaWaaaI#5#aau#XbraU#8.HbN.T.RbY#0#9#w.Kb6#M#Q#Qa0#Y#Y#N#N..",
|
||||
"..#h#j.YbOb1bO#Ya0.NbKa5aj.c.f#G#z.1#3.Mbe#zaO.x#pbT#.bmbsbs.F#1#easat.Gbc.hb.b2aragbgbPaC.3#k.v#4babe#9.KbH#7b0#Qak.a.i#N#Y#T..",
|
||||
"..az.Y#j.Y.Ab1#Y.8.N#gbK.IaX.r.raDaV.Bb0bfbeb3bab3#HazbBaYbsaqbRaf#1.DaB#na2#K#4b3.ybC.Yaf#k#Z.y.d#p#S#3#v#7#M#g.N.N.a#N#Y#NbO..",
|
||||
"..#h.p#C#jbFbO#8.a.NbK#.#7bk.z.zb3#H#9aKbm#J.y#Hbablb#.e.PaqbmbsaNaN#1aB#2bZ.x.2aub3.AbSbjapbobobo.rbn#9#v#gbK.9bI.a.a#Yb1bObO..",
|
||||
"..#haz.YbF#VbO#Y.abI#QaK.I.Q.z.WaO#za7b0an.ub#.R.y.R#XbXbEbtbJbR#Bbsb4.D.3.v#p#za3#s.ubJbj#u.WbWb3.Rbe#9#v#v#g.9bI#Yb1b1#b.A#j..",
|
||||
"..#h#C.p#C.Y#bbO#YbI.9.o.Iab#Zb3.x.da7bK#WbmalbTae.t#F#Gaz.nbsaqbJ.6#R#U#aaMbx#KbPbz#laoanb#ba.2.RbG#G#9#v#v#g.9bI.ab1#bbF#Vaz..",
|
||||
"..#haz.p.p#V#Vb1#Y.a#6bK#7bk.1#z#Z.y#m#.a1a1bq.LbX#HblbN.3#N.PaobJafbQ.3.tblbx.TazbB.X.kaYb7bG.d.x#ZaV#3bH#v#Q.NbI#8b1b1.A.Y.Y..",
|
||||
"..az#h#C.p#VbO#b#YbIbK#g#7aQ.d.y.RbX#mbK#y#ybt.#bZ#IaM.l.2bdbmanaobMap.t.2bY.2.ObO.s.X#W.6bX#F.yaOaD#G#9b6#7.I#Q.a.ab1#bbF.Y.Y..",
|
||||
"..#9#h.p.p#V#Vb1.a.NbK#..IaQ.xbob3aO#m.9#L.ZaY#w#iaJagaGbr#5.8aF.4a#blbN#Z#Z.WaP#l#l.6#WaY#0aO.y.xb3#PaA#7b6bK#QbI#8b1bO.A#V.Y..",
|
||||
"..#h.p#C#V.YbO#Y.abI.9aK.Ibf#D.1bYbY#mbK#ybt#ybHbSbT#aba.tbx#S.M#B.y#kbxbYbYaP.YbR#A.6bmbt.Lb3#z.W#Dbn#3bK#.#M#Q.N#Yb1b1#V.Yaz..",
|
||||
"..#h#C.p#V.p#b.A.a#Y#Q#..Ib7#kbe#4#pa7bK#ybH.g.gbHbfbZbN#4bNbgakah#Zbg#F.x.1#9bK.P#A.X.#btbTaO.W.r.ra8.e#Q.o#Q#Q.a.ab1bO.A.Yaz..",
|
||||
"..#h.p#h#C#VbOb1#YbI.9.o.I.L#H#Z.2.vaA#QbHaK.g.g#y#7#nbr#a.H.vaE.zaU#4blbebCbIaK#Lbm#LbJbtaXaO.z#z#G.EaA#g#Q.9bI.a.a#Nb1#jbO.Y..",
|
||||
"..#h#C#h#V.p#V.A.a#8.9.9.Iah#4bY#4bGbP#QaKaKaKaK#7#wbEbg.z.zay.E#a#K.2#ZbCbO#v#gbH.Xbb.ubDbk#z.r#c.f.E#9#Q#6bI.i#8b1#YbO.AbO.J..",
|
||||
"..#h.p#9.p.p#b.A#8#Y.9.9.I.0.R.2bN#XbP.NaK.IaK#v.IbS.KaQaR.Wbl#K.RbY.R.y#9#M#gaKbH.Kbb#yaCbk.r#Ga8#D#TaAbK#6.i.a#Y#bbObO.Y#jaz..",
|
||||
"..#9#9.p.p.Y#V.Ab1#YbI.9#7a#bn.Hb2#FaP.a.I#g#g#g#v#7bHb0.L.HbY.y.0#ZaObC.8b0#g#6aKbH#wbb#LaX#D#q.Ea3.UaAbK#QbI#Y#Y#bbO.AbO.Y.Y..",
|
||||
"..#9#h#h#C.p.Y#V#Y#Y#6.obEbk.H.2bUbe#m.a#g#g#Q#M#M#vaK#6bq#k.d.x.y#Z..az#M#v.o#6.o#v#L#tbSbda8bU.Ub5.O#3#6#6bI.ib1#bbF.Y#C.Yaz..",
|
||||
"..#9#9.p.p.p#Vb1#Y.N#6.o#Q#O.R.xaM.HaPa0bK#Q#Q#M#M#MbK#gb0akb3aO.xbX#9#x#v#g.N#6.9.wbH#yb0bn#D.f#q.j.U#3.N#6#8.i#b#b.Y.p.Y.paz..",
|
||||
"..#9#h#9.p.p#V#bb1#8bI#g.NbAb.br.t#H#m#Y#Q#g#Q.9.9.N#6.o#gb0avbG#Z...Y.w#g#6bIbIbIbK#v.K#Ma7#s#s....#haA#Q.NbI#Yb1#V#V#V.p.paz..",
|
||||
"..#9#9#9.p.p#VbO#Y#8#6.i#M.Q#z.H#f#K.B#Y#6.9.N.9bIbI.9.9#M#M#JbybP.B.Nb0.NbIbI#Y.ibI#vbH.wbubW.E.Sa3a7#m.o#Q#Y#Yb1#V#V#C.p.p.e..",
|
||||
"..#3#9#9#9.Y#V#VbF#Y#8#6ak#O#db2br.HaP#N.N#QbIbI.a#Y.i.8#M#Qa0.L.B.p#Q#Q.i.i.i#Y.ibI#Q#..c.E.ja3a3bWambP.N.9#Y#Y#b#b#V.p.p.p#9..",
|
||||
"..#3.e#9.p.p.Y.Yb1b1#Y#.#Ubgbl.T#S..aw#obI.a.a#8#Y#Y.a#YbI.Na0.8bO#8a0#Qa0#8b1#Y#Y#8#Q.ibO#Ta9a9bWa3ay#Eb1.a.ab1#V#V.Y.p.p.e#9..",
|
||||
"..#3#9.p#h#C.p.Y#Vb1#b#V.a.Y.Y.Y#CazbO.eb1#8#Y#b#bb1b1#8bI#Y.8.abIb1#Y.Nb1#Y#Y#Y#b#Y.9.8.8.C.JbO#j.Yaz#C.p.Y#bb1#V.p.p.p#C.e#9..",
|
||||
"..#9#9#9.p#9.p.Y.Y#V#b#bb1#8.i#8.a.a#Y#Y#Y#Yb1b1#b#bb1#N#Y#8b1#Y#Yb1#8#Yb1#b#b#b#bb1#Y.N.w.8.N.8#Q.8.i.a#b#Y#bbO#V.Y.p#C.p.p#9..",
|
||||
"..#3#9.e#9.p.p#9#C.Y#V#b#b#b#Y#Y#Y#Y#Y#Yb1b1bO#V.Y#j#Vb1b1bObObObO.Ab1#N.A.AbF#V#V#V#b#8.aa0.a.ibI.8#Y#Yb1#V#V#V#V.p.p#9.p.e#9..",
|
||||
"..#3#3#9.e.e.p.p.p.p#V.Y#b#b#Vb1#b#Yb1.A#V.Y.Y.Y.Y.Y.A#j.YbO#VbO.Y#jbO#b#j#j#V.Y#V#V#bb1#Y.a#Yb1.a#8b1b1#b.A#V#C.p.p.p.p.e.e#9..",
|
||||
"..#3aAaA#3#9.e.e#9#C#C.Y.p.Y#V#VbF#VbO.Y#j.p.p.Y#C#j.Y#j.Y#j.Y#j.Y.YbO.Y#j.Y.p.p.p.p.Y#VbOb1#NbObOb1b1.A#V.p.p.p#C.p#9#9#9.e#9..",
|
||||
"..#3#9.e#3aA#9.e#9.p.p.e.p.p.p#V#j.Y.Y.Y#9.p.p#9.Yaz.Yaz.paz.Y.paz.Y.Y#j#C.p#C.p#C#C.p#V#VbO#VbF#V#j#V#j.p.p.p#C.p#9#C#C#9.e#9..",
|
||||
"..#3aA#9aA#9aA.e#9.e#9#9.p.p.p.p#Caz.Y#C.p.p#9.p#C#Caz.p#Caz.Y#C.p#9#j.p#h.p#C#C#C.e.p#9.Y#j.Y.Y.p.p.p#C.p.p#9#9#9#9#9.e#9.e#3..",
|
||||
"..#3.e#3.e#3.e#9#9aA#9.e.e.e.p#C.p#h#Caz#9.p.p.p#h.Y#9.p.p#C.paz.p#h.Yaz#9.p#C.e.e.e.p.p#9.p.paz#C.paz.Y#9.p.e#9.e#9#9#9#9aA#9..",
|
||||
"......bC..bC..bCbCbCbCbCbCbC..bC....bC..bCbCbCbCbC..bC....bC......bC..bCbCbCbCbCbCbCbCbCbCbC....bC......bCbC..bC..bC..bC........"
|
||||
};
|
8
user/wxLayout/Mpch.h
Normal file
@@ -0,0 +1,8 @@
|
||||
/*
|
||||
This is an empty Mpch.h file to allow me to move the
|
||||
wxl* files between Mahogany and the wxLayout sample
|
||||
without modifying them.
|
||||
*/
|
||||
|
||||
static int _mpch_dummy = 0;
|
||||
|
50
user/wxLayout/README
Normal file
@@ -0,0 +1,50 @@
|
||||
|
||||
README for wxLayout classes
|
||||
---------------------------
|
||||
|
||||
All the source in this directory is copyrighted under the
|
||||
GPL (GNU GENERAL PUBLIC LICENSE), version 2,
|
||||
by Karsten Ballueder <ballueder@usa.net>.
|
||||
|
||||
|
||||
This is still work in progress, so if you want to make any significant
|
||||
changes, please get in touch with me before.
|
||||
|
||||
There are three building blocks for rich text editing:
|
||||
|
||||
wxllist :
|
||||
|
||||
The wxLayoutList layout engine. It is a linked list of wxLayoutObjects
|
||||
which can arrange and display them on any wxDC. I am trying to keep
|
||||
this class as simple as possible, to be just the core layout
|
||||
engine. All "convenience" functions should be defined in classes built
|
||||
on top of this.
|
||||
The wxLayoutList is derived from kbList, a double-linked list with an
|
||||
interface modelled after the STL list. As wxLayoutList depends on the
|
||||
way kbList treats iterators (i.e. the iterator value after an insert()
|
||||
or erase() operation), I don't feel like rewriting it for wxList.
|
||||
|
||||
wxlwindow :
|
||||
|
||||
Contains a class wxLayoutWindow, derived from wxScrolledWindow which
|
||||
can directly be used as a rich-text display or editing window. The
|
||||
function responsible for keyboard handling is virtual and can be
|
||||
overloaded for different keybindings. wxLayoutWindow can sent fake
|
||||
menu-events to the application to react to the user clicking on
|
||||
objects.
|
||||
|
||||
wxlparser:
|
||||
|
||||
Contains several high level functions operating on
|
||||
wxLayoutList. Currently implemented is inserting of text (including
|
||||
linebreaks) and export of objects, text or html.
|
||||
Planned for the future is an html parser for importing html.
|
||||
|
||||
|
||||
wxLayout.cpp is a simple test program. It will export Text and HTML to
|
||||
stdout and demonstrate some of the features and bugs of wxLayoutList.
|
||||
|
||||
There are still things to do and I'm working on them. :-)
|
||||
|
||||
Karsten Ballueder <Ballueder@usa.ne> 29 June 1998
|
||||
|
56
user/wxLayout/TODO
Normal file
@@ -0,0 +1,56 @@
|
||||
|
||||
BUGS
|
||||
=====================================================================
|
||||
|
||||
- dmalloc shows duplicate deletion after merging two lines and
|
||||
deleting the second half
|
||||
|
||||
- word wrap for objects with lots of non-space needs to search in positive
|
||||
direction if begin of first object is reached
|
||||
|
||||
- delete in empty line doesn't always work
|
||||
- fix initial scrollbar sizes
|
||||
- fix horiz scrollbar size
|
||||
- occasionally wraps lines wongly (twice) ??
|
||||
|
||||
|
||||
TODO
|
||||
=====================================================================
|
||||
|
||||
- Image at end of a message doesn't get considered properly in
|
||||
wxLayoutList::GetSize(), so it cannot be seen
|
||||
- searching for text
|
||||
- moving cursor in non-edit mode
|
||||
- cursor screen positioning ignores font sizes once again :-(
|
||||
--> UpdateCursorScreenPos() cannot work as it ignores previous font formatting commands.
|
||||
Either draw cursor when drawing text, or wait for new wxLayoutObjectCmd to be fully
|
||||
implemented.
|
||||
|
||||
RECENTLY FIXED (?)
|
||||
- fix(simplify) cursor size calculation
|
||||
- delete in empty line doesn't work
|
||||
- fix horiz scrollbar size OK here, a Mahogany problem?
|
||||
- with a large number of lines, wraps to top of scrolled window
|
||||
--> check where the problem lies, add a debug function showing all coordinates
|
||||
|
||||
- update rectangle (needs support in wxllist and wxWindows)
|
||||
--> needs a bit of fixing still
|
||||
some code bits are commented out in wxlwindow.cpp
|
||||
offset handling seems a bit dodgy, white shadow to top/left of cursor
|
||||
|
||||
|
||||
- replacement of llist in window
|
||||
- undo
|
||||
- font optimisations(!)
|
||||
- occasionally wraps lines wongly (twice) ??
|
||||
- UNDO
|
||||
later:
|
||||
- DragNDrop ... broken in wxGTK at present
|
||||
- cut&paste ... broken in wxGTK at present, Paste already implemented
|
||||
- Selections
|
||||
|
||||
- More optimisations:
|
||||
- let each line have a pointer to the last layoutcommand and let that
|
||||
one only store the settings that changed, then we no longer need to
|
||||
recalculate all the lines
|
||||
|
336
user/wxLayout/kbList.cpp
Normal file
@@ -0,0 +1,336 @@
|
||||
/*-*- c++ -*-********************************************************
|
||||
* kbList.cc : a double linked list *
|
||||
* *
|
||||
* (C) 1998 by Karsten Ball<6C>der (Ballueder@usa.net) *
|
||||
* *
|
||||
* $Id$ *
|
||||
* *
|
||||
* $Log$
|
||||
* Revision 1.3 1998/11/19 20:34:50 KB
|
||||
* fixes
|
||||
*
|
||||
* Revision 1.8 1998/09/23 08:57:27 KB
|
||||
* changed deletion behaviour
|
||||
*
|
||||
* Revision 1.7 1998/08/16 21:21:29 VZ
|
||||
*
|
||||
* 1) fixed config file bug: it was never created (attempt to create ~/.M/config
|
||||
* always failed, must mkdir("~/.M") first)
|
||||
* 2) "redesign" of "Folder properties" dialog and bug corrected, small change to
|
||||
* MInputBox (it was too wide)
|
||||
* 3) bug in ProvFC when it didn't reckognize the books as being in the correct
|
||||
* format (=> messages "can't reopen book") corrected
|
||||
* 4) I tried to enhance MDialog_About(), but it didn't really work... oh well,
|
||||
* I've never said I was an artist
|
||||
*
|
||||
* Revision 1.6 1998/07/08 11:56:56 KB
|
||||
* M compiles and runs on Solaris 2.5/gcc 2.8/c-client gso
|
||||
*
|
||||
* Revision 1.5 1998/06/27 20:07:18 KB
|
||||
* several bug fixes for kbList
|
||||
* started adding my layout stuff
|
||||
*
|
||||
* Revision 1.1.1.1 1998/06/13 21:51:12 karsten
|
||||
* initial code
|
||||
*
|
||||
* Revision 1.4 1998/05/24 14:48:00 KB
|
||||
* lots of progress on Python, but cannot call functions yet
|
||||
* kbList fixes again?
|
||||
*
|
||||
* Revision 1.3 1998/05/18 17:48:34 KB
|
||||
* more list<>->kbList changes, fixes for wxXt, improved makefiles
|
||||
*
|
||||
* Revision 1.2 1998/05/14 16:39:31 VZ
|
||||
*
|
||||
* fixed SIGSEGV in ~kbList if the list is empty
|
||||
*
|
||||
* Revision 1.1 1998/05/13 19:02:11 KB
|
||||
* added kbList, adapted MimeTypes for it, more python, new icons
|
||||
*
|
||||
*******************************************************************/
|
||||
|
||||
#ifdef __GNUG__
|
||||
# pragma implementation "kbList.h"
|
||||
#endif
|
||||
|
||||
#include "kbList.h"
|
||||
|
||||
|
||||
kbListNode::kbListNode( void *ielement,
|
||||
kbListNode *iprev,
|
||||
kbListNode *inext)
|
||||
{
|
||||
next = inext;
|
||||
prev = iprev;
|
||||
if(prev)
|
||||
prev->next = this;
|
||||
if(next)
|
||||
next->prev = this;
|
||||
element = ielement;
|
||||
}
|
||||
|
||||
kbListNode::~kbListNode()
|
||||
{
|
||||
if(prev)
|
||||
prev->next = next;
|
||||
if(next)
|
||||
next->prev = prev;
|
||||
}
|
||||
|
||||
|
||||
kbList::iterator::iterator(kbListNode *n)
|
||||
{
|
||||
node = n;
|
||||
}
|
||||
|
||||
void *
|
||||
kbList::iterator::operator*()
|
||||
{
|
||||
return node->element;
|
||||
}
|
||||
|
||||
kbList::iterator &
|
||||
kbList::iterator::operator++()
|
||||
{
|
||||
node = node ? node->next : NULL;
|
||||
return *this;
|
||||
}
|
||||
|
||||
kbList::iterator &
|
||||
kbList::iterator::operator--()
|
||||
{
|
||||
node = node ? node->prev : NULL;
|
||||
return *this;
|
||||
}
|
||||
kbList::iterator &
|
||||
kbList::iterator::operator++(int /* foo */)
|
||||
{
|
||||
return operator++();
|
||||
}
|
||||
|
||||
kbList::iterator &
|
||||
kbList::iterator::operator--(int /* bar */)
|
||||
{
|
||||
return operator--();
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
kbList::iterator::operator !=(kbList::iterator const & i) const
|
||||
{
|
||||
return node != i.node;
|
||||
}
|
||||
|
||||
bool
|
||||
kbList::iterator::operator ==(kbList::iterator const & i) const
|
||||
{
|
||||
return node == i.node;
|
||||
}
|
||||
|
||||
kbList::kbList(bool ownsEntriesFlag)
|
||||
{
|
||||
first = NULL;
|
||||
last = NULL;
|
||||
ownsEntries = ownsEntriesFlag;
|
||||
}
|
||||
|
||||
void
|
||||
kbList::push_back(void *element)
|
||||
{
|
||||
if(! first) // special case of empty list
|
||||
{
|
||||
first = new kbListNode(element);
|
||||
last = first;
|
||||
return;
|
||||
}
|
||||
else
|
||||
last = new kbListNode(element, last);
|
||||
}
|
||||
|
||||
void
|
||||
kbList::push_front(void *element)
|
||||
{
|
||||
if(! first) // special case of empty list
|
||||
{
|
||||
push_back(element);
|
||||
return;
|
||||
}
|
||||
else
|
||||
first = new kbListNode(element, NULL, first);
|
||||
}
|
||||
|
||||
void *
|
||||
kbList::pop_back(void)
|
||||
{
|
||||
iterator i;
|
||||
void *data;
|
||||
bool ownsFlagBak = ownsEntries;
|
||||
i = tail();
|
||||
data = *i;
|
||||
ownsEntries = false;
|
||||
erase(i);
|
||||
ownsEntries = ownsFlagBak;
|
||||
return data;
|
||||
}
|
||||
|
||||
void *
|
||||
kbList::pop_front(void)
|
||||
{
|
||||
iterator i;
|
||||
void *data;
|
||||
bool ownsFlagBak = ownsEntries;
|
||||
|
||||
i = begin();
|
||||
data = *i;
|
||||
ownsEntries = false;
|
||||
erase(i);
|
||||
ownsEntries = ownsFlagBak;
|
||||
return data;
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
kbList::insert(kbList::iterator & i, void *element)
|
||||
{
|
||||
if(! i.Node())
|
||||
return;
|
||||
else if(i.Node() == first)
|
||||
{
|
||||
push_front(element);
|
||||
i = first;
|
||||
return;
|
||||
}
|
||||
i = kbList::iterator(new kbListNode(element, i.Node()->prev, i.Node()));
|
||||
}
|
||||
|
||||
void
|
||||
kbList::doErase(kbList::iterator & i)
|
||||
{
|
||||
kbListNode
|
||||
*node = i.Node(),
|
||||
*prev, *next;
|
||||
|
||||
if(! node) // illegal iterator
|
||||
return;
|
||||
|
||||
prev = node->prev;
|
||||
next = node->next;
|
||||
|
||||
// correct first/last:
|
||||
if(node == first)
|
||||
first = node->next;
|
||||
if(node == last) // don't put else here!
|
||||
last = node->prev;
|
||||
|
||||
// build new links:
|
||||
if(prev)
|
||||
prev->next = next;
|
||||
if(next)
|
||||
next->prev = prev;
|
||||
|
||||
// delete this node and contents:
|
||||
// now done separately
|
||||
//if(ownsEntries)
|
||||
//delete *i;
|
||||
delete i.Node();
|
||||
|
||||
// change the iterator to next element:
|
||||
i = kbList::iterator(next);
|
||||
}
|
||||
|
||||
kbList::~kbList()
|
||||
{
|
||||
kbListNode *next;
|
||||
|
||||
while ( first != NULL )
|
||||
{
|
||||
next = first->next;
|
||||
if(ownsEntries)
|
||||
delete first->element;
|
||||
delete first;
|
||||
first = next;
|
||||
}
|
||||
}
|
||||
|
||||
kbList::iterator
|
||||
kbList::begin(void) const
|
||||
{
|
||||
return kbList::iterator(first);
|
||||
}
|
||||
|
||||
kbList::iterator
|
||||
kbList::tail(void) const
|
||||
{
|
||||
return kbList::iterator(last);
|
||||
}
|
||||
|
||||
kbList::iterator
|
||||
kbList::end(void) const
|
||||
{
|
||||
return kbList::iterator(NULL); // the one after the last
|
||||
}
|
||||
|
||||
unsigned
|
||||
kbList::size(void) const // inefficient
|
||||
{
|
||||
unsigned count = 0;
|
||||
kbList::iterator i;
|
||||
for(i = begin(); i != end(); i++, count++)
|
||||
;
|
||||
return count;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#ifdef KBLIST_TEST
|
||||
|
||||
#include <iostream.h>
|
||||
|
||||
KBLIST_DEFINE(kbListInt,int);
|
||||
|
||||
int main(void)
|
||||
{
|
||||
int
|
||||
n, *ptr;
|
||||
kbListInt
|
||||
l;
|
||||
kbListInt::iterator
|
||||
i;
|
||||
|
||||
for(n = 0; n < 10; n++)
|
||||
{
|
||||
ptr = new int;
|
||||
*ptr = n*n;
|
||||
l.push_back(ptr);
|
||||
}
|
||||
|
||||
i = l.begin(); // first element
|
||||
i++; // 2nd
|
||||
i++; // 3rd
|
||||
i++; // 4th, insert here:
|
||||
ptr = new int;
|
||||
*ptr = 4444;
|
||||
l.insert(i,ptr);
|
||||
|
||||
// this cannot work, because l.end() returns NULL:
|
||||
i = l.end(); // behind last
|
||||
i--; // still behind last
|
||||
l.erase(i); // doesn't do anything
|
||||
|
||||
// this works:
|
||||
i = l.tail(); // last element
|
||||
i--;
|
||||
--i;
|
||||
l.erase(i); // erase 3rd last element (49)
|
||||
|
||||
for(i = l.begin(); i != l.end(); i++)
|
||||
cout << *i << '\t' << *((int *)*i) << endl;
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
315
user/wxLayout/kbList.h
Normal file
@@ -0,0 +1,315 @@
|
||||
/*-*- c++ -*-********************************************************
|
||||
* kbList.h : a double linked list *
|
||||
* *
|
||||
* (C) 1998 by Karsten Ball<6C>der (Ballueder@usa.net) *
|
||||
* *
|
||||
* $Id$
|
||||
*
|
||||
*******************************************************************/
|
||||
|
||||
#ifndef KBLIST_H
|
||||
# define KBLIST_H
|
||||
|
||||
#ifdef __GNUG__
|
||||
# pragma interface "kbList.h"
|
||||
#endif
|
||||
|
||||
#ifndef NULL
|
||||
# define NULL 0
|
||||
#endif
|
||||
|
||||
/**@name Double linked list implementation. */
|
||||
//@{
|
||||
|
||||
/** kbListNode is a class used by kbList. It represents a single
|
||||
element in the list. It is not intended for general use outside
|
||||
kbList functions.
|
||||
*/
|
||||
struct kbListNode
|
||||
{
|
||||
/// pointer to next node or NULL
|
||||
struct kbListNode *next;
|
||||
/// pointer to previous node or NULL
|
||||
struct kbListNode *prev;
|
||||
/// pointer to the actual data
|
||||
void *element;
|
||||
/** Constructor - it automatically links the node into the list, if
|
||||
the iprev, inext parameters are given.
|
||||
@param ielement pointer to the data for this node (i.e. the data itself)
|
||||
@param iprev if not NULL, use this as previous element in list
|
||||
@param inext if not NULL, use this as next element in list
|
||||
*/
|
||||
kbListNode( void *ielement,
|
||||
kbListNode *iprev = NULL,
|
||||
kbListNode *inext = NULL);
|
||||
/// Destructor.
|
||||
~kbListNode();
|
||||
};
|
||||
|
||||
/** The main list class, handling void pointers as data.
|
||||
*/
|
||||
|
||||
class kbList
|
||||
{
|
||||
public:
|
||||
/// An iterator class for kbList, just like for the STL classes.
|
||||
class iterator
|
||||
{
|
||||
protected:
|
||||
/// the node to which this iterator points
|
||||
kbListNode *node;
|
||||
friend class kbList;
|
||||
public:
|
||||
/** Constructor.
|
||||
@param n if not NULL, the node to which to point
|
||||
*/
|
||||
iterator(kbListNode *n = NULL);
|
||||
/** Dereference operator.
|
||||
@return the data pointer of the node belonging to this
|
||||
iterator
|
||||
*/
|
||||
void * operator*();
|
||||
|
||||
/** This operator allows us to write if(i). It is <em>not</em> a
|
||||
dereference operator and the result is always useless apart
|
||||
from its logical value!
|
||||
*/
|
||||
operator void*() const { return node == NULL ? (void*)0 : (void*)(-1); }
|
||||
|
||||
/** Increment operator - prefix, goes to next node in list.
|
||||
@return itself
|
||||
*/
|
||||
iterator & operator++();
|
||||
|
||||
/** Decrement operator - prefix, goes to previous node in list.
|
||||
@return itself
|
||||
*/
|
||||
iterator & operator--();
|
||||
|
||||
/** Increment operator - prefix, goes to next node in list.
|
||||
@return itself
|
||||
*/
|
||||
iterator & operator++(int); //postfix
|
||||
|
||||
/** Decrement operator - prefix, goes to previous node in list.
|
||||
@return itself
|
||||
*/
|
||||
iterator & operator--(int); //postfix
|
||||
|
||||
/** Comparison operator.
|
||||
@return true if not equal.
|
||||
*/
|
||||
bool operator !=(iterator const &) const;
|
||||
|
||||
/* Comparison operator.
|
||||
@return true if equal
|
||||
*/
|
||||
bool operator ==(iterator const &) const;
|
||||
|
||||
/** Returns a pointer to the node associated with this iterator.
|
||||
This function is not for general use and should be
|
||||
protected. However, if protected, it cannot be called from
|
||||
derived classes' iterators. (Is this a bug in gcc/egcs?)
|
||||
@return the node pointer
|
||||
*/
|
||||
inline kbListNode * Node(void) const
|
||||
{ return node; }
|
||||
};
|
||||
|
||||
/** Constructor.
|
||||
@param ownsEntriesFlag if true, the list owns the entries and
|
||||
will issue a delete on each of them when deleting them. If
|
||||
false, the entries themselves will not get deleted. Do not use
|
||||
this with array types!
|
||||
*/
|
||||
kbList(bool ownsEntriesFlag = true);
|
||||
|
||||
/** Destructor.
|
||||
If entries are owned, they will all get deleted from here.
|
||||
*/
|
||||
~kbList();
|
||||
|
||||
/** Tell list whether it owns objects. If owned, they can be
|
||||
deleted by list. See the constructor for more details.
|
||||
@param ownsflag if true, list will own entries
|
||||
*/
|
||||
void ownsObjects(bool ownsflag = true)
|
||||
{ ownsEntries = ownsflag; }
|
||||
|
||||
/** Query whether list owns entries.
|
||||
@return true if list owns entries
|
||||
*/
|
||||
bool ownsObjects(void)
|
||||
{ return ownsEntries; }
|
||||
|
||||
/** Add an entry at the end of the list.
|
||||
@param element pointer to data
|
||||
*/
|
||||
void push_back(void *element);
|
||||
|
||||
/** Add an entry at the head of the list.
|
||||
@param element pointer to data
|
||||
*/
|
||||
void push_front(void *element);
|
||||
|
||||
/** Get element from end of the list and delete it.
|
||||
NOTE: In this case the element's data will not get deleted by
|
||||
the list. It is the responsibility of the caller to free it.
|
||||
@return the element data
|
||||
*/
|
||||
void *pop_back(void);
|
||||
|
||||
/** Get element from head of the list and delete it.
|
||||
NOTE: In this case the element's data will not get deleted by
|
||||
the list. It is the responsibility of the caller to free it.
|
||||
@return the element data
|
||||
*/
|
||||
void *pop_front(void);
|
||||
|
||||
/** Insert an element into the list.
|
||||
@param i an iterator pointing to the element, before which the new one should be inserted
|
||||
@param element the element data
|
||||
*/
|
||||
void insert(iterator & i, void *element);
|
||||
|
||||
/** Remove an element from the list _without_ deleting the object.
|
||||
@param i iterator pointing to the element to be deleted
|
||||
@return the value of the element just removed
|
||||
*/
|
||||
void *remove(iterator& i) { void *p = *i; doErase(i); return p; }
|
||||
|
||||
/** Erase an element, move iterator to following element.
|
||||
@param i iterator pointing to the element to be deleted
|
||||
*/
|
||||
void erase(iterator & i) { deleteContent(i); doErase(i); }
|
||||
|
||||
/* Get head of list.
|
||||
@return iterator pointing to head of list
|
||||
*/
|
||||
iterator begin(void) const;
|
||||
|
||||
/* Get end of list.
|
||||
@return iterator pointing after the end of the list. This is an
|
||||
invalid iterator which cannot be dereferenced or decremented. It is
|
||||
only of use in comparisons. NOTE: this is different from STL!
|
||||
@see tail
|
||||
*/
|
||||
iterator end(void) const;
|
||||
|
||||
/* Get last element in list.
|
||||
@return iterator pointing to the last element in the list.
|
||||
@see end
|
||||
*/
|
||||
iterator tail(void) const;
|
||||
|
||||
/* Get the number of elements in the list.
|
||||
@return number of elements in the list
|
||||
*/
|
||||
unsigned size(void) const;
|
||||
|
||||
/* Query whether list is empty.
|
||||
@return true if list is empty
|
||||
*/
|
||||
inline bool empty(void) const
|
||||
{ return first == NULL ; }
|
||||
|
||||
protected:
|
||||
/// if true, list owns entries
|
||||
bool ownsEntries;
|
||||
/// pointer to first element in list
|
||||
kbListNode *first;
|
||||
/// pointer to last element in list
|
||||
kbListNode *last;
|
||||
protected:
|
||||
/** Erase an element, move iterator to following element.
|
||||
@param i iterator pointing to the element to be deleted
|
||||
*/
|
||||
void doErase(iterator & i);
|
||||
|
||||
/** Deletes the actual content if ownsflag is set.
|
||||
param iterator i
|
||||
*/
|
||||
inline void deleteContent(iterator i)
|
||||
{ if(ownsEntries) delete *i; }
|
||||
|
||||
|
||||
private:
|
||||
/// forbid copy construction
|
||||
kbList(kbList const &foo);
|
||||
/// forbid assignments
|
||||
kbList& operator=(const kbList& foo);
|
||||
};
|
||||
|
||||
/// just for backward compatibility, will be removed soon
|
||||
typedef kbList::iterator kbListIterator;
|
||||
/// cast an iterator to a pointer, compatibility only to be removed
|
||||
#define kbListICast(type, iterator) ((type *)*iterator)
|
||||
/// cast an iterator to a const pointer, compatibility only to be removed
|
||||
#define kbListIcCast(type, iterator) ((type const *)*iterator)
|
||||
|
||||
/** Macro to define a kbList with a given name, having elements of
|
||||
pointer to the given type. I.e. KBLIST_DEFINE(Int,int) would
|
||||
create a kbListInt type holding int pointers.
|
||||
*/
|
||||
#define KBLIST_DEFINE(name,type) \
|
||||
class name : public kbList \
|
||||
{ \
|
||||
public: \
|
||||
class iterator : public kbList::iterator \
|
||||
{ \
|
||||
protected: \
|
||||
inline iterator(kbList::iterator const & i) \
|
||||
{ node = i.Node(); } \
|
||||
friend class name; \
|
||||
public: \
|
||||
inline iterator(kbListNode *n = NULL) \
|
||||
: kbList::iterator(n) {} \
|
||||
inline type * operator*() \
|
||||
/* the cast is needed for MS VC++ 5.0 */ \
|
||||
{ return (type *)((kbList::iterator *)this)->operator*() ; } \
|
||||
}; \
|
||||
inline name(bool ownsEntriesFlag = TRUE) \
|
||||
: kbList(ownsEntriesFlag) {} \
|
||||
\
|
||||
inline type *pop_back(void) \
|
||||
{ return (type *) kbList::pop_back(); } \
|
||||
\
|
||||
inline type *pop_front(void) \
|
||||
{ return (type *) kbList::pop_front(); } \
|
||||
\
|
||||
type *remove(iterator& i) \
|
||||
{ return (type *)kbList::remove(i); } \
|
||||
inline void erase(iterator & i) \
|
||||
{ deleteContent(i); doErase(i); } \
|
||||
\
|
||||
inline iterator begin(void) const \
|
||||
{ return kbList::begin(); } \
|
||||
\
|
||||
inline iterator end(void) const \
|
||||
{ return kbList::end(); } \
|
||||
\
|
||||
inline iterator tail(void) const \
|
||||
{ return kbList::tail(); } \
|
||||
~name() \
|
||||
{ \
|
||||
kbListNode *next; \
|
||||
while ( first != NULL ) \
|
||||
{ \
|
||||
next = first->next; \
|
||||
if(ownsEntries) \
|
||||
delete (type *)first->element; \
|
||||
delete first; \
|
||||
first = next; \
|
||||
} \
|
||||
} \
|
||||
protected: \
|
||||
inline void deleteContent(iterator i) \
|
||||
{ if(ownsEntries) delete *i; } \
|
||||
}
|
||||
|
||||
#ifdef MCONFIG_H
|
||||
/// define the most commonly used list type once:
|
||||
KBLIST_DEFINE(kbStringList, String);
|
||||
#endif
|
||||
//@}
|
||||
#endif // KBLIST_H
|
431
user/wxLayout/wxLayout.cpp
Normal file
@@ -0,0 +1,431 @@
|
||||
/*
|
||||
* Program: wxLayout
|
||||
*
|
||||
* Author: Karsten Ball<6C>der
|
||||
*
|
||||
* Copyright: (C) 1998, Karsten Ball<6C>der <Ballueder@usa.net>
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma implementation "wxLayout.h"
|
||||
#endif
|
||||
|
||||
#include "wx/wxprec.h"
|
||||
#ifdef __BORLANDC__
|
||||
# pragma hdrstop
|
||||
#endif
|
||||
|
||||
#include "wxLayout.h"
|
||||
#include "wx/textfile.h"
|
||||
|
||||
|
||||
#include "Micon.xpm"
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// main program
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
IMPLEMENT_APP(MyApp)
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// MyFrame
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
enum ids{ ID_ADD_SAMPLE = 1, ID_CLEAR, ID_PRINT,
|
||||
ID_PRINT_SETUP, ID_PAGE_SETUP, ID_PREVIEW, ID_PRINT_PS,
|
||||
ID_PRINT_SETUP_PS, ID_PAGE_SETUP_PS,ID_PREVIEW_PS,
|
||||
ID_WRAP, ID_NOWRAP, ID_PASTE, ID_COPY,
|
||||
ID_WXLAYOUT_DEBUG, ID_QUIT, ID_CLICK, ID_HTML, ID_TEXT,
|
||||
ID_TEST, ID_LONG_TEST };
|
||||
|
||||
|
||||
IMPLEMENT_DYNAMIC_CLASS( MyFrame, wxFrame )
|
||||
|
||||
BEGIN_EVENT_TABLE(MyFrame,wxFrame)
|
||||
EVT_MENU(ID_PRINT, MyFrame::OnPrint)
|
||||
EVT_MENU(ID_PREVIEW, MyFrame::OnPrintPreview)
|
||||
EVT_MENU(ID_PRINT_SETUP, MyFrame::OnPrintSetup)
|
||||
EVT_MENU(ID_PAGE_SETUP, MyFrame::OnPageSetup)
|
||||
EVT_MENU(ID_PRINT_PS, MyFrame::OnPrintPS)
|
||||
EVT_MENU(ID_PREVIEW_PS, MyFrame::OnPrintPreviewPS)
|
||||
EVT_MENU(ID_PRINT_SETUP_PS, MyFrame::OnPrintSetupPS)
|
||||
EVT_MENU(ID_PAGE_SETUP_PS, MyFrame::OnPageSetupPS)
|
||||
EVT_MENU (-1, MyFrame::OnCommand)
|
||||
EVT_COMMAND (-1,-1, MyFrame::OnCommand)
|
||||
EVT_CHAR ( wxLayoutWindow::OnChar )
|
||||
END_EVENT_TABLE()
|
||||
|
||||
|
||||
MyFrame::MyFrame(void) :
|
||||
wxFrame( (wxFrame *) NULL, -1, (char *) "wxLayout", wxPoint(20,20), wxSize(600,360) )
|
||||
{
|
||||
CreateStatusBar( 1 );
|
||||
|
||||
SetStatusText( "wxLayout by Karsten Ball<6C>der." );
|
||||
|
||||
wxMenuBar *menu_bar = new wxMenuBar();
|
||||
|
||||
wxMenu *file_menu = new wxMenu;
|
||||
file_menu->Append(ID_PRINT, "&Print...", "Print");
|
||||
file_menu->Append(ID_PRINT_SETUP, "Print &Setup...","Setup printer properties");
|
||||
file_menu->Append(ID_PAGE_SETUP, "Page Set&up...", "Page setup");
|
||||
file_menu->Append(ID_PREVIEW, "Print Pre&view", "Preview");
|
||||
#ifdef __WXMSW__
|
||||
file_menu->AppendSeparator();
|
||||
file_menu->Append(ID_PRINT_PS, "Print PostScript...", "Print (PostScript)");
|
||||
file_menu->Append(ID_PRINT_SETUP_PS, "Print Setup PostScript...", "Setup printer properties (PostScript)");
|
||||
file_menu->Append(ID_PAGE_SETUP_PS, "Page Setup PostScript...", "Page setup (PostScript)");
|
||||
file_menu->Append(ID_PREVIEW_PS, "Print Preview PostScript", "Preview (PostScript)");
|
||||
#endif
|
||||
file_menu->AppendSeparator();
|
||||
file_menu->Append( ID_TEXT, "Export Text");
|
||||
file_menu->Append( ID_HTML, "Export HTML");
|
||||
file_menu->Append( ID_QUIT, "Exit");
|
||||
menu_bar->Append(file_menu, "File" );
|
||||
|
||||
wxMenu *edit_menu = new wxMenu;
|
||||
edit_menu->Append( ID_CLEAR, "Clear");
|
||||
edit_menu->Append( ID_ADD_SAMPLE, "Example");
|
||||
edit_menu->Append( ID_LONG_TEST, "Add many lines");
|
||||
edit_menu->AppendSeparator();
|
||||
edit_menu->Append(ID_WRAP, "Wrap mode", "Activate wrapping at pixel 200.");
|
||||
edit_menu->Append(ID_NOWRAP, "No-wrap mode", "Deactivate wrapping.");
|
||||
edit_menu->AppendSeparator();
|
||||
edit_menu->Append(ID_COPY, "Copy", "Copy text to clipboard.");
|
||||
edit_menu->Append(ID_PASTE,"Paste", "Paste text from clipboard.");
|
||||
menu_bar->Append(edit_menu, "Edit" );
|
||||
|
||||
#ifndef __WXMSW__
|
||||
menu_bar->Show( TRUE );
|
||||
#endif // MSW
|
||||
|
||||
SetMenuBar( menu_bar );
|
||||
|
||||
m_lwin = new wxLayoutWindow(this);
|
||||
m_lwin->SetMouseTracking(true);
|
||||
m_lwin->SetEditable(true);
|
||||
m_lwin->SetWrapMargin(40);
|
||||
m_lwin->Clear(wxROMAN,16,wxNORMAL,wxNORMAL, false);
|
||||
m_lwin->SetFocus();
|
||||
};
|
||||
|
||||
void
|
||||
MyFrame::AddSampleText(wxLayoutList *llist)
|
||||
{
|
||||
llist->SetFont(wxROMAN,16,wxNORMAL,wxNORMAL, false);
|
||||
llist->Insert("--");
|
||||
llist->LineBreak();
|
||||
|
||||
llist->SetFont(wxROMAN);
|
||||
llist->Insert("The quick brown fox jumps over the lazy dog.");
|
||||
llist->LineBreak();
|
||||
llist->Insert("Hello ");
|
||||
llist->Insert(new wxLayoutObjectIcon(new wxICON(Micon)));
|
||||
llist->SetFontWeight(wxBOLD);
|
||||
llist->Insert("World! ");
|
||||
llist->SetFontWeight(wxNORMAL);
|
||||
llist->Insert("The quick brown fox jumps...");
|
||||
llist->LineBreak();
|
||||
|
||||
llist->Insert("over the lazy dog.");
|
||||
llist->SetFont(-1,-1,-1,-1,true);
|
||||
llist->Insert("underlined");
|
||||
llist->SetFont(-1,-1,-1,-1,false);
|
||||
llist->SetFont(wxROMAN);
|
||||
llist->Insert("This is ");
|
||||
llist->SetFont(-1,-1,-1,wxBOLD); llist->Insert("BOLD "); llist->SetFont(-1,-1,-1,wxNORMAL);
|
||||
llist->Insert("and ");
|
||||
llist->SetFont(-1,-1,wxITALIC);
|
||||
llist->Insert("italics ");
|
||||
llist->SetFont(-1,-1,wxNORMAL);
|
||||
llist->LineBreak();
|
||||
|
||||
llist->Insert("and ");
|
||||
llist->SetFont(-1,-1,wxSLANT);
|
||||
llist->Insert("slanted");
|
||||
llist->SetFont(-1,-1,wxNORMAL);
|
||||
llist->Insert(" text.");
|
||||
llist->LineBreak();
|
||||
llist->Insert("and ");
|
||||
llist->SetFont(-1,-1,-1,-1,-1,"blue");
|
||||
llist->Insert("blue");
|
||||
llist->SetFont(-1,-1,-1,-1,-1,"black");
|
||||
llist->Insert(" and ");
|
||||
llist->SetFont(-1,-1,-1,-1,-1,"green","black");
|
||||
llist->Insert("green on black");
|
||||
llist->SetFont(-1,-1,-1,-1,-1,"black","white");
|
||||
llist->Insert(" text.");
|
||||
llist->LineBreak();
|
||||
|
||||
llist->SetFont(-1,-1,wxSLANT);
|
||||
llist->Insert("Slanted");
|
||||
llist->SetFont(-1,-1,wxNORMAL);
|
||||
llist->Insert(" and normal text and ");
|
||||
llist->SetFont(-1,-1,wxSLANT);
|
||||
llist->Insert("slanted");
|
||||
llist->SetFont(-1,-1,wxNORMAL);
|
||||
llist->Insert(" again.");
|
||||
llist->LineBreak();
|
||||
|
||||
// add some more text for testing:
|
||||
llist->Insert("And here the source for the test program:");
|
||||
llist->LineBreak();
|
||||
llist->SetFont(wxTELETYPE,16);
|
||||
char buffer[1024];
|
||||
FILE *in = fopen("wxLayout.cpp","r");
|
||||
if(in)
|
||||
{
|
||||
for(;;)
|
||||
{
|
||||
fgets(buffer,1024,in);
|
||||
if(feof(in))
|
||||
break;
|
||||
llist->Insert(buffer);
|
||||
llist->LineBreak();
|
||||
}
|
||||
}
|
||||
llist->MoveCursorTo(wxPoint(0,0));
|
||||
m_lwin->SetDirty();
|
||||
m_lwin->Refresh();
|
||||
}
|
||||
|
||||
void
|
||||
MyFrame::Clear(void)
|
||||
{
|
||||
m_lwin->Clear(wxROMAN,16,wxNORMAL,wxNORMAL, false);
|
||||
}
|
||||
|
||||
|
||||
void MyFrame::OnCommand( wxCommandEvent &event )
|
||||
{
|
||||
switch (event.GetId())
|
||||
{
|
||||
case ID_QUIT:
|
||||
Close( TRUE );
|
||||
break;
|
||||
case ID_PRINT:
|
||||
{
|
||||
wxPrinter printer;
|
||||
wxLayoutPrintout printout(m_lwin->GetLayoutList(),_("M: Printout"));
|
||||
if (! printer.Print(this, &printout, TRUE))
|
||||
wxMessageBox(
|
||||
_("There was a problem with printing the message:\n"
|
||||
"perhaps your current printer is not set up correctly?"),
|
||||
_("Printing"), wxOK);
|
||||
}
|
||||
break;
|
||||
case ID_NOWRAP:
|
||||
case ID_WRAP:
|
||||
m_lwin->SetWrapMargin(event.GetId() == ID_NOWRAP ? 0 : 40);
|
||||
break;
|
||||
case ID_ADD_SAMPLE:
|
||||
AddSampleText(m_lwin->GetLayoutList());
|
||||
break;
|
||||
case ID_CLEAR:
|
||||
Clear();
|
||||
break;
|
||||
case ID_CLICK:
|
||||
cerr << "Received click event." << endl;
|
||||
break;
|
||||
case ID_PASTE:
|
||||
m_lwin->Paste();
|
||||
break;
|
||||
case ID_COPY:
|
||||
m_lwin->Copy();
|
||||
break;
|
||||
case ID_HTML:
|
||||
{
|
||||
wxLayoutExportObject *export;
|
||||
wxLayoutExportStatus status(m_lwin->GetLayoutList());
|
||||
|
||||
while((export = wxLayoutExport( &status,
|
||||
WXLO_EXPORT_AS_HTML)) != NULL)
|
||||
{
|
||||
if(export->type == WXLO_EXPORT_HTML)
|
||||
cout << *(export->content.text);
|
||||
else
|
||||
cout << "<!--UNKNOWN OBJECT>";
|
||||
delete export;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case ID_TEXT:
|
||||
{
|
||||
wxLayoutExportObject *export;
|
||||
wxLayoutExportStatus status(m_lwin->GetLayoutList());
|
||||
|
||||
while((export = wxLayoutExport( &status, WXLO_EXPORT_AS_TEXT)) != NULL)
|
||||
{
|
||||
if(export->type == WXLO_EXPORT_TEXT)
|
||||
cout << *(export->content.text);
|
||||
else
|
||||
cout << "<!--UNKNOWN OBJECT>";
|
||||
delete export;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case ID_LONG_TEST:
|
||||
{
|
||||
wxString line;
|
||||
wxLayoutList *llist = m_lwin->GetLayoutList();
|
||||
for(int i = 1; i < 5000; i++)
|
||||
{
|
||||
line.Printf("This is line number %d.", i);
|
||||
llist->Insert(line);
|
||||
llist->LineBreak();
|
||||
}
|
||||
llist->MoveCursorTo(wxPoint(0,0));
|
||||
m_lwin->SetDirty();
|
||||
m_lwin->Refresh();
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
void MyFrame::OnPrint(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
#ifdef __WXMSW__
|
||||
wxGetApp().SetPrintMode(wxPRINT_WINDOWS);
|
||||
#else
|
||||
wxGetApp().SetPrintMode(wxPRINT_POSTSCRIPT);
|
||||
#endif
|
||||
wxPrinter printer;
|
||||
wxLayoutPrintout printout( m_lwin->GetLayoutList(),"Printout from wxLayout");
|
||||
if (! printer.Print(this, &printout, TRUE))
|
||||
wxMessageBox(
|
||||
"There was a problem printing.\nPerhaps your current printer is not set correctly?",
|
||||
"Printing", wxOK);
|
||||
}
|
||||
|
||||
void MyFrame::OnPrintPS(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
wxGetApp().SetPrintMode(wxPRINT_POSTSCRIPT);
|
||||
|
||||
#ifdef OS_UNIX
|
||||
wxPostScriptPrinter printer;
|
||||
wxLayoutPrintout printout( m_lwin->GetLayoutList(),"My printout");
|
||||
printer.Print(this, &printout, TRUE);
|
||||
#endif
|
||||
}
|
||||
|
||||
void MyFrame::OnPrintPreview(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
#ifdef __WXMSW__
|
||||
wxGetApp().SetPrintMode(wxPRINT_WINDOWS);
|
||||
#else
|
||||
wxGetApp().SetPrintMode(wxPRINT_POSTSCRIPT);
|
||||
#endif
|
||||
wxPrintData printData;
|
||||
|
||||
// Pass two printout objects: for preview, and possible printing.
|
||||
wxPrintPreview *preview = new wxPrintPreview(new
|
||||
wxLayoutPrintout(
|
||||
m_lwin->GetLayoutList()), new wxLayoutPrintout( m_lwin->GetLayoutList()), & printData);
|
||||
if (!preview->Ok())
|
||||
{
|
||||
delete preview;
|
||||
wxMessageBox("There was a problem previewing.\nPerhaps your current printer is not set correctly?", "Previewing", wxOK);
|
||||
return;
|
||||
}
|
||||
|
||||
wxPreviewFrame *frame = new wxPreviewFrame(preview, this, "Demo Print Preview", wxPoint(100, 100), wxSize(600, 650));
|
||||
frame->Centre(wxBOTH);
|
||||
frame->Initialize();
|
||||
frame->Show(TRUE);
|
||||
}
|
||||
|
||||
void MyFrame::OnPrintPreviewPS(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
wxGetApp().SetPrintMode(wxPRINT_POSTSCRIPT);
|
||||
|
||||
wxPrintData printData;
|
||||
|
||||
// Pass two printout objects: for preview, and possible printing.
|
||||
wxPrintPreview *preview = new wxPrintPreview(new wxLayoutPrintout( m_lwin->GetLayoutList()), new wxLayoutPrintout( m_lwin->GetLayoutList()), & printData);
|
||||
wxPreviewFrame *frame = new wxPreviewFrame(preview, this, "Demo Print Preview", wxPoint(100, 100), wxSize(600, 650));
|
||||
frame->Centre(wxBOTH);
|
||||
frame->Initialize();
|
||||
frame->Show(TRUE);
|
||||
}
|
||||
|
||||
void MyFrame::OnPrintSetup(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
#ifdef OS_WIN
|
||||
wxGetApp().SetPrintMode(wxPRINT_WINDOWS);
|
||||
#else
|
||||
wxGetApp().SetPrintMode(wxPRINT_POSTSCRIPT);
|
||||
#endif
|
||||
wxPrintDialog printerDialog(this, & m_PrintData);
|
||||
printerDialog.ShowModal();
|
||||
}
|
||||
|
||||
void MyFrame::OnPageSetup(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
#ifdef __WXMSW__
|
||||
wxGetApp().SetPrintMode(wxPRINT_WINDOWS);
|
||||
#else
|
||||
wxGetApp().SetPrintMode(wxPRINT_POSTSCRIPT);
|
||||
#endif
|
||||
wxPageSetupData data;
|
||||
|
||||
#ifdef __WXMSW__
|
||||
wxPageSetupDialog pageSetupDialog(this, & data);
|
||||
#else
|
||||
wxGenericPageSetupDialog pageSetupDialog(this, & data);
|
||||
#endif
|
||||
pageSetupDialog.ShowModal();
|
||||
|
||||
data = pageSetupDialog.GetPageSetupData();
|
||||
}
|
||||
|
||||
void MyFrame::OnPrintSetupPS(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
wxGetApp().SetPrintMode(wxPRINT_POSTSCRIPT);
|
||||
|
||||
wxPrintData data;
|
||||
|
||||
#ifdef __WXMSW__
|
||||
wxPrintDialog printerDialog(this, & data);
|
||||
#else
|
||||
wxGenericPrintDialog printerDialog(this, & data);
|
||||
#endif
|
||||
printerDialog.ShowModal();
|
||||
}
|
||||
|
||||
void MyFrame::OnPageSetupPS(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
wxGetApp().SetPrintMode(wxPRINT_POSTSCRIPT);
|
||||
|
||||
wxPageSetupData data;
|
||||
#ifdef __WXMSW__
|
||||
wxPageSetupDialog pageSetupDialog(this, & data);
|
||||
#else
|
||||
wxGenericPageSetupDialog pageSetupDialog(this, & data);
|
||||
#endif
|
||||
pageSetupDialog.ShowModal();
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// MyApp
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
MyApp::MyApp(void) :
|
||||
wxApp( )
|
||||
{
|
||||
};
|
||||
|
||||
bool MyApp::OnInit(void)
|
||||
{
|
||||
wxFrame *frame = new MyFrame();
|
||||
frame->Show( TRUE );
|
||||
// wxSetAFMPath("/usr/local/src/wxWindows/misc/afm/");
|
||||
return TRUE;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
66
user/wxLayout/wxLayout.h
Normal file
@@ -0,0 +1,66 @@
|
||||
/* -*- c++ -*- */
|
||||
|
||||
#ifndef __WXLAYOUTH__
|
||||
#define __WXLAYOUTH__
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma interface
|
||||
#endif
|
||||
|
||||
#include "wx/wx.h"
|
||||
|
||||
#include "wxllist.h"
|
||||
#include "wxlwindow.h"
|
||||
#include "wxlparser.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// derived classes
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class MyFrame;
|
||||
class MyApp;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// MyFrame
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class MyFrame: public wxFrame
|
||||
{
|
||||
DECLARE_DYNAMIC_CLASS(MyFrame)
|
||||
|
||||
public:
|
||||
|
||||
MyFrame(void);
|
||||
void AddSampleText(wxLayoutList *llist);
|
||||
void Clear(void);
|
||||
void OnCommand( wxCommandEvent &event );
|
||||
|
||||
void OnPrint(wxCommandEvent& event);
|
||||
void OnPrintPreview(wxCommandEvent& event);
|
||||
void OnPrintSetup(wxCommandEvent& event);
|
||||
void OnPageSetup(wxCommandEvent& event);
|
||||
void OnPrintPS(wxCommandEvent& event);
|
||||
void OnPrintPreviewPS(wxCommandEvent& event);
|
||||
void OnPrintSetupPS(wxCommandEvent& event);
|
||||
void OnPageSetupPS(wxCommandEvent& event);
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
|
||||
private:
|
||||
wxLayoutWindow *m_lwin;
|
||||
wxPrintData m_PrintData;
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// MyApp
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class MyApp: public wxApp
|
||||
{
|
||||
public:
|
||||
|
||||
MyApp(void);
|
||||
virtual bool OnInit(void);
|
||||
};
|
||||
|
||||
#endif // __WXCONVERTH__
|
1975
user/wxLayout/wxllist.cpp
Normal file
1003
user/wxLayout/wxllist.h
Normal file
253
user/wxLayout/wxlparser.cpp
Normal file
@@ -0,0 +1,253 @@
|
||||
/*-*- c++ -*-********************************************************
|
||||
* wxlparser.h : parsers, import/export for wxLayoutList *
|
||||
* *
|
||||
* (C) 1998,1999 by Karsten Ball<6C>der (Ballueder@usa.net) *
|
||||
* *
|
||||
* $Id$
|
||||
*******************************************************************/
|
||||
|
||||
#ifdef __GNUG__
|
||||
# pragma implementation "wxlparser.h"
|
||||
#endif
|
||||
|
||||
#include "Mpch.h"
|
||||
#ifdef M_PREFIX
|
||||
# include "gui/wxllist.h"
|
||||
# include "gui/wxlparser.h"
|
||||
#else
|
||||
# include "wxllist.h"
|
||||
# include "wxlparser.h"
|
||||
#endif
|
||||
|
||||
#define BASE_SIZE 12
|
||||
|
||||
inline static bool IsEndOfLine(const char *p, int mode)
|
||||
{
|
||||
// in addition to Unix EOL convention we also (but not instead) understand
|
||||
// the DOS one under Windows
|
||||
return
|
||||
(mode == WXLO_EXPORT_WITH_CRLF) ?
|
||||
((*p == '\r') && (*(p + 1) == '\n'))
|
||||
:
|
||||
(((*p == '\r') && (*(p + 1) == '\n'))||(*p == '\n'));
|
||||
}
|
||||
|
||||
void wxLayoutImportText(wxLayoutList *list, wxString const &str, int withflag)
|
||||
{
|
||||
if(str.Length() == 0)
|
||||
return;
|
||||
char * cptr = (char *)str.c_str(); // string gets changed only temporarily
|
||||
const char * begin = cptr;
|
||||
char backup;
|
||||
|
||||
for(;;)
|
||||
{
|
||||
begin = cptr;
|
||||
while( *cptr && !IsEndOfLine(cptr, withflag) )
|
||||
cptr++;
|
||||
backup = *cptr;
|
||||
*cptr = '\0';
|
||||
list->Insert(begin);
|
||||
*cptr = backup;
|
||||
|
||||
// check if it's the end of this line
|
||||
if ( IsEndOfLine(cptr, withflag) )
|
||||
{
|
||||
// if it was "\r\n", skip the following '\n'
|
||||
if ( *cptr == '\r' )
|
||||
cptr++;
|
||||
list->LineBreak();
|
||||
}
|
||||
else if(backup == '\0') // reached end of string
|
||||
break;
|
||||
cptr++;
|
||||
}
|
||||
}
|
||||
|
||||
static
|
||||
wxString wxLayoutExportCmdAsHTML(wxLayoutObjectCmd const & cmd,
|
||||
wxLayoutStyleInfo *styleInfo)
|
||||
{
|
||||
static char buffer[20];
|
||||
wxString html;
|
||||
|
||||
wxLayoutStyleInfo si;
|
||||
cmd.GetStyle(&si);
|
||||
|
||||
int size, sizecount;
|
||||
|
||||
html += "<font ";
|
||||
|
||||
html +="color=";
|
||||
sprintf(buffer,"\"#%02X%02X%02X\"", si.fg_red,si.fg_green,si.fg_blue);
|
||||
html += buffer;
|
||||
|
||||
|
||||
html += " bgcolor=";
|
||||
sprintf(buffer,"\"#%02X%02X%02X\"", si.bg_red,si.bg_green,si.bg_blue);
|
||||
html += buffer;
|
||||
|
||||
switch(si.family)
|
||||
{
|
||||
case wxSWISS:
|
||||
case wxMODERN:
|
||||
html += " face=\"Arial,Helvetica\""; break;
|
||||
case wxROMAN:
|
||||
html += " face=\"Times New Roman, Times\""; break;
|
||||
case wxTELETYPE:
|
||||
html += " face=\"Courier New, Courier\""; break;
|
||||
default:
|
||||
;
|
||||
}
|
||||
|
||||
size = BASE_SIZE; sizecount = 0;
|
||||
while(size < si.size && sizecount < 5)
|
||||
{
|
||||
sizecount ++;
|
||||
size = (size*12)/10;
|
||||
}
|
||||
while(size > si.size && sizecount > -5)
|
||||
{
|
||||
sizecount --;
|
||||
size = (size*10)/12;
|
||||
}
|
||||
html += "size=";
|
||||
sprintf(buffer,"%+1d", sizecount);
|
||||
html += buffer;
|
||||
|
||||
html +=">";
|
||||
|
||||
if(styleInfo != NULL)
|
||||
html ="</font>"+html; // terminate any previous font command
|
||||
|
||||
if((si.weight == wxBOLD) && ( (!styleInfo) || (styleInfo->weight != wxBOLD)))
|
||||
html += "<b>";
|
||||
else
|
||||
if(si.weight != wxBOLD && ( styleInfo && (styleInfo->weight == wxBOLD)))
|
||||
html += "</b>";
|
||||
|
||||
if(si.style == wxSLANT)
|
||||
si.style = wxITALIC; // the same for html
|
||||
|
||||
if((si.style == wxITALIC) && ( (!styleInfo) || (styleInfo->style != wxITALIC)))
|
||||
html += "<i>";
|
||||
else
|
||||
if(si.style != wxITALIC && ( styleInfo && (styleInfo->style == wxITALIC)))
|
||||
html += "</i>";
|
||||
|
||||
if(si.underline && ( (!styleInfo) || ! styleInfo->underline))
|
||||
html += "<u>";
|
||||
else if(si.underline == false && ( styleInfo && styleInfo->underline))
|
||||
html += "</u>";
|
||||
|
||||
|
||||
*styleInfo = si; // update last style info
|
||||
|
||||
return html;
|
||||
}
|
||||
|
||||
|
||||
|
||||
wxLayoutExportStatus::wxLayoutExportStatus(wxLayoutList *list)
|
||||
{
|
||||
list->GetDefaults()->GetStyle(&m_si);
|
||||
m_line = list->GetFirstLine();
|
||||
m_iterator = m_line->GetFirstObject();
|
||||
}
|
||||
|
||||
|
||||
|
||||
#define WXLO_IS_TEXT(type) \
|
||||
( type == WXLO_TYPE_TEXT \
|
||||
|| (type == WXLO_TYPE_CMD \
|
||||
&& mode == WXLO_EXPORT_AS_HTML))
|
||||
|
||||
|
||||
wxLayoutExportObject *wxLayoutExport(wxLayoutExportStatus *status,
|
||||
int mode, int flags)
|
||||
{
|
||||
wxASSERT(status);
|
||||
wxLayoutExportObject * export;
|
||||
|
||||
if(status->m_iterator == NULLIT) // end of line
|
||||
{
|
||||
if(!status->m_line || status->m_line->GetNextLine() == NULL)
|
||||
// reached end of list
|
||||
return NULL;
|
||||
}
|
||||
export = new wxLayoutExportObject();
|
||||
wxLayoutObjectType type;
|
||||
if(status->m_iterator != NULLIT)
|
||||
{
|
||||
type = (** status->m_iterator).GetType();
|
||||
if( mode == WXLO_EXPORT_AS_OBJECTS || ! WXLO_IS_TEXT(type)) // simple case
|
||||
{
|
||||
export->type = WXLO_EXPORT_OBJECT;
|
||||
export->content.object = *status->m_iterator;
|
||||
status->m_iterator++;
|
||||
return export;
|
||||
}
|
||||
}
|
||||
else
|
||||
{ // iterator == NULLIT
|
||||
if(mode == WXLO_EXPORT_AS_OBJECTS)
|
||||
{
|
||||
export->type = WXLO_EXPORT_EMPTYLINE;
|
||||
export->content.object = NULL; //empty line
|
||||
status->m_line = status->m_line->GetNextLine();
|
||||
if(status->m_line)
|
||||
status->m_iterator = status->m_line->GetFirstObject();
|
||||
return export;
|
||||
}
|
||||
else
|
||||
type = WXLO_TYPE_TEXT;
|
||||
}
|
||||
|
||||
wxString *str = new wxString();
|
||||
// text must be concatenated
|
||||
for(;;)
|
||||
{
|
||||
while(status->m_iterator == NULLIT)
|
||||
{
|
||||
if(flags & WXLO_EXPORT_AS_HTML)
|
||||
*str += "<br>";
|
||||
if(flags & WXLO_EXPORT_WITH_CRLF)
|
||||
*str += "\r\n";
|
||||
else
|
||||
*str += '\n';
|
||||
|
||||
status->m_line = status->m_line->GetNextLine();
|
||||
if(status->m_line)
|
||||
status->m_iterator = status->m_line->GetFirstObject();
|
||||
else
|
||||
break; // end of list
|
||||
}
|
||||
if(! status->m_line) // reached end of list, fall through
|
||||
break;
|
||||
type = (** status->m_iterator).GetType();
|
||||
if(type == WXLO_TYPE_ICON)
|
||||
break;
|
||||
switch(type)
|
||||
{
|
||||
case WXLO_TYPE_TEXT:
|
||||
*str += ((wxLayoutObjectText *)*status->m_iterator)->GetText();
|
||||
break;
|
||||
case WXLO_TYPE_CMD:
|
||||
wxASSERT_MSG( mode == WXLO_EXPORT_AS_HTML,
|
||||
"reached cmd object in text mode" );
|
||||
|
||||
*str += wxLayoutExportCmdAsHTML(*(wxLayoutObjectCmd const
|
||||
*)*status->m_iterator, & status->m_si);
|
||||
break;
|
||||
default: // ignore icons
|
||||
;
|
||||
}
|
||||
status->m_iterator++;
|
||||
}
|
||||
|
||||
export->type = (mode == WXLO_EXPORT_AS_HTML)
|
||||
? WXLO_EXPORT_HTML : WXLO_EXPORT_TEXT;
|
||||
export->content.text = str;
|
||||
return export;
|
||||
}
|
||||
|
85
user/wxLayout/wxlparser.h
Normal file
@@ -0,0 +1,85 @@
|
||||
/*-*- c++ -*-********************************************************
|
||||
* wxlparser.h : parsers, import/export for wxLayoutList *
|
||||
* *
|
||||
* (C) 1998 by Karsten Ball<6C>der (Ballueder@usa.net) *
|
||||
* *
|
||||
* $Id$
|
||||
*******************************************************************/
|
||||
#ifndef WXLPARSER_H
|
||||
# define WXLPARSER_H
|
||||
|
||||
#ifdef __GNUG__
|
||||
# pragma interface "wxlparser.h"
|
||||
#endif
|
||||
|
||||
#ifndef NULL
|
||||
# define NULL 0
|
||||
#endif
|
||||
|
||||
enum wxLayoutExportType
|
||||
{
|
||||
WXLO_EXPORT_TEXT,
|
||||
WXLO_EXPORT_HTML,
|
||||
WXLO_EXPORT_OBJECT,
|
||||
// this can be caused by empty lines:
|
||||
WXLO_EXPORT_EMPTYLINE
|
||||
};
|
||||
|
||||
enum wxLayoutExportMode
|
||||
{
|
||||
WXLO_EXPORT_AS_TEXT = 0x00,
|
||||
WXLO_EXPORT_AS_TEXT_AND_COMMANDS = 0x01,
|
||||
WXLO_EXPORT_AS_HTML = 0x02,
|
||||
WXLO_EXPORT_AS_OBJECTS = 0x03,
|
||||
|
||||
// non 0:
|
||||
WXLO_EXPORT_WITH_CRLF = 0x10,
|
||||
WXLO_EXPORT_WITH_LF_ONLY = 0x20
|
||||
};
|
||||
|
||||
struct wxLayoutExportObject
|
||||
{
|
||||
wxLayoutExportType type;
|
||||
union
|
||||
{
|
||||
wxString *text;
|
||||
wxLayoutObject *object;
|
||||
}content;
|
||||
~wxLayoutExportObject()
|
||||
{
|
||||
if(type == WXLO_EXPORT_TEXT || type == WXLO_EXPORT_HTML)
|
||||
delete content.text;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
struct wxLayoutExportStatus
|
||||
{
|
||||
wxLayoutExportStatus(wxLayoutList *list);
|
||||
wxLayoutLine * m_line;
|
||||
wxLOiterator m_iterator;
|
||||
wxLayoutStyleInfo m_si;
|
||||
};
|
||||
|
||||
#ifdef OS_WIN
|
||||
/// import text into a wxLayoutList (including linefeeds):
|
||||
void wxLayoutImportText(wxLayoutList *list, wxString const &str,
|
||||
int withflag = WXLO_EXPORT_WITH_CRLF);
|
||||
|
||||
wxLayoutExportObject *wxLayoutExport(wxLayoutExportStatus *status,
|
||||
int mode = WXLO_EXPORT_AS_TEXT,
|
||||
int flags =
|
||||
WXLO_EXPORT_WITH_CRLF);
|
||||
#else
|
||||
/// import text into a wxLayoutList (including linefeeds):
|
||||
void wxLayoutImportText(wxLayoutList *list, wxString const &str,
|
||||
int withflag = WXLO_EXPORT_WITH_LF_ONLY);
|
||||
|
||||
/// export text in a given format
|
||||
wxLayoutExportObject *wxLayoutExport(wxLayoutExportStatus *status,
|
||||
int mode = WXLO_EXPORT_AS_TEXT,
|
||||
int flags =
|
||||
WXLO_EXPORT_WITH_LF_ONLY);
|
||||
#endif
|
||||
|
||||
#endif //WXLPARSER_H
|
683
user/wxLayout/wxlwindow.cpp
Normal file
@@ -0,0 +1,683 @@
|
||||
/*-*- c++ -*-********************************************************
|
||||
* wxLwindow.h : a scrolled Window for displaying/entering rich text*
|
||||
* *
|
||||
* (C) 1998, 1999 by Karsten Ball<6C>der (Ballueder@usa.net) *
|
||||
* *
|
||||
* $Id$
|
||||
*******************************************************************/
|
||||
|
||||
#ifdef __GNUG__
|
||||
# pragma implementation "wxlwindow.h"
|
||||
#endif
|
||||
|
||||
#include "wx/wxprec.h"
|
||||
#ifdef __BORLANDC__
|
||||
# pragma hdrstop
|
||||
#endif
|
||||
|
||||
|
||||
#include "Mpch.h"
|
||||
#ifdef M_BASEDIR
|
||||
# ifndef USE_PCH
|
||||
# include "Mcommon.h"
|
||||
# include "gui/wxMenuDefs.h"
|
||||
# include "gui/wxMApp.h"
|
||||
# endif // USE_PCH
|
||||
# include "gui/wxlwindow.h"
|
||||
# include "gui/wxlparser.h"
|
||||
#else
|
||||
# ifdef __WXMSW__
|
||||
# include <windows.h>
|
||||
# undef FindWindow
|
||||
# undef GetCharWidth
|
||||
# undef StartDoc
|
||||
# endif
|
||||
|
||||
# include "wxlwindow.h"
|
||||
# include "wxlparser.h"
|
||||
#endif
|
||||
|
||||
#include <wx/clipbrd.h>
|
||||
#include <wx/textctrl.h>
|
||||
#include <wx/dataobj.h>
|
||||
|
||||
#include <ctype.h>
|
||||
|
||||
#ifdef WXLAYOUT_DEBUG
|
||||
# define WXLO_DEBUG(x) wxLogDebug x
|
||||
#else
|
||||
# define WXLO_DEBUG(x)
|
||||
#endif
|
||||
|
||||
/// offsets to put a nice frame around text
|
||||
#define WXLO_XOFFSET 4
|
||||
#define WXLO_YOFFSET 4
|
||||
|
||||
/// offset to the right and bottom for when to redraw scrollbars
|
||||
#define WXLO_ROFFSET 20
|
||||
#define WXLO_BOFFSET 20
|
||||
|
||||
BEGIN_EVENT_TABLE(wxLayoutWindow,wxScrolledWindow)
|
||||
EVT_PAINT (wxLayoutWindow::OnPaint)
|
||||
EVT_CHAR (wxLayoutWindow::OnChar)
|
||||
EVT_KEY_UP (wxLayoutWindow::OnKeyUp)
|
||||
EVT_LEFT_DOWN(wxLayoutWindow::OnLeftMouseClick)
|
||||
EVT_RIGHT_DOWN(wxLayoutWindow::OnRightMouseClick)
|
||||
EVT_LEFT_DCLICK(wxLayoutWindow::OnMouseDblClick)
|
||||
EVT_MOTION (wxLayoutWindow::OnMouseMove)
|
||||
EVT_MENU_RANGE(WXLOWIN_MENU_FIRST, WXLOWIN_MENU_LAST, wxLayoutWindow::OnMenu)
|
||||
EVT_SET_FOCUS(wxLayoutWindow::OnSetFocus)
|
||||
EVT_KILL_FOCUS(wxLayoutWindow::OnKillFocus)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
wxLayoutWindow::wxLayoutWindow(wxWindow *parent)
|
||||
: wxScrolledWindow(parent, -1, wxDefaultPosition, wxDefaultSize,
|
||||
wxHSCROLL | wxVSCROLL | wxBORDER)
|
||||
|
||||
{
|
||||
m_Editable = false;
|
||||
m_doSendEvents = false;
|
||||
m_ViewStartX = 0; m_ViewStartY = 0;
|
||||
m_DoPopupMenu = true;
|
||||
m_PopupMenu = MakeFormatMenu();
|
||||
m_memDC = new wxMemoryDC;
|
||||
m_bitmap = new wxBitmap(4,4);
|
||||
m_bitmapSize = wxPoint(4,4);
|
||||
m_llist = new wxLayoutList();
|
||||
m_BGbitmap = NULL;
|
||||
m_ScrollToCursor = false;
|
||||
SetWrapMargin(0);
|
||||
wxPoint max = m_llist->GetSize();
|
||||
SetScrollbars(10, 20 /*lineHeight*/, max.x/10+1, max.y/20+1);
|
||||
EnableScrolling(true,true);
|
||||
m_maxx = max.x; m_maxy = max.y;
|
||||
m_Selecting = false;
|
||||
SetCursor(wxCURSOR_IBEAM);
|
||||
SetDirty();
|
||||
}
|
||||
|
||||
wxLayoutWindow::~wxLayoutWindow()
|
||||
{
|
||||
delete m_memDC; // deletes bitmap automatically (?)
|
||||
delete m_bitmap;
|
||||
delete m_llist;
|
||||
delete m_PopupMenu;
|
||||
SetBackgroundBitmap(NULL);
|
||||
}
|
||||
|
||||
#ifdef __WXMSW__
|
||||
long
|
||||
wxLayoutWindow::MSWGetDlgCode()
|
||||
{
|
||||
// if we don't return this, we won't get OnChar() events for TABs and ENTER
|
||||
return DLGC_WANTCHARS | DLGC_WANTARROWS | DLGC_WANTMESSAGE;
|
||||
}
|
||||
#endif //MSW
|
||||
|
||||
void
|
||||
wxLayoutWindow::OnMouse(int eventId, wxMouseEvent& event)
|
||||
{
|
||||
wxPaintDC dc( this );
|
||||
PrepareDC( dc );
|
||||
SetFocus();
|
||||
|
||||
wxPoint findPos;
|
||||
findPos.x = dc.DeviceToLogicalX(event.GetX());
|
||||
findPos.y = dc.DeviceToLogicalY(event.GetY());
|
||||
|
||||
findPos.x -= WXLO_XOFFSET;
|
||||
findPos.y -= WXLO_YOFFSET;
|
||||
|
||||
if(findPos.x < 0) findPos.x = 0;
|
||||
if(findPos.y < 0) findPos.y = 0;
|
||||
|
||||
m_ClickPosition = wxPoint(event.GetX(), event.GetY());
|
||||
|
||||
wxPoint cursorPos;
|
||||
bool found;
|
||||
wxLayoutObject *obj = m_llist->FindObjectScreen(dc, findPos,
|
||||
&cursorPos, &found);
|
||||
|
||||
//has the mouse only been moved?
|
||||
if(eventId == WXLOWIN_MENU_MOUSEMOVE)
|
||||
{
|
||||
// found is only true if we are really over an object, not just
|
||||
// behind it
|
||||
if(found && obj && obj->GetUserData() != NULL)
|
||||
{
|
||||
if(!m_HandCursor)
|
||||
SetCursor(wxCURSOR_HAND);
|
||||
m_HandCursor = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(m_HandCursor)
|
||||
SetCursor(wxCURSOR_IBEAM);
|
||||
m_HandCursor = FALSE;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// always move cursor to mouse click:
|
||||
if(obj && eventId == WXLOWIN_MENU_LCLICK)
|
||||
{
|
||||
m_llist->MoveCursorTo(cursorPos);
|
||||
ScrollToCursor();
|
||||
Refresh(FALSE); // DoPaint suppresses flicker under GTK
|
||||
}
|
||||
if(!m_doSendEvents) // nothing to do
|
||||
return;
|
||||
|
||||
// only do the menu if activated, editable and not on a clickable object
|
||||
if(eventId == WXLOWIN_MENU_RCLICK
|
||||
&& IsEditable()
|
||||
&& (! obj || (obj && obj->GetUserData() == NULL))
|
||||
)
|
||||
{
|
||||
PopupMenu(m_PopupMenu, m_ClickPosition.x, m_ClickPosition.y);
|
||||
return;
|
||||
}
|
||||
// find the object at this position
|
||||
if(obj)
|
||||
{
|
||||
wxCommandEvent commandEvent(wxEVT_COMMAND_MENU_SELECTED, eventId);
|
||||
commandEvent.SetEventObject( this );
|
||||
commandEvent.SetClientData((char *)obj);
|
||||
GetEventHandler()->ProcessEvent(commandEvent);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Some simple keyboard handling.
|
||||
*/
|
||||
void
|
||||
wxLayoutWindow::OnChar(wxKeyEvent& event)
|
||||
{
|
||||
#ifdef WXLAYOUT_DEBUG
|
||||
if(event.KeyCode() == WXK_F1)
|
||||
{
|
||||
m_llist->Debug();
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
long keyCode = event.KeyCode();
|
||||
if(m_Selecting && ! event.ShiftDown())
|
||||
{
|
||||
m_llist->EndSelection();
|
||||
m_Selecting = false;
|
||||
}
|
||||
else
|
||||
if(! m_Selecting && event.ShiftDown())
|
||||
{
|
||||
switch(keyCode)
|
||||
{
|
||||
case WXK_UP:
|
||||
case WXK_DOWN:
|
||||
case WXK_RIGHT:
|
||||
case WXK_LEFT:
|
||||
case WXK_PRIOR:
|
||||
case WXK_NEXT:
|
||||
case WXK_HOME:
|
||||
case WXK_END:
|
||||
m_Selecting = true;
|
||||
m_llist->StartSelection();
|
||||
break;
|
||||
default:
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
/* These two nested switches work like this:
|
||||
The first one processes all non-editing keycodes, to move the
|
||||
cursor, etc. It's default will process all keycodes causing
|
||||
modifications to the buffer, but only if editing is allowed.
|
||||
*/
|
||||
switch(keyCode)
|
||||
{
|
||||
case WXK_RIGHT:
|
||||
m_llist->MoveCursorHorizontally(1);
|
||||
break;
|
||||
case WXK_LEFT:
|
||||
m_llist->MoveCursorHorizontally(-1);
|
||||
break;
|
||||
case WXK_UP:
|
||||
m_llist->MoveCursorVertically(-1);
|
||||
break;
|
||||
case WXK_DOWN:
|
||||
m_llist->MoveCursorVertically(1);
|
||||
break;
|
||||
case WXK_PRIOR:
|
||||
m_llist->MoveCursorVertically(-20);
|
||||
break;
|
||||
case WXK_NEXT:
|
||||
m_llist->MoveCursorVertically(20);
|
||||
break;
|
||||
case WXK_HOME:
|
||||
m_llist->MoveCursorToBeginOfLine();
|
||||
break;
|
||||
case WXK_END:
|
||||
m_llist->MoveCursorToEndOfLine();
|
||||
break;
|
||||
default:
|
||||
if(keyCode == 'c' && event.ControlDown())
|
||||
Copy();
|
||||
if( IsEditable() )
|
||||
{
|
||||
/* First, handle control keys */
|
||||
if(event.ControlDown() && ! event.AltDown())
|
||||
{
|
||||
switch(keyCode)
|
||||
{
|
||||
case WXK_DELETE :
|
||||
case 'd':
|
||||
m_llist->Delete(1);
|
||||
break;
|
||||
case 'y':
|
||||
m_llist->DeleteLines(1);
|
||||
break;
|
||||
case 'h': // like backspace
|
||||
if(m_llist->MoveCursorHorizontally(-1)) m_llist->Delete(1);
|
||||
break;
|
||||
case 'u':
|
||||
m_llist->DeleteToBeginOfLine();
|
||||
break;
|
||||
case 'k':
|
||||
m_llist->DeleteToEndOfLine();
|
||||
break;
|
||||
case 'v':
|
||||
Paste();
|
||||
break;
|
||||
#ifdef WXLAYOUT_DEBUG
|
||||
case WXK_F1:
|
||||
m_llist->SetFont(-1,-1,-1,-1,true); // underlined
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
;
|
||||
}
|
||||
}
|
||||
// ALT only:
|
||||
else if( event.AltDown() && ! event.ControlDown() )
|
||||
{
|
||||
switch(keyCode)
|
||||
{
|
||||
case WXK_DELETE:
|
||||
case 'd':
|
||||
m_llist->DeleteWord();
|
||||
break;
|
||||
default:
|
||||
;
|
||||
}
|
||||
}
|
||||
// no control keys:
|
||||
else if ( ! event.AltDown() && ! event.ControlDown())
|
||||
{
|
||||
switch(keyCode)
|
||||
{
|
||||
case WXK_INSERT:
|
||||
if(event.ShiftDown())
|
||||
Paste();
|
||||
break;
|
||||
case WXK_DELETE :
|
||||
m_llist->Delete(1);
|
||||
break;
|
||||
case WXK_BACK: // backspace
|
||||
if(m_llist->MoveCursorHorizontally(-1)) m_llist->Delete(1);
|
||||
break;
|
||||
case WXK_RETURN:
|
||||
if(m_WrapMargin > 0)
|
||||
m_llist->WrapLine(m_WrapMargin);
|
||||
m_llist->LineBreak();
|
||||
break;
|
||||
default:
|
||||
if((!(event.ControlDown() || event.AltDown() || event.MetaDown()))
|
||||
&& (keyCode < 256 && keyCode >= 32)
|
||||
)
|
||||
{
|
||||
wxString tmp;
|
||||
tmp += keyCode;
|
||||
if(m_WrapMargin > 0 && isspace(keyCode))
|
||||
m_llist->WrapLine(m_WrapMargin);
|
||||
m_llist->Insert(tmp);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
SetDirty();
|
||||
SetModified();
|
||||
}// if(IsEditable())
|
||||
}// first switch()
|
||||
ScrollToCursor();
|
||||
wxRect r = *m_llist->GetUpdateRect();
|
||||
DoPaint(&r);
|
||||
}
|
||||
|
||||
void
|
||||
wxLayoutWindow::OnKeyUp(wxKeyEvent& event)
|
||||
{
|
||||
if(event.KeyCode() == WXK_SHIFT && m_llist->IsSelecting())
|
||||
m_llist->EndSelection();
|
||||
event.Skip();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
wxLayoutWindow::ScrollToCursor(void)
|
||||
{
|
||||
wxClientDC dc( this );
|
||||
PrepareDC( dc );
|
||||
|
||||
int x0,y0,x1,y1, dx, dy;
|
||||
|
||||
// Calculate where the top of the visible area is:
|
||||
ViewStart(&x0,&y0);
|
||||
GetScrollPixelsPerUnit(&dx, &dy);
|
||||
x0 *= dx; y0 *= dy;
|
||||
|
||||
// Get the size of the visible window:
|
||||
GetClientSize(&x1,&y1);
|
||||
wxASSERT(x1 > 0);
|
||||
wxASSERT(y1 > 0);
|
||||
// As we have the values anyway, use them to avoid unnecessary
|
||||
// scrollbar updates.
|
||||
if(x1 > m_maxx) m_maxx = x1;
|
||||
if(y1 > m_maxy) m_maxy = y1;
|
||||
/* Make sure that the scrollbars are at a position so that the
|
||||
cursor is visible if we are editing. */
|
||||
/** Scroll so that cursor is visible! */
|
||||
WXLO_DEBUG(("m_ScrollToCursor = %d", (int) m_ScrollToCursor));
|
||||
wxPoint cc = m_llist->GetCursorScreenPos(*m_memDC);
|
||||
if(cc.x < x0 || cc.y < y0
|
||||
|| cc.x >= x0+(9*x1)/10 || cc.y >= y0+(9*y1/10)) // (9*x)/10 == 90%
|
||||
{
|
||||
int nx, ny;
|
||||
nx = cc.x - x1/2; if(nx < 0) nx = 0;
|
||||
ny = cc.y - y1/2; if(ny < 0) ny = 0;
|
||||
Scroll(nx/dx,ny/dy); // new view start
|
||||
x0 = nx; y0 = ny;
|
||||
m_ScrollToCursor = false; // avoid recursion
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
wxLayoutWindow::OnPaint( wxPaintEvent &WXUNUSED(event)) // or: OnDraw(wxDC& dc)
|
||||
{
|
||||
wxRect region = GetUpdateRegion().GetBox();
|
||||
InternalPaint(& region);
|
||||
}
|
||||
|
||||
void
|
||||
wxLayoutWindow::DoPaint(const wxRect *updateRect)
|
||||
{
|
||||
#ifdef __WXGTK__
|
||||
InternalPaint(updateRect);
|
||||
#else
|
||||
Refresh(FALSE, updateRect); // Causes bad flicker under wxGTK!!!
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
wxLayoutWindow::InternalPaint(const wxRect *updateRect)
|
||||
{
|
||||
wxPaintDC dc( this );
|
||||
PrepareDC( dc );
|
||||
|
||||
int x0,y0,x1,y1, dx, dy;
|
||||
|
||||
// Calculate where the top of the visible area is:
|
||||
ViewStart(&x0,&y0);
|
||||
GetScrollPixelsPerUnit(&dx, &dy);
|
||||
x0 *= dx; y0 *= dy;
|
||||
|
||||
// Get the size of the visible window:
|
||||
GetClientSize(&x1,&y1);
|
||||
wxASSERT(x1 > 0);
|
||||
wxASSERT(y1 > 0);
|
||||
// As we have the values anyway, use them to avoid unnecessary
|
||||
// scrollbar updates.
|
||||
if(x1 > m_maxx) m_maxx = x1;
|
||||
if(y1 > m_maxy) m_maxy = y1;
|
||||
|
||||
WXLO_DEBUG(("Update rect: %ld,%ld / %ld,%ld",
|
||||
updateRect->x, updateRect->y,
|
||||
updateRect->x+updateRect->width,
|
||||
updateRect->y+updateRect->height));
|
||||
|
||||
if(IsDirty())
|
||||
ResizeScrollbars();
|
||||
|
||||
/* Check whether the window has grown, if so, we need to reallocate
|
||||
the bitmap to be larger. */
|
||||
if(x1 > m_bitmapSize.x || y1 > m_bitmapSize.y)
|
||||
{
|
||||
wxASSERT(m_bitmapSize.x > 0);
|
||||
wxASSERT(m_bitmapSize.y > 0);
|
||||
|
||||
m_memDC->SelectObject(wxNullBitmap);
|
||||
delete m_bitmap;
|
||||
m_bitmapSize = wxPoint(x1,y1);
|
||||
m_bitmap = new wxBitmap(x1,y1);
|
||||
m_memDC->SelectObject(*m_bitmap);
|
||||
}
|
||||
|
||||
m_memDC->SetDeviceOrigin(0,0);
|
||||
m_memDC->SetBrush(wxBrush(m_llist->GetDefaults()->GetBGColour(),wxSOLID));
|
||||
m_memDC->SetPen(wxPen(m_llist->GetDefaults()->GetBGColour(),
|
||||
0,wxTRANSPARENT));
|
||||
m_memDC->SetLogicalFunction(wxCOPY);
|
||||
|
||||
/* Either fill the background with the background bitmap, or clear
|
||||
it. */
|
||||
if(m_BGbitmap)
|
||||
{
|
||||
CoordType
|
||||
y, x,
|
||||
w = m_BGbitmap->GetWidth(),
|
||||
h = m_BGbitmap->GetHeight();
|
||||
for(y = 0; y < y1; y+=h)
|
||||
for(x = 0; x < x1; x+=w)
|
||||
m_memDC->DrawBitmap(*m_BGbitmap, x, y);
|
||||
m_memDC->SetBackgroundMode(wxTRANSPARENT);
|
||||
}
|
||||
else
|
||||
{
|
||||
// clear the background: (must not be done if we use the update rectangle!)
|
||||
m_memDC->SetBackgroundMode(wxSOLID);
|
||||
m_memDC->DrawRectangle(0,0,x1, y1);
|
||||
}
|
||||
|
||||
|
||||
/* This is the important bit: we tell the list to draw itself: */
|
||||
WXLO_DEBUG(("Update rect: %ld,%ld / %ld,%ld",
|
||||
updateRect->x, updateRect->y,
|
||||
updateRect->x+updateRect->width,
|
||||
updateRect->y+updateRect->height));
|
||||
|
||||
// Device origins on the memDC are suspect, we translate manually
|
||||
// with the translate parameter of Draw().
|
||||
wxPoint offset(-x0+WXLO_XOFFSET,-y0+WXLO_YOFFSET);
|
||||
m_llist->Draw(*m_memDC,offset, y0, y0+y1);
|
||||
|
||||
// We start calculating a new update rect before drawing the
|
||||
// cursor, so that the cursor coordinates get included in the next
|
||||
// update rectangle (although they are drawn on the memDC, this is
|
||||
// needed to erase it):
|
||||
m_llist->InvalidateUpdateRect();
|
||||
m_llist->DrawCursor(*m_memDC,
|
||||
m_HaveFocus && IsEditable(), // draw a thick
|
||||
// cursor for editable windows with focus
|
||||
offset);
|
||||
|
||||
// Now copy everything to the screen:
|
||||
#if 0
|
||||
// This somehow doesn't work, but even the following bit with the
|
||||
// whole rect at once is still a bit broken I think.
|
||||
wxRegionIterator ri ( GetUpdateRegion() );
|
||||
if(ri)
|
||||
while(ri)
|
||||
{
|
||||
WXLO_DEBUG(("UpdateRegion: %ld,%ld, %ld,%ld",
|
||||
ri.GetX(),ri.GetY(),ri.GetW(),ri.GetH()));
|
||||
dc.Blit(x0+ri.GetX(),y0+ri.GetY(),ri.GetW(),ri.GetH(),
|
||||
m_memDC,ri.GetX(),ri.GetY(),wxCOPY,FALSE);
|
||||
ri++;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
// FIXME: Trying to copy only the changed parts, but it does not seem
|
||||
// to work:
|
||||
// x0 = updateRect->x; y0 = updateRect->y;
|
||||
// if(updateRect->height < y1)
|
||||
// y1 = updateRect->height;
|
||||
// y1 += WXLO_YOFFSET; //FIXME might not be needed
|
||||
dc.Blit(x0,y0,x1,y1,m_memDC,0,0,wxCOPY,FALSE);
|
||||
}
|
||||
|
||||
ResetDirty();
|
||||
m_ScrollToCursor = false;
|
||||
}
|
||||
|
||||
// change the range and position of scrollbars
|
||||
void
|
||||
wxLayoutWindow::ResizeScrollbars(bool exact)
|
||||
{
|
||||
wxPoint max = m_llist->GetSize();
|
||||
|
||||
if(max.x > m_maxx || max.y > m_maxy
|
||||
|| max.x > m_maxx-WXLO_ROFFSET || max.y > m_maxy-WXLO_BOFFSET
|
||||
|| exact)
|
||||
{
|
||||
if(! exact)
|
||||
{
|
||||
// add an extra bit to the sizes to avoid future updates
|
||||
max.x = max.x+WXLO_ROFFSET;
|
||||
max.y = max.y+WXLO_BOFFSET;
|
||||
}
|
||||
ViewStart(&m_ViewStartX, &m_ViewStartY);
|
||||
SetScrollbars(10, 20, max.x/10+1,max.y/20+1,m_ViewStartX,m_ViewStartY,true);
|
||||
m_maxx = max.x; m_maxy = max.y;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
wxLayoutWindow::Paste(void)
|
||||
{
|
||||
wxString text;
|
||||
// Read some text
|
||||
if (wxTheClipboard->Open())
|
||||
{
|
||||
wxTextDataObject data;
|
||||
if (wxTheClipboard->IsSupported( data.GetFormat() ))
|
||||
{
|
||||
wxTheClipboard->GetData(&data);
|
||||
text += data.GetText();
|
||||
}
|
||||
wxTheClipboard->Close();
|
||||
}
|
||||
#if 0
|
||||
/* My attempt to get the primary selection, but it does not
|
||||
work. :-( */
|
||||
if(text.Length() == 0)
|
||||
{
|
||||
wxTextCtrl tmp_tctrl(this,-1);
|
||||
tmp_tctrl.Paste();
|
||||
text += tmp_tctrl.GetValue();
|
||||
}
|
||||
#endif
|
||||
wxLayoutImportText( m_llist, text);
|
||||
}
|
||||
|
||||
bool
|
||||
wxLayoutWindow::Copy(void)
|
||||
{
|
||||
wxLayoutList *llist = m_llist->GetSelection();
|
||||
if(! llist)
|
||||
return FALSE;
|
||||
|
||||
wxString text;
|
||||
wxLayoutExportObject *export;
|
||||
wxLayoutExportStatus status(llist);
|
||||
while((export = wxLayoutExport( &status, WXLO_EXPORT_AS_TEXT)) != NULL)
|
||||
{
|
||||
if(export->type == WXLO_EXPORT_TEXT)
|
||||
text << *(export->content.text);
|
||||
delete export;
|
||||
}
|
||||
delete llist;
|
||||
|
||||
// Read some text
|
||||
if (wxTheClipboard->Open())
|
||||
{
|
||||
wxTextDataObject *data = new wxTextDataObject( text );
|
||||
bool rc = wxTheClipboard->SetData( data );
|
||||
wxTheClipboard->Close();
|
||||
return rc;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
wxMenu *
|
||||
wxLayoutWindow::MakeFormatMenu()
|
||||
{
|
||||
wxMenu *m = new wxMenu(_("Layout Menu"));
|
||||
|
||||
m->Append(WXLOWIN_MENU_LARGER ,_("&Larger"),_("Switch to larger font."), false);
|
||||
m->Append(WXLOWIN_MENU_SMALLER ,_("&Smaller"),_("Switch to smaller font."), false);
|
||||
m->AppendSeparator();
|
||||
m->Append(WXLOWIN_MENU_UNDERLINE_ON, _("&Underline on"),_("Activate underline mode."), false);
|
||||
m->Append(WXLOWIN_MENU_UNDERLINE_OFF,_("&Underline off"),_("Deactivate underline mode."), false);
|
||||
m->Append(WXLOWIN_MENU_BOLD_ON ,_("&Bold on"),_("Activate bold mode."), false);
|
||||
m->Append(WXLOWIN_MENU_BOLD_OFF ,_("&Bold off"),_("Deactivate bold mode."), false);
|
||||
m->Append(WXLOWIN_MENU_ITALICS_ON ,_("&Italics on"),_("Activate italics mode."), false);
|
||||
m->Append(WXLOWIN_MENU_ITALICS_OFF ,_("&Italics off"),_("Deactivate italics mode."), false);
|
||||
m->AppendSeparator();
|
||||
m->Append(WXLOWIN_MENU_ROMAN ,_("&Roman"),_("Switch to roman font."), false);
|
||||
m->Append(WXLOWIN_MENU_TYPEWRITER,_("&Typewriter"),_("Switch to typewriter font."), false);
|
||||
m->Append(WXLOWIN_MENU_SANSSERIF ,_("&Sans Serif"),_("Switch to sans serif font."), false);
|
||||
return m;
|
||||
}
|
||||
|
||||
void wxLayoutWindow::OnMenu(wxCommandEvent& event)
|
||||
{
|
||||
switch (event.GetId())
|
||||
{
|
||||
case WXLOWIN_MENU_LARGER:
|
||||
m_llist->SetFontLarger(); break;
|
||||
case WXLOWIN_MENU_SMALLER:
|
||||
m_llist->SetFontSmaller(); break;
|
||||
case WXLOWIN_MENU_UNDERLINE_ON:
|
||||
m_llist->SetFontUnderline(true); break;
|
||||
case WXLOWIN_MENU_UNDERLINE_OFF:
|
||||
m_llist->SetFontUnderline(false); break;
|
||||
case WXLOWIN_MENU_BOLD_ON:
|
||||
m_llist->SetFontWeight(wxBOLD); break;
|
||||
case WXLOWIN_MENU_BOLD_OFF:
|
||||
m_llist->SetFontWeight(wxNORMAL); break;
|
||||
case WXLOWIN_MENU_ITALICS_ON:
|
||||
m_llist->SetFontStyle(wxITALIC); break;
|
||||
case WXLOWIN_MENU_ITALICS_OFF:
|
||||
m_llist->SetFontStyle(wxNORMAL); break;
|
||||
case WXLOWIN_MENU_ROMAN:
|
||||
m_llist->SetFontFamily(wxROMAN); break;
|
||||
case WXLOWIN_MENU_TYPEWRITER:
|
||||
m_llist->SetFontFamily(wxFIXED); break;
|
||||
case WXLOWIN_MENU_SANSSERIF:
|
||||
m_llist->SetFontFamily(wxSWISS); break;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
wxLayoutWindow::OnSetFocus(wxFocusEvent &ev)
|
||||
{
|
||||
m_HaveFocus = true;
|
||||
//FIXME: need argument DoPaint(); // to repaint the cursor
|
||||
}
|
||||
|
||||
void
|
||||
wxLayoutWindow::OnKillFocus(wxFocusEvent &ev)
|
||||
{
|
||||
m_HaveFocus = false;
|
||||
//FIXME: need argument DoPaint(); // to repaint the cursor
|
||||
}
|
210
user/wxLayout/wxlwindow.h
Normal file
@@ -0,0 +1,210 @@
|
||||
/*-*- c++ -*-********************************************************
|
||||
* wxLwindow.h : a scrolled Window for displaying/entering rich text*
|
||||
* *
|
||||
* (C) 1998,1999 by Karsten Ball<6C>der (Ballueder@usa.net) *
|
||||
* *
|
||||
* $Id$
|
||||
*******************************************************************/
|
||||
#ifndef WXLWINDOW_H
|
||||
#define WXLWINDOW_H
|
||||
|
||||
#ifdef __GNUG__
|
||||
# pragma interface "wxlwindow.h"
|
||||
#endif
|
||||
|
||||
#ifndef USE_PCH
|
||||
# include <wx/wx.h>
|
||||
#endif
|
||||
|
||||
#include "wxllist.h"
|
||||
|
||||
#ifndef WXLOWIN_MENU_FIRST
|
||||
# define WXLOWIN_MENU_FIRST 12000
|
||||
#endif
|
||||
|
||||
enum
|
||||
{
|
||||
WXLOWIN_MENU_LARGER = WXLOWIN_MENU_FIRST,
|
||||
WXLOWIN_MENU_SMALLER,
|
||||
WXLOWIN_MENU_UNDERLINE_ON,
|
||||
WXLOWIN_MENU_UNDERLINE_OFF,
|
||||
WXLOWIN_MENU_BOLD_ON,
|
||||
WXLOWIN_MENU_BOLD_OFF,
|
||||
WXLOWIN_MENU_ITALICS_ON,
|
||||
WXLOWIN_MENU_ITALICS_OFF,
|
||||
WXLOWIN_MENU_ROMAN,
|
||||
WXLOWIN_MENU_TYPEWRITER,
|
||||
WXLOWIN_MENU_SANSSERIF,
|
||||
WXLOWIN_MENU_RCLICK,
|
||||
WXLOWIN_MENU_LCLICK,
|
||||
WXLOWIN_MENU_DBLCLICK,
|
||||
WXLOWIN_MENU_MOUSEMOVE,
|
||||
WXLOWIN_MENU_LAST = WXLOWIN_MENU_MOUSEMOVE
|
||||
};
|
||||
|
||||
/**
|
||||
This class is a rich text editing widget.
|
||||
*/
|
||||
class wxLayoutWindow : public wxScrolledWindow
|
||||
{
|
||||
public:
|
||||
/** Constructor.
|
||||
@param parent parent window to display this panel in
|
||||
*/
|
||||
wxLayoutWindow(wxWindow *parent);
|
||||
|
||||
/// Destructor.
|
||||
virtual ~wxLayoutWindow();
|
||||
|
||||
/**@name Editing functionality */
|
||||
//@{
|
||||
/// Clears the window and sets default parameters.
|
||||
void Clear(int family = wxROMAN,
|
||||
int size=12,
|
||||
int style=wxNORMAL,
|
||||
int weight=wxNORMAL,
|
||||
int underline=0,
|
||||
wxColour *fg=NULL,
|
||||
wxColour *bg=NULL)
|
||||
{
|
||||
GetLayoutList()->Clear(family,size,style,weight,underline,fg,bg);
|
||||
SetBackgroundColour(GetLayoutList()->GetDefaults()->GetBGColour());
|
||||
ResizeScrollbars(true);
|
||||
SetDirty();
|
||||
SetModified(false);
|
||||
wxRect r;
|
||||
int w,h;
|
||||
r.x = r.y = 0; GetSize(&w,&h);
|
||||
r.width = w;
|
||||
r.height = h;
|
||||
DoPaint(&r);
|
||||
}
|
||||
/** Sets a background image, only used on screen, not on printouts.
|
||||
@param bitmap a pointer to a wxBitmap or NULL to remove it
|
||||
*/
|
||||
void SetBackgroundBitmap(wxBitmap *bitmap = NULL)
|
||||
{
|
||||
if(m_BGbitmap) delete m_BGbitmap;
|
||||
m_BGbitmap = bitmap;
|
||||
}
|
||||
/// Enable or disable editing, i.e. processing of keystrokes.
|
||||
void SetEditable(bool toggle) { m_Editable = toggle; }
|
||||
/// Query whether list can be edited by user.
|
||||
bool IsEditable(void) const { return m_Editable; }
|
||||
/// Pastes text from clipboard.
|
||||
void Paste(void);
|
||||
/// Copies selection to clipboard.
|
||||
bool Copy(void);
|
||||
|
||||
//@}
|
||||
|
||||
void EnablePopup(bool enable = true) { m_DoPopupMenu = enable; }
|
||||
|
||||
/** Sets the wrap margin.
|
||||
@param margin set this to 0 to disable it
|
||||
*/
|
||||
void SetWrapMargin(CoordType margin) { m_WrapMargin = margin; }
|
||||
|
||||
/** Redraws the window.
|
||||
Internally, this stores the parameter and calls a refresh on
|
||||
wxMSW, draws directly on wxGTK.
|
||||
*/
|
||||
void DoPaint(const wxRect *updateRect);
|
||||
|
||||
#ifdef __WXMSW__
|
||||
virtual long MSWGetDlgCode();
|
||||
#endif //MSW
|
||||
|
||||
/// if exact == false, assume 50% extra size for the future
|
||||
void ResizeScrollbars(bool exact = false); // don't change this to true!
|
||||
|
||||
/// if the flag is true, we send events when user clicks on embedded objects
|
||||
inline void SetMouseTracking(bool doIt = true) { m_doSendEvents = doIt; }
|
||||
|
||||
/* Returns a pointer to the wxLayoutList object.
|
||||
@return the list
|
||||
*/
|
||||
wxLayoutList * GetLayoutList(void) { return m_llist; }
|
||||
|
||||
/**@name Callbacks */
|
||||
//@{
|
||||
void OnPaint(wxPaintEvent &event);
|
||||
void OnChar(wxKeyEvent& event);
|
||||
void OnKeyUp(wxKeyEvent& event);
|
||||
void OnMenu(wxCommandEvent& event);
|
||||
void OnLeftMouseClick(wxMouseEvent& event) { OnMouse(WXLOWIN_MENU_LCLICK, event); }
|
||||
void OnRightMouseClick(wxMouseEvent& event) { OnMouse(WXLOWIN_MENU_RCLICK, event); }
|
||||
void OnMouseDblClick(wxMouseEvent& event) { OnMouse(WXLOWIN_MENU_DBLCLICK, event); }
|
||||
void OnMouseMove(wxMouseEvent &event) { OnMouse(WXLOWIN_MENU_MOUSEMOVE, event) ; }
|
||||
void OnSetFocus(wxFocusEvent &ev);
|
||||
void OnKillFocus(wxFocusEvent &ev);
|
||||
//@}
|
||||
|
||||
/// Creates a wxMenu for use as a format popup.
|
||||
static wxMenu * MakeFormatMenu(void);
|
||||
/**@name Dirty flag handling for optimisations. */
|
||||
//@{
|
||||
/// Set dirty flag.
|
||||
void SetDirty(void) { m_Dirty = true; }
|
||||
/// Query whether window needs redrawing.
|
||||
bool IsDirty(void) const { return m_Dirty; }
|
||||
/// Reset dirty flag.
|
||||
void ResetDirty(void) { m_Dirty = false; }
|
||||
//@}
|
||||
/// Redraws the window, used by DoPaint() or OnPaint().
|
||||
void InternalPaint(const wxRect *updateRect);
|
||||
|
||||
/// Has list been modified/edited?
|
||||
bool IsModified(void) const { return m_Modified; }
|
||||
/// Mark list as modified or unchanged.
|
||||
void SetModified(bool modified = true) { m_Modified = modified; }
|
||||
|
||||
protected:
|
||||
/// generic function for mouse events processing
|
||||
void OnMouse(int eventId, wxMouseEvent& event);
|
||||
/// as the name says
|
||||
void ScrollToCursor(void);
|
||||
/// for sending events
|
||||
wxWindow *m_Parent;
|
||||
/// Shall we send events?
|
||||
bool m_doSendEvents;
|
||||
/// Where does the current view start?
|
||||
int m_ViewStartX; int m_ViewStartY;
|
||||
/// Do we currently have the focus?
|
||||
bool m_HaveFocus;
|
||||
/// do we handle clicks of the right mouse button?
|
||||
bool m_DoPopupMenu;
|
||||
/// Should InternalPaint() scroll to cursor.
|
||||
bool m_ScrollToCursor;
|
||||
/// Do we currently have a non-standard cursor?
|
||||
bool m_HandCursor;
|
||||
/// the menu
|
||||
wxMenu * m_PopupMenu;
|
||||
/// for derived classes, set when mouse is clicked
|
||||
wxPoint m_ClickPosition;
|
||||
/// for scrollbar calculations:
|
||||
int m_maxx;
|
||||
int m_maxy;
|
||||
int m_lineHeight;
|
||||
private:
|
||||
/// The layout list to be displayed.
|
||||
wxLayoutList *m_llist;
|
||||
/// Can user edit the window?
|
||||
bool m_Editable;
|
||||
/// Are we currently building a selection with the keyboard?
|
||||
bool m_Selecting;
|
||||
/// wrap margin
|
||||
CoordType m_WrapMargin;
|
||||
/// Is list dirty (for redraws, internal use)?
|
||||
bool m_Dirty;
|
||||
/// Has list been edited?
|
||||
bool m_Modified;
|
||||
wxMemoryDC *m_memDC;
|
||||
wxBitmap *m_bitmap;
|
||||
wxPoint m_bitmapSize;
|
||||
/// a pointer to a bitmap for the background
|
||||
wxBitmap *m_BGbitmap;
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
#endif
|
@@ -1,114 +0,0 @@
|
||||
*.pyc
|
||||
*.pyd
|
||||
*.pyo
|
||||
*.zip
|
||||
.cvsignore
|
||||
.emacs.desktop
|
||||
__init__.py
|
||||
__init__.py
|
||||
__init__.pyc
|
||||
__init__.pyc
|
||||
__init__.pyo
|
||||
__init__.pyo
|
||||
cmndlgs.py
|
||||
cmndlgs.py
|
||||
cmndlgs.pyc
|
||||
cmndlgs.pyc
|
||||
cmndlgs.pyo
|
||||
cmndlgs.pyo
|
||||
controls.py
|
||||
controls.py
|
||||
controls.pyc
|
||||
controls.pyc
|
||||
controls.pyo
|
||||
controls.pyo
|
||||
controls2.py
|
||||
controls2.py
|
||||
controls2.pyc
|
||||
controls2.pyc
|
||||
controls2.pyo
|
||||
controls2.pyo
|
||||
docs
|
||||
events.py
|
||||
events.py
|
||||
events.pyc
|
||||
events.pyc
|
||||
events.pyo
|
||||
events.pyo
|
||||
frames.py
|
||||
frames.py
|
||||
frames.pyc
|
||||
frames.pyc
|
||||
frames.pyo
|
||||
frames.pyo
|
||||
gdi.py
|
||||
gdi.py
|
||||
gdi.pyc
|
||||
gdi.pyc
|
||||
gdi.pyo
|
||||
gdi.pyo
|
||||
glcanvas.py
|
||||
glcanvas.pyc
|
||||
glcanvasc.ilk
|
||||
glcanvasc.pyd
|
||||
image.py
|
||||
image.pyc
|
||||
mdi.py
|
||||
mdi.py
|
||||
mdi.pyc
|
||||
mdi.pyc
|
||||
mdi.pyo
|
||||
mdi.pyo
|
||||
misc.py
|
||||
misc.py
|
||||
misc.pyc
|
||||
misc.pyc
|
||||
misc.pyo
|
||||
misc.pyo
|
||||
printfw.py
|
||||
stattool.py
|
||||
stattool.py
|
||||
stattool.pyc
|
||||
stattool.pyc
|
||||
stattool.pyo
|
||||
stattool.pyo
|
||||
utils.py
|
||||
utils.py
|
||||
utils.pyc
|
||||
utils.pyc
|
||||
utils.pyo
|
||||
utilsc.ilk
|
||||
utilsc.pyd
|
||||
windows.py
|
||||
windows.py
|
||||
windows.pyc
|
||||
windows.pyc
|
||||
windows.pyo
|
||||
windows.pyo
|
||||
windows2.py
|
||||
windows2.py
|
||||
windows2.pyc
|
||||
windows2.pyc
|
||||
windows2.pyo
|
||||
windows2.pyo
|
||||
windows3.py
|
||||
windows3.pyc
|
||||
windows3.pyo
|
||||
wx.py
|
||||
wx.py
|
||||
wx.pyc
|
||||
wx.pyc
|
||||
wx.pyo
|
||||
wxc.ilk
|
||||
wxc.pdb
|
||||
wxc.pyd
|
||||
wxp.py
|
||||
wxp.pyc
|
||||
wxp.pyo
|
||||
wxpc.ilk
|
||||
wxpc.pdb
|
||||
wxpc.pyd
|
||||
*.py
|
||||
*.pyc
|
||||
*.pyo
|
||||
*.pyd
|
@@ -1,318 +0,0 @@
|
||||
wxPython README
|
||||
---------------
|
||||
|
||||
Welcome to the wonderful world of wxPython!
|
||||
|
||||
Once you have installed the wxPython extension module, you can try it
|
||||
out by going to the [install dir]\wxPython\demo directory and typing:
|
||||
|
||||
python demo.py
|
||||
|
||||
There are also some other sample files there for you to play with and
|
||||
learn from.
|
||||
|
||||
If you selected to install the documentation then point your browser
|
||||
to [install dir]\wxPython\docs\index.htm and you will then be looking
|
||||
at the docs for wxWindows. For the most part you can use the C++ docs
|
||||
as most classes and methods are used identically. Where there are
|
||||
differences they are documented with a "wxPython Note."
|
||||
|
||||
On Win32 systems the binary self-installer creates a program group on
|
||||
the Start Menu that contains a link to running the demo and a link to
|
||||
the help file. To help you save disk space I'm now using Microsoft's
|
||||
HTML Help format. If your system doesn't know what to do with the help
|
||||
file, you can install the HTML Help Viewer as part of IE 4+, NT
|
||||
Service Pack 4+, or the HTML Workshop at
|
||||
|
||||
http://msdn.microsoft.com/workshop/author/htmlhelp/download.asp.
|
||||
|
||||
|
||||
|
||||
Getting Help
|
||||
------------
|
||||
|
||||
Since wxPython is a blending of multiple technologies, help comes from
|
||||
multiple sources. See the http://alldunn.com/wxPython for details on
|
||||
various sources of help, but probably the best source is the
|
||||
wxPython-users mail list. You can view the archive or subscribe by
|
||||
going to
|
||||
|
||||
http://starship.python.net/mailman/listinfo/wxpython-users
|
||||
|
||||
Or you can send mail directly to the list using this address:
|
||||
|
||||
wxpython-users@starship.python.net
|
||||
|
||||
----------------------------------------------------------------------
|
||||
|
||||
|
||||
What's new in 2.1b1
|
||||
--------------------
|
||||
Fixed wxComboBox.SetSelection so that it actually sets the selected
|
||||
item. (Actually just removed it from wxPython and let it default to
|
||||
wxChoice.SetSelection which was already doing the right thing.)
|
||||
|
||||
Added the Printing Framework.
|
||||
|
||||
Switched back to using the wxWindows DLL for the pre-built Win32
|
||||
version. The problem was needing to reinitialize static class info
|
||||
data after loading each extension module.
|
||||
|
||||
Lots of little tweaks and additions to reflect changes to various
|
||||
wxWindows classes.
|
||||
|
||||
Fixed a bug with attaching objects to tree items. Actually was a
|
||||
symptom of a larger problem with not obtaining the interpreter lock
|
||||
when doing any Py_DECREFs.
|
||||
|
||||
wxSizer and friends. Sizers are layout tools that manage a colection
|
||||
of windows and sizers. Different types of sizers apply different
|
||||
types of layout algorithms. You saw it here first! These classes are
|
||||
not even in the wxWindows C++ library yet!
|
||||
|
||||
|
||||
|
||||
What's new in 2.0b9
|
||||
-------------------
|
||||
Bug fix for ListCtrl in test4.py (Was a missing file... DSM!)
|
||||
|
||||
Bug fix for occassional GPF on Win32 systems upon termination of a
|
||||
wxPython application.
|
||||
|
||||
Added wxListBox.GetSelections returning selections as a Tuple.
|
||||
|
||||
Added a wxTreeItemData that is able to hold any Python object and be
|
||||
associated with items in a wxTreeCtrl. Added test pytree.py to show
|
||||
this feature off.
|
||||
|
||||
Added wxSafeYield function.
|
||||
|
||||
OpenGL Canvas can be optionally compiled in to wxPython.
|
||||
|
||||
Awesome new Demo Framework for showing off wxPython and for learning
|
||||
how it all works.
|
||||
|
||||
The pre-built Win32 version is no longer distributing the wxWindows
|
||||
DLL. It is statically linked with the wxWindows library instead.
|
||||
|
||||
Added a couple missing items from the docs.
|
||||
|
||||
Added wxImage, wxImageHandler, wxPNGHandler, wxJPEGHandler,
|
||||
wxGIFHandler and wxBMPHandler.
|
||||
|
||||
Added new methods to wxTextCtrl.
|
||||
|
||||
Fixed some problems with how SWIG was wrapping some wxTreeCtrl
|
||||
methods.
|
||||
|
||||
|
||||
|
||||
What's new in 2.0b8
|
||||
-------------------
|
||||
Support for using Python threads in wxPython apps.
|
||||
|
||||
Several missing methods from various classes.
|
||||
|
||||
Various bug fixes.
|
||||
|
||||
|
||||
|
||||
What's new in 2.0b7
|
||||
-------------------
|
||||
Added DLG_PNT and DLG_SZE convienience methods to wxWindow class.
|
||||
|
||||
Added missing constructor and other methods for wxMenuItem.
|
||||
|
||||
|
||||
|
||||
What's new in 2.0b6
|
||||
-------------------
|
||||
Just a quickie update to fix the self-installer to be compatible with
|
||||
Python 1.5.2b2's Registry settings.
|
||||
|
||||
|
||||
What's new in 2.0b5
|
||||
-------------------
|
||||
Well obviously the numbering scheme has changed. I did this to
|
||||
reflect the fact that this truly is the second major revision of
|
||||
wxPython, (well the third actually if you count the one I did for
|
||||
wxWindows 1.68 and then threw away...) and also that it is associated
|
||||
with the 2.0 version of wxWindows.
|
||||
|
||||
I have finally started documenting wxPython. There are several pages
|
||||
in the wxWindows documentation tree specifically about wxPython, and I
|
||||
have added notes within the class references about where and how wxPython
|
||||
diverges from wxWindows.
|
||||
|
||||
Added wxWindow_FromHWND(hWnd) for wxMSW to construct a wxWindow from a
|
||||
window handle. If you can get the window handle into the python code,
|
||||
it should just work... More news on this later.
|
||||
|
||||
Added wxImageList, wxToolTip.
|
||||
|
||||
Re-enabled wxConfig.DeleteAll() since it is reportedly fixed for the
|
||||
wxRegConfig class.
|
||||
|
||||
As usual, some bug fixes, tweaks, etc.
|
||||
|
||||
|
||||
|
||||
What's new in 0.5.3
|
||||
-------------------
|
||||
Added wxSashWindow, wxSashEvent, wxLayoutAlgorithm, etc.
|
||||
|
||||
Various cleanup, tweaks, minor additions, etc. to maintain
|
||||
compatibility with the current wxWindows.
|
||||
|
||||
|
||||
|
||||
What's new in 0.5.0
|
||||
-------------------
|
||||
Changed the import semantics from "from wxPython import *" to "from
|
||||
wxPython.wx import *" This is for people who are worried about
|
||||
namespace pollution, they can use "from wxPython import wx" and then
|
||||
prefix all the wxPython identifiers with "wx."
|
||||
|
||||
Added wxTaskbarIcon for wxMSW.
|
||||
|
||||
Made the events work for wxGrid.
|
||||
|
||||
Added wxConfig.
|
||||
|
||||
Added wxMiniFrame for wxGTK.
|
||||
|
||||
Changed many of the args and return values that were pointers to gdi
|
||||
objects to references to reflect changes in the wxWindows API.
|
||||
|
||||
Other assorted fixes and additions.
|
||||
|
||||
|
||||
|
||||
|
||||
What's new in 0.4.2
|
||||
-------------------
|
||||
|
||||
wxPython on wxGTK works!!! Both dynamic and static on Linux and
|
||||
static on Solaris have been tested. Many thanks go to Harm
|
||||
<H.v.d.Heijden@phys.tue.nl> for his astute detective work on tracking
|
||||
down a nasty DECREF bug. Okay so I have to confess that it was just a
|
||||
DSM (Dumb Stupid Mistake) on my part but it was nasty none the less
|
||||
because the behavior was so different on different platforms.
|
||||
|
||||
The dynamicly loaded module on Solaris is still segfaulting, so it
|
||||
must have been a different issue all along...
|
||||
|
||||
|
||||
|
||||
What's New in 0.4
|
||||
-----------------
|
||||
|
||||
1. Worked on wxGTK compatibility. It is partially working. On a
|
||||
Solaris/Sparc box wxPython is working but only when it is statically
|
||||
linked with the Python interpreter. When built as a dyamically loaded
|
||||
extension module, things start acting weirdly and it soon seg-faults.
|
||||
And on Linux both the statically linked and the dynamically linked
|
||||
version segfault shortly after starting up.
|
||||
|
||||
2. Added Toolbar, StatusBar and SplitterWindow classes.
|
||||
|
||||
3. Varioius bug fixes, enhancements, etc.
|
||||
|
||||
----------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
Build Instructions
|
||||
------------------
|
||||
I used SWIG (http://www.swig.org) to create the source code for the
|
||||
extension module. This enabled me to only have to deal with a small
|
||||
amount of code and only have to bother with the exceptional issues.
|
||||
SWIG takes care of the rest and generates all the repetative code for
|
||||
me. You don't need SWIG to build the extension module as all the
|
||||
generated C++ code is included under the src directory.
|
||||
|
||||
I added a few minor features to SWIG to control some of the code
|
||||
generation. If you want to playaround with this the patches are in
|
||||
wxPython/SWIG.patches and they should be applied to the 1.1p5 version
|
||||
of SWIG. These new patches are documented at
|
||||
http://starship.skyport.net/crew/robind/#swig, and they should also
|
||||
end up in the 1.2 version of SWIG.
|
||||
|
||||
wxPython is organized as a Python package. This means that the
|
||||
directory containing the results of the build process should be a
|
||||
subdirectory of a directory on the PYTHONPATH. (And preferably should
|
||||
be named wxPython.) You can control where the build process will dump
|
||||
wxPython by setting the TARGETDIR makefile variable. The default is
|
||||
$(WXWIN)/utils/wxPython, where this README.txt is located. If you
|
||||
leave it here then you should add $(WXWIN)/utils to your PYTHONPATH.
|
||||
However, you may prefer to use something that is already on your
|
||||
PYTHONPATH, such as the site-packages directory on Unix systems.
|
||||
|
||||
|
||||
Win32
|
||||
-----
|
||||
|
||||
1. Build wxWindows with wxUSE_RESOURCE_LOADING_IN_MSW set to 1 in
|
||||
include/wx/msw/setup.h so icons can be loaded dynamically. While
|
||||
there, make sure wxUSE_OWNER_DRAWN is also set to 1.
|
||||
|
||||
2. Change into the $(WXWIN)/utils/wxPython/src directory.
|
||||
|
||||
3. Edit makefile.vc and specify where your python installation is at.
|
||||
You may also want to fiddle with the TARGETDIR variable as described
|
||||
above.
|
||||
|
||||
4. Run nmake -f makefile.vc
|
||||
|
||||
5. If it builds successfully, congratulations! Move on to the next
|
||||
step. If not then you can try mailing me for help. Also, I will
|
||||
always have a pre-built win32 version of this extension module at
|
||||
http://alldunn.com/wxPython/.
|
||||
|
||||
6. Change to the $(WXWIN)/utils/wxPython/demo directory.
|
||||
|
||||
7. Try executing the demo program. For example:
|
||||
|
||||
python demo.py
|
||||
|
||||
To run it without requiring a console, you can use the pythonw.exe
|
||||
version of Python either from the command line or from a shortcut.
|
||||
|
||||
|
||||
|
||||
Unix
|
||||
----
|
||||
0. I configure wxWindows like this, YMMV:
|
||||
|
||||
./configure --with-gtk --without-shared --with-threads --without-unicode --with-libjpeg
|
||||
|
||||
|
||||
1. Change into the $(WXWIN)/utils/wxPython/src directory.
|
||||
|
||||
2. Edit Setup.in and ensure that the flags, directories, and toolkit
|
||||
options are correct. See the above commentary about TARGETDIR. There
|
||||
are a few sample Setup.in.[platform] files provided.
|
||||
|
||||
3. Run this command to generate a makefile:
|
||||
|
||||
make -f Makefile.pre.in boot
|
||||
|
||||
4. Run these commands to build and then install the wxPython extension
|
||||
module:
|
||||
|
||||
make
|
||||
make install
|
||||
|
||||
|
||||
5. Change to the $(WXWIN)/utils/wxPython/demo directory.
|
||||
|
||||
6. Try executing the demo program. For example:
|
||||
|
||||
python demo.py
|
||||
|
||||
----------------
|
||||
Robin Dunn
|
||||
robin@alldunn.com
|
||||
|
||||
|
||||
|
@@ -1,97 +0,0 @@
|
||||
*** swig.h.old Wed Feb 04 14:59:40 1998
|
||||
--- swig.h Fri Aug 28 14:46:32 1998
|
||||
***************
|
||||
*** 178,185 ****
|
||||
--- 178,211 ----
|
||||
char *firstkey();
|
||||
char *nextkey();
|
||||
};
|
||||
|
||||
+ // -------------------------------------------------------------------
|
||||
+ // Simple Vector class
|
||||
+ // User is responsible for deleting contents before deleteing Vector
|
||||
+ // -------------------------------------------------------------------
|
||||
+
|
||||
+ class Vector {
|
||||
+ public:
|
||||
+ Vector(size_t allocSize=8);
|
||||
+ ~Vector();
|
||||
+
|
||||
+ size_t size() { return m_size; }
|
||||
+ size_t count() { return m_count; }
|
||||
+ size_t append(void* object);
|
||||
+ size_t extend(size_t newSize);
|
||||
+
|
||||
+ void*& operator[] (size_t idx);
|
||||
+
|
||||
+ static void* s_nullPtr;
|
||||
+
|
||||
+ private:
|
||||
+ size_t m_size;
|
||||
+ size_t m_count;
|
||||
+ void** m_data;
|
||||
+ };
|
||||
+
|
||||
+
|
||||
/************************************************************************
|
||||
* class DataType
|
||||
*
|
||||
* Defines the basic datatypes supported by the translator.
|
||||
***************
|
||||
*** 684,691 ****
|
||||
--- 710,761 ----
|
||||
extern char *name_get(char *vname, int suppress=0);
|
||||
extern char *name_set(char *vname, int suppress=0);
|
||||
extern char *name_construct(char *classname, int suppress=0);
|
||||
extern char *name_destroy(char *classname, int suppress=0);
|
||||
+
|
||||
+ // ----------------------------------------------------------------------
|
||||
+ // class CPP_class
|
||||
+ //
|
||||
+ // Class for managing class members (internally)
|
||||
+ // ----------------------------------------------------------------------
|
||||
+
|
||||
+ class CPP_member;
|
||||
+
|
||||
+ class CPP_class {
|
||||
+ public:
|
||||
+ char *classname; // Real class name
|
||||
+ char *classrename; // New name of class (if applicable)
|
||||
+ char *classtype; // class type (struct, union, class)
|
||||
+ int strip; // Strip off class declarator
|
||||
+ int wextern; // Value of extern wrapper variable for this class
|
||||
+ int have_constructor; // Status bit indicating if we've seen a constructor
|
||||
+ int have_destructor; // Status bit indicating if a destructor has been seen
|
||||
+ int is_abstract; // Status bit indicating if this is an abstract class
|
||||
+ int generate_default; // Generate default constructors
|
||||
+ int objective_c; // Set if this is an objective C class
|
||||
+ int error; // Set if this class can't be generated
|
||||
+ int line; // Line number
|
||||
+ char **baseclass; // Base classes (if any)
|
||||
+ Hash *local; // Hash table for local types
|
||||
+ Hash *scope; // Local scope hash table
|
||||
+ DocEntry *de; // Documentation entry of class
|
||||
+ CPP_member *members; // Linked list of members
|
||||
+ CPP_class *next; // Next class
|
||||
+ static CPP_class *classlist; // List of all classes stored
|
||||
+
|
||||
+ Vector addPragmas;
|
||||
+
|
||||
+ CPP_class(char *name, char *ctype);
|
||||
+ void add_member(CPP_member *m);
|
||||
+ CPP_member *search_member(char *name);
|
||||
+ void inherit_decls(int mode);
|
||||
+ void emit_decls();
|
||||
+ static CPP_class *search(char *name);
|
||||
+ void create_default();
|
||||
+ static void create_all();
|
||||
+ };
|
||||
+
|
||||
+ extern CPP_class *current_class;
|
||||
|
||||
/***********************************************************************
|
||||
* -- Revision History
|
||||
* $Log$
|
||||
* Revision 1.1 1998/10/03 05:56:02 RD
|
||||
* *** empty log message ***
|
||||
*
|
@@ -1,136 +0,0 @@
|
||||
*** python.cxx.old Fri Jan 02 22:17:40 1998
|
||||
--- python.cxx Fri Aug 28 14:49:18 1998
|
||||
***************
|
||||
*** 1679,1684 ****
|
||||
--- 1679,1701 ----
|
||||
}
|
||||
}
|
||||
}
|
||||
+ } else if (strcmp(cmd, "addtomethod") == 0) {
|
||||
+ // parse value, expected to be in the form "methodName:line"
|
||||
+ char* txtptr = strchr(value, ':');
|
||||
+ if (txtptr) {
|
||||
+ // add name and line to a list in current_class
|
||||
+ *txtptr = 0;
|
||||
+ txtptr++;
|
||||
+ AddPragmaData* apData = new AddPragmaData(value, txtptr);
|
||||
+ current_class->addPragmas.append(apData);
|
||||
+
|
||||
+ } else {
|
||||
+ fprintf(stderr,"%s : Line %d. Malformed addtomethod pragma. Should be \"methodName:text\"\n",
|
||||
+ input_file, line_number);
|
||||
+ }
|
||||
+ } else if (strcmp(cmd, "addtoclass") == 0) {
|
||||
+ AddPragmaData* apData = new AddPragmaData("__class__", value);
|
||||
+ current_class->addPragmas.append(apData);
|
||||
} else {
|
||||
fprintf(stderr,"%s : Line %d. Unrecognized pragma.\n", input_file, line_number);
|
||||
}
|
||||
*** python.h.old Thu Jul 24 22:18:50 1997
|
||||
--- python.h Fri Aug 28 14:46:08 1998
|
||||
***************
|
||||
*** 185,191 ****
|
||||
--- 185,203 ----
|
||||
void cpp_class_decl(char *, char *,char *);
|
||||
void pragma(char *, char *, char *);
|
||||
void add_typedef(DataType *t, char *name);
|
||||
+
|
||||
+ void emitAddPragmas(String& output, char* name, char* spacing);
|
||||
};
|
||||
|
||||
#define PYSHADOW_MEMBER 0x2
|
||||
+
|
||||
+ struct AddPragmaData {
|
||||
+ String m_method;
|
||||
+ String m_text;
|
||||
+
|
||||
+ AddPragmaData(char* method, char* text)
|
||||
+ : m_method(method),
|
||||
+ m_text(text)
|
||||
+ {}
|
||||
+ };
|
||||
|
||||
*** pycpp.cxx.old Fri Jan 02 20:23:22 1998
|
||||
--- pycpp.cxx Fri Aug 28 16:01:46 1998
|
||||
***************
|
||||
*** 276,281 ****
|
||||
--- 276,282 ----
|
||||
}
|
||||
}
|
||||
// if ((t->type != T_VOID) || (t->is_pointer))
|
||||
+ emitAddPragmas(*pyclass, realname, tab8);
|
||||
*pyclass << tab8 << "return val\n";
|
||||
|
||||
// Change the usage string to reflect our shadow class
|
||||
***************
|
||||
*** 394,399 ****
|
||||
--- 395,401 ----
|
||||
}
|
||||
*construct << ")\n";
|
||||
*construct << tab8 << "self.thisown = 1\n";
|
||||
+ emitAddPragmas(*construct, "__init__", tab8);
|
||||
have_constructor = 1;
|
||||
} else {
|
||||
|
||||
***************
|
||||
*** 494,502 ****
|
||||
*pyclass << tab4 << "def __del__(self):\n"
|
||||
<< tab8 << "if self.thisown == 1 :\n"
|
||||
<< tab8 << tab4 << module << "." << name_destroy(realname) << "(self.this)\n";
|
||||
!
|
||||
have_destructor = 1;
|
||||
-
|
||||
if (doc_entry) {
|
||||
doc_entry->usage = "";
|
||||
doc_entry->usage << "del this";
|
||||
--- 496,503 ----
|
||||
*pyclass << tab4 << "def __del__(self):\n"
|
||||
<< tab8 << "if self.thisown == 1 :\n"
|
||||
<< tab8 << tab4 << module << "." << name_destroy(realname) << "(self.this)\n";
|
||||
! emitAddPragmas(*pyclass, "__del__", tab8);
|
||||
have_destructor = 1;
|
||||
if (doc_entry) {
|
||||
doc_entry->usage = "";
|
||||
doc_entry->usage << "del this";
|
||||
***************
|
||||
*** 552,557 ****
|
||||
--- 553,560 ----
|
||||
<< tab8 << "return \"<C " << class_name <<" instance>\"\n";
|
||||
|
||||
classes << repr;
|
||||
+ emitAddPragmas(classes, "__class__", tab4);
|
||||
+
|
||||
}
|
||||
|
||||
// Now build the real class with a normal constructor
|
||||
***************
|
||||
*** 747,752 ****
|
||||
--- 750,777 ----
|
||||
}
|
||||
}
|
||||
|
||||
+ // --------------------------------------------------------------------------------
|
||||
+ // PYTHON::emitAddPragmas(String& output, char* name, char* spacing);
|
||||
+ //
|
||||
+ // Search the current_class->addPragmas vector for any text belonging to name.
|
||||
+ // Append the text properly spcaed to the output string.
|
||||
+ //
|
||||
+ // --------------------------------------------------------------------------------
|
||||
+
|
||||
+ void PYTHON::emitAddPragmas(String& output, char* name, char* spacing)
|
||||
+ {
|
||||
+ AddPragmaData* apData;
|
||||
+ size_t count;
|
||||
+ int i;
|
||||
+
|
||||
+ count = current_class->addPragmas.count();
|
||||
+ for (i=0; i<count; i++) {
|
||||
+ apData = (AddPragmaData*)current_class->addPragmas[i];
|
||||
+ if (strcmp(apData->m_method, name) == 0) {
|
||||
+ output << spacing << apData->m_text << "\n";
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
|
||||
/*********************************************************************************
|
||||
*
|
@@ -1,499 +0,0 @@
|
||||
*** cplus.cxx.old Mon Feb 02 14:55:42 1998
|
||||
--- cplus.cxx Fri Aug 28 12:02:50 1998
|
||||
***************
|
||||
*** 581,612 ****
|
||||
// Class for managing class members (internally)
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
static char *inherit_base_class = 0;
|
||||
|
||||
- class CPP_class {
|
||||
- public:
|
||||
- char *classname; // Real class name
|
||||
- char *classrename; // New name of class (if applicable)
|
||||
- char *classtype; // class type (struct, union, class)
|
||||
- int strip; // Strip off class declarator
|
||||
- int wextern; // Value of extern wrapper variable for this class
|
||||
- int have_constructor; // Status bit indicating if we've seen a constructor
|
||||
- int have_destructor; // Status bit indicating if a destructor has been seen
|
||||
- int is_abstract; // Status bit indicating if this is an abstract class
|
||||
- int generate_default; // Generate default constructors
|
||||
- int objective_c; // Set if this is an objective C class
|
||||
- int error; // Set if this class can't be generated
|
||||
- int line; // Line number
|
||||
- char **baseclass; // Base classes (if any)
|
||||
- Hash *local; // Hash table for local types
|
||||
- Hash *scope; // Local scope hash table
|
||||
- DocEntry *de; // Documentation entry of class
|
||||
- CPP_member *members; // Linked list of members
|
||||
- CPP_class *next; // Next class
|
||||
- static CPP_class *classlist; // List of all classes stored
|
||||
|
||||
! CPP_class(char *name, char *ctype) {
|
||||
CPP_class *c;
|
||||
classname = copy_string(name);
|
||||
classtype = copy_string(ctype);
|
||||
classrename = 0;
|
||||
--- 581,593 ----
|
||||
// Class for managing class members (internally)
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
static char *inherit_base_class = 0;
|
||||
+ CPP_class *CPP_class::classlist = 0;
|
||||
+ CPP_class *current_class;
|
||||
|
||||
|
||||
! CPP_class::CPP_class(char *name, char *ctype) {
|
||||
CPP_class *c;
|
||||
classname = copy_string(name);
|
||||
classtype = copy_string(ctype);
|
||||
classrename = 0;
|
||||
***************
|
||||
*** 642,650 ****
|
||||
// ------------------------------------------------------------------------------
|
||||
// Add a new C++ member to this class
|
||||
// ------------------------------------------------------------------------------
|
||||
|
||||
! void add_member(CPP_member *m) {
|
||||
CPP_member *cm;
|
||||
|
||||
// Set base class where this was defined
|
||||
if (inherit_base_class)
|
||||
--- 623,631 ----
|
||||
// ------------------------------------------------------------------------------
|
||||
// Add a new C++ member to this class
|
||||
// ------------------------------------------------------------------------------
|
||||
|
||||
! void CPP_class::add_member(CPP_member *m) {
|
||||
CPP_member *cm;
|
||||
|
||||
// Set base class where this was defined
|
||||
if (inherit_base_class)
|
||||
***************
|
||||
*** 664,672 ****
|
||||
// ------------------------------------------------------------------------------
|
||||
// Search for a member with the given name. Returns the member on success, 0 on failure
|
||||
// ------------------------------------------------------------------------------
|
||||
|
||||
! CPP_member *search_member(char *name) {
|
||||
CPP_member *m;
|
||||
char *c;
|
||||
m = members;
|
||||
while (m) {
|
||||
--- 645,653 ----
|
||||
// ------------------------------------------------------------------------------
|
||||
// Search for a member with the given name. Returns the member on success, 0 on failure
|
||||
// ------------------------------------------------------------------------------
|
||||
|
||||
! CPP_member *CPP_class::search_member(char *name) {
|
||||
CPP_member *m;
|
||||
char *c;
|
||||
m = members;
|
||||
while (m) {
|
||||
***************
|
||||
*** 680,688 ****
|
||||
// ------------------------------------------------------------------------------
|
||||
// Inherit. Put all the declarations associated with this class into the current
|
||||
// ------------------------------------------------------------------------------
|
||||
|
||||
! void inherit_decls(int mode) {
|
||||
CPP_member *m;
|
||||
m = members;
|
||||
while (m) {
|
||||
inherit_base_class = m->base;
|
||||
--- 661,669 ----
|
||||
// ------------------------------------------------------------------------------
|
||||
// Inherit. Put all the declarations associated with this class into the current
|
||||
// ------------------------------------------------------------------------------
|
||||
|
||||
! void CPP_class::inherit_decls(int mode) {
|
||||
CPP_member *m;
|
||||
m = members;
|
||||
while (m) {
|
||||
inherit_base_class = m->base;
|
||||
***************
|
||||
*** 696,704 ****
|
||||
// ------------------------------------------------------------------------------
|
||||
// Emit all of the declarations associated with this class
|
||||
// ------------------------------------------------------------------------------
|
||||
|
||||
! void emit_decls() {
|
||||
CPP_member *m = members;
|
||||
int last_scope = name_scope(0);
|
||||
abstract = is_abstract;
|
||||
while (m) {
|
||||
--- 677,685 ----
|
||||
// ------------------------------------------------------------------------------
|
||||
// Emit all of the declarations associated with this class
|
||||
// ------------------------------------------------------------------------------
|
||||
|
||||
! void CPP_class::emit_decls() {
|
||||
CPP_member *m = members;
|
||||
int last_scope = name_scope(0);
|
||||
abstract = is_abstract;
|
||||
while (m) {
|
||||
***************
|
||||
*** 713,721 ****
|
||||
// ------------------------------------------------------------------------------
|
||||
// Search for a given class in the list
|
||||
// ------------------------------------------------------------------------------
|
||||
|
||||
! static CPP_class *search(char *name) {
|
||||
CPP_class *c;
|
||||
c = classlist;
|
||||
if (!name) return 0;
|
||||
while (c) {
|
||||
--- 694,702 ----
|
||||
// ------------------------------------------------------------------------------
|
||||
// Search for a given class in the list
|
||||
// ------------------------------------------------------------------------------
|
||||
|
||||
! CPP_class *CPP_class::search(char *name) {
|
||||
CPP_class *c;
|
||||
c = classlist;
|
||||
if (!name) return 0;
|
||||
while (c) {
|
||||
***************
|
||||
*** 729,737 ****
|
||||
// Add default constructors and destructors
|
||||
//
|
||||
// ------------------------------------------------------------------------------
|
||||
|
||||
! void create_default() {
|
||||
if (!generate_default) return;
|
||||
|
||||
// Try to generate a constructor if not available.
|
||||
|
||||
--- 710,718 ----
|
||||
// Add default constructors and destructors
|
||||
//
|
||||
// ------------------------------------------------------------------------------
|
||||
|
||||
! void CPP_class::create_default() {
|
||||
if (!generate_default) return;
|
||||
|
||||
// Try to generate a constructor if not available.
|
||||
|
||||
***************
|
||||
*** 751,764 ****
|
||||
// ------------------------------------------------------------------------------
|
||||
// Dump *all* of the classes saved out to the various
|
||||
// language modules (this does what cplus_close_class used to do)
|
||||
// ------------------------------------------------------------------------------
|
||||
- static void create_all();
|
||||
- };
|
||||
-
|
||||
- CPP_class *CPP_class::classlist = 0;
|
||||
- static CPP_class *current_class;
|
||||
-
|
||||
void CPP_class::create_all() {
|
||||
CPP_class *c;
|
||||
c = classlist;
|
||||
while (c) {
|
||||
--- 732,739 ----
|
||||
*** vector.cxx.old Fri Aug 28 14:23:16 1998
|
||||
--- vector.cxx Fri Aug 28 14:46:52 1998
|
||||
***************
|
||||
*** 0 ****
|
||||
--- 1,182 ----
|
||||
+
|
||||
+ /*******************************************************************************
|
||||
+ * Simplified Wrapper and Interface Generator (SWIG)
|
||||
+ *
|
||||
+ * Dave Beazley
|
||||
+ *
|
||||
+ * Department of Computer Science Theoretical Division (T-11)
|
||||
+ * University of Utah Los Alamos National Laboratory
|
||||
+ * Salt Lake City, Utah 84112 Los Alamos, New Mexico 87545
|
||||
+ * beazley@cs.utah.edu beazley@lanl.gov
|
||||
+ *
|
||||
+ * Copyright (c) 1995-1997
|
||||
+ * The University of Utah and the Regents of the University of California
|
||||
+ * All Rights Reserved
|
||||
+ *
|
||||
+ * Permission is hereby granted, without written agreement and without
|
||||
+ * license or royalty fees, to use, copy, modify, and distribute this
|
||||
+ * software and its documentation for any purpose, provided that
|
||||
+ * (1) The above copyright notice and the following two paragraphs
|
||||
+ * appear in all copies of the source code and (2) redistributions
|
||||
+ * including binaries reproduces these notices in the supporting
|
||||
+ * documentation. Substantial modifications to this software may be
|
||||
+ * copyrighted by their authors and need not follow the licensing terms
|
||||
+ * described here, provided that the new terms are clearly indicated in
|
||||
+ * all files where they apply.
|
||||
+ *
|
||||
+ * IN NO EVENT SHALL THE AUTHOR, THE UNIVERSITY OF CALIFORNIA, THE
|
||||
+ * UNIVERSITY OF UTAH OR DISTRIBUTORS OF THIS SOFTWARE BE LIABLE TO ANY
|
||||
+ * PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
|
||||
+ * DAMAGES ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION,
|
||||
+ * EVEN IF THE AUTHORS OR ANY OF THE ABOVE PARTIES HAVE BEEN ADVISED OF
|
||||
+ * THE POSSIBILITY OF SUCH DAMAGE.
|
||||
+ *
|
||||
+ * THE AUTHOR, THE UNIVERSITY OF CALIFORNIA, AND THE UNIVERSITY OF UTAH
|
||||
+ * SPECIFICALLY DISCLAIM ANY WARRANTIES,INCLUDING, BUT NOT LIMITED TO,
|
||||
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
+ * PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND
|
||||
+ * THE AUTHORS AND DISTRIBUTORS HAVE NO OBLIGATION TO PROVIDE MAINTENANCE,
|
||||
+ * SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
|
||||
+ *
|
||||
+ *******************************************************************************/
|
||||
+
|
||||
+ #include "internal.h"
|
||||
+
|
||||
+ /*******************************************************************************
|
||||
+ * $Header$
|
||||
+ *
|
||||
+ * File : vector.cxx
|
||||
+ *
|
||||
+ * A very simple Vector class. Allways assumes that memory allocations are
|
||||
+ * successful. Should be made more robust...
|
||||
+ *
|
||||
+ *******************************************************************************/
|
||||
+
|
||||
+ void* Vector::s_nullPtr = NULL;
|
||||
+
|
||||
+ // -----------------------------------------------------------------------------
|
||||
+ // Vector::Vector(size_t allocSize = 8)
|
||||
+ //
|
||||
+ // Constructor. Creates a new Vector.
|
||||
+ //
|
||||
+ // Inputs : initial allocation size (optional)
|
||||
+ //
|
||||
+ // Output : New Vector object.
|
||||
+ //
|
||||
+ // Side Effects : None
|
||||
+ // -----------------------------------------------------------------------------
|
||||
+
|
||||
+ Vector::Vector(size_t allocSize)
|
||||
+ : m_size(allocSize),
|
||||
+ m_count(0),
|
||||
+ m_data(0)
|
||||
+ {
|
||||
+ if (m_size) {
|
||||
+ m_data = new void*[m_size];
|
||||
+ int i;
|
||||
+ for (i=0; i<m_size;i++)
|
||||
+ m_data[i] = 0;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ // -----------------------------------------------------------------------------
|
||||
+ // Vector::~Vector
|
||||
+ //
|
||||
+ // Destructor. Only cleans up the vector, not its contents!
|
||||
+ //
|
||||
+ // -----------------------------------------------------------------------------
|
||||
+
|
||||
+
|
||||
+ Vector::~Vector() {
|
||||
+ if (m_data) {
|
||||
+ delete [] m_data;
|
||||
+ }
|
||||
+
|
||||
+ m_data = 0;
|
||||
+ m_size = m_count = 0;
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+
|
||||
+ // -----------------------------------------------------------------------------
|
||||
+ // size_t Vector::extend(size_t newSize)
|
||||
+ //
|
||||
+ // Extends the vector to at least newSize length. Won't do anything if newSize
|
||||
+ // is smaller than the current size of the vector.
|
||||
+ //
|
||||
+ // Returns the new allocated size.
|
||||
+ //
|
||||
+ // -----------------------------------------------------------------------------
|
||||
+
|
||||
+ #define GRANULARITY 16
|
||||
+
|
||||
+ size_t Vector::extend(size_t newSize) {
|
||||
+
|
||||
+ if (newSize > m_size) {
|
||||
+ newSize = newSize + (GRANULARITY - (newSize % GRANULARITY));
|
||||
+
|
||||
+ void** temp = new void*[newSize];
|
||||
+ memcpy(temp, m_data, m_size*sizeof(void*));
|
||||
+
|
||||
+ int i;
|
||||
+ for (i=m_size; i<newSize; i++)
|
||||
+ temp[i] = 0;
|
||||
+
|
||||
+ delete [] m_data;
|
||||
+ m_data = temp;
|
||||
+ m_size = newSize;
|
||||
+ }
|
||||
+ return m_size;
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ // -----------------------------------------------------------------------------
|
||||
+ // Vector::append(void* object)
|
||||
+ //
|
||||
+ // Appends the object pointer to vector at index m_count. Increments m_count.
|
||||
+ // Returns the new count.
|
||||
+ // -----------------------------------------------------------------------------
|
||||
+
|
||||
+ size_t Vector::append(void* object) {
|
||||
+ if (m_count >= m_size) {
|
||||
+ extend(m_count + 1);
|
||||
+ }
|
||||
+
|
||||
+ m_data[m_count] = object;
|
||||
+ m_count += 1;
|
||||
+
|
||||
+ return m_count;
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ // -----------------------------------------------------------------------------
|
||||
+ // Vector::operator[] (size_t idx)
|
||||
+ //
|
||||
+ // Returns a reference to the void pointer at idx. If idx is beyond the range
|
||||
+ // of the vector, returns a reference to s_nullPtr.
|
||||
+ //
|
||||
+ // -----------------------------------------------------------------------------
|
||||
+
|
||||
+ void*& Vector::operator[] (size_t idx) {
|
||||
+ if (idx >= m_size) {
|
||||
+ s_nullPtr = 0;
|
||||
+ return s_nullPtr;
|
||||
+ }
|
||||
+
|
||||
+ return m_data[idx];
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ /***********************************************************************
|
||||
+ *
|
||||
+ * -- Revision History
|
||||
+ * $Log$
|
||||
+ * Revision 1.2 1999/04/30 03:28:35 RD
|
||||
+ * wxPython 2.0b9, first phase (win32)
|
||||
+ * Added gobs of stuff, see wxPython/README.txt for details
|
||||
+ *
|
||||
+ * Revision 1.1.4.1 1999/03/27 23:28:59 RD
|
||||
+ *
|
||||
+ * wxPython 2.0b8
|
||||
+ * Python thread support
|
||||
+ * various minor additions
|
||||
+ * various minor fixes
|
||||
+ *
|
||||
+ * Revision 1.1 1998/10/03 05:56:03 RD
|
||||
+ * *** empty log message ***
|
||||
+ *
|
||||
+ *
|
||||
+ ***********************************************************************/
|
||||
+
|
||||
+
|
||||
+
|
||||
+
|
||||
+
|
||||
+
|
||||
*** makefile.msc.old Mon Jun 23 15:15:32 1997
|
||||
--- makefile.msc Fri Aug 28 10:21:58 1998
|
||||
***************
|
||||
*** 33,50 ****
|
||||
# Normally, you shouldn't have to change anything below this point #
|
||||
########################################################################
|
||||
|
||||
LIBOBJS = main.obj scanner.obj symbol.obj include.obj types.obj parms.obj emit.obj newdoc.obj ascii.obj \
|
||||
! html.obj latex.obj cplus.obj lang.obj hash.obj sstring.obj wrapfunc.obj getopt.obj comment.obj typemap.obj naming.obj
|
||||
|
||||
LIBSRCS = main.cxx scanner.cxx symbol.cxx include.cxx types.cxx parms.cxx emit.cxx \
|
||||
! newdoc.cxx ascii.cxx html.cxx latex.cxx cplus.cxx lang.cxx hash.cxx \
|
||||
sstring.cxx wrapfunc.cxx getopt.cxx comment.cxx typemap.cxx naming.cxx
|
||||
|
||||
LIBHEADERS = internal.h ../Include/swig.h latex.h ascii.h html.h nodoc.h
|
||||
LIBNAME = ..\libswig.lib
|
||||
INCLUDE = -I../Include -I$(STD_INC)
|
||||
! CFLAGS = -Zi -nologo -DSWIG_LIB="\"$(SWIG_LIB)\"" -DSWIG_CC="\"$(CC)\"" -DMSDOS -DSTDC_HEADERS=1 -DHAVE_LIBDL=1 $(SWIG_OPTS)
|
||||
LD_FLAGS = -VERBOSE
|
||||
|
||||
|
||||
#
|
||||
--- 33,50 ----
|
||||
# Normally, you shouldn't have to change anything below this point #
|
||||
########################################################################
|
||||
|
||||
LIBOBJS = main.obj scanner.obj symbol.obj include.obj types.obj parms.obj emit.obj newdoc.obj ascii.obj \
|
||||
! html.obj latex.obj cplus.obj lang.obj hash.obj vector.obj sstring.obj wrapfunc.obj getopt.obj comment.obj typemap.obj naming.obj
|
||||
|
||||
LIBSRCS = main.cxx scanner.cxx symbol.cxx include.cxx types.cxx parms.cxx emit.cxx \
|
||||
! newdoc.cxx ascii.cxx html.cxx latex.cxx cplus.cxx lang.cxx hash.cxx vector.cxx \
|
||||
sstring.cxx wrapfunc.cxx getopt.cxx comment.cxx typemap.cxx naming.cxx
|
||||
|
||||
LIBHEADERS = internal.h ../Include/swig.h latex.h ascii.h html.h nodoc.h
|
||||
LIBNAME = ..\libswig.lib
|
||||
INCLUDE = -I../Include -I$(STD_INC)
|
||||
! CFLAGS = -Zi -nologo -DSWIG_LIB="\"$(SWIG_LIB)\"" -DSWIG_CC="\"$(CC)\"" -DMSDOS -DSTDC_HEADERS=1 -DHAVE_LIBDL=1 $(SWIG_OPTS) $(OTHERFLAGS)
|
||||
LD_FLAGS = -VERBOSE
|
||||
|
||||
|
||||
#
|
||||
*** makefile.bc.old Sun Jan 04 12:49:24 1998
|
||||
--- makefile.bc Fri Aug 28 14:42:58 1998
|
||||
***************
|
||||
*** 34,47 ****
|
||||
########################################################################
|
||||
|
||||
LIBOBJS = main.obj scanner.obj symbol.obj include.obj types.obj parms.obj \
|
||||
emit.obj newdoc.obj ascii.obj \
|
||||
! html.obj latex.obj cplus.obj lang.obj hash.obj sstring.obj \
|
||||
wrapfunc.obj getopt.obj comment.obj typemap.obj naming.obj
|
||||
|
||||
LIBSRCS = main.cxx scanner.cxx symbol.cxx include.cxx types.cxx parms.cxx \
|
||||
emit.cxx newdoc.cxx ascii.cxx html.cxx latex.cxx cplus.cxx lang.cxx hash.cxx \
|
||||
! sstring.cxx wrapfunc.cxx getopt.cxx comment.cxx typemap.cxx naming.cxx
|
||||
|
||||
LIBHEADERS = internal.h ../Include/swig.h latex.h ascii.h html.h nodoc.h
|
||||
LIBNAME = ..\libswig.lib
|
||||
INCLUDE = -I../Include -I$(STD_INC)
|
||||
--- 34,47 ----
|
||||
########################################################################
|
||||
|
||||
LIBOBJS = main.obj scanner.obj symbol.obj include.obj types.obj parms.obj \
|
||||
emit.obj newdoc.obj ascii.obj \
|
||||
! html.obj latex.obj cplus.obj lang.obj hash.obj vector.obj sstring.obj \
|
||||
wrapfunc.obj getopt.obj comment.obj typemap.obj naming.obj
|
||||
|
||||
LIBSRCS = main.cxx scanner.cxx symbol.cxx include.cxx types.cxx parms.cxx \
|
||||
emit.cxx newdoc.cxx ascii.cxx html.cxx latex.cxx cplus.cxx lang.cxx hash.cxx \
|
||||
! vector.cxx sstring.cxx wrapfunc.cxx getopt.cxx comment.cxx typemap.cxx naming.cxx
|
||||
|
||||
LIBHEADERS = internal.h ../Include/swig.h latex.h ascii.h html.h nodoc.h
|
||||
LIBNAME = ..\libswig.lib
|
||||
INCLUDE = -I../Include -I$(STD_INC)
|
||||
*** Makefile.in.old Wed May 28 22:56:56 1997
|
||||
--- Makefile.in Fri Aug 28 14:43:36 1998
|
||||
***************
|
||||
*** 51,63 ****
|
||||
# Normally, you shouldn't have to change anything below this point #
|
||||
########################################################################
|
||||
|
||||
LIBOBJS = main.o scanner.o symbol.o include.o types.o parms.o emit.o newdoc.o ascii.o \
|
||||
! html.o latex.o cplus.o lang.o hash.o sstring.o wrapfunc.o getopt.o comment.o \
|
||||
typemap.o naming.o
|
||||
|
||||
LIBSRCS = main.cxx scanner.cxx symbol.cxx include.cxx types.cxx parms.cxx emit.cxx \
|
||||
! newdoc.cxx ascii.cxx html.cxx latex.cxx cplus.cxx lang.cxx hash.cxx \
|
||||
sstring.cxx wrapfunc.cxx getopt.cxx comment.cxx typemap.cxx naming.cxx
|
||||
|
||||
LIBHEADERS = internal.h ../Include/swig.h latex.h ascii.h html.h nodoc.h
|
||||
LIB = ../libswig.a
|
||||
--- 51,63 ----
|
||||
# Normally, you shouldn't have to change anything below this point #
|
||||
########################################################################
|
||||
|
||||
LIBOBJS = main.o scanner.o symbol.o include.o types.o parms.o emit.o newdoc.o ascii.o \
|
||||
! html.o latex.o cplus.o lang.o hash.o vector.o sstring.o wrapfunc.o getopt.o comment.o \
|
||||
typemap.o naming.o
|
||||
|
||||
LIBSRCS = main.cxx scanner.cxx symbol.cxx include.cxx types.cxx parms.cxx emit.cxx \
|
||||
! newdoc.cxx ascii.cxx html.cxx latex.cxx cplus.cxx lang.cxx hash.cxx vector.cxx \
|
||||
sstring.cxx wrapfunc.cxx getopt.cxx comment.cxx typemap.cxx naming.cxx
|
||||
|
||||
LIBHEADERS = internal.h ../Include/swig.h latex.h ascii.h html.h nodoc.h
|
||||
LIB = ../libswig.a
|
@@ -1,5 +0,0 @@
|
||||
*.pyc
|
||||
.emacs.desktop
|
||||
hangman_dict.txt
|
||||
setup.bat
|
||||
tmphtml.txt
|
@@ -1,25 +0,0 @@
|
||||
#!/bin/env python
|
||||
#----------------------------------------------------------------------------
|
||||
# Name: ColorPanel.py
|
||||
# Purpose: Testing lots of stuff, controls, window types, etc.
|
||||
#
|
||||
# Author: Robin Dunn & Gary Dumer
|
||||
#
|
||||
# Created:
|
||||
# RCS-ID: $Id$
|
||||
# Copyright: (c) 1998 by Total Control Software
|
||||
# Licence: wxWindows license
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
from wxPython.wx import *
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
||||
class ColoredPanel(wxWindow):
|
||||
def __init__(self, parent, color):
|
||||
wxWindow.__init__(self, parent, -1,
|
||||
wxDefaultPosition, wxDefaultSize, wxRAISED_BORDER)
|
||||
self.SetBackgroundColour(color)
|
||||
|
||||
#---------------------------------------------------------------------------
|
@@ -1,123 +0,0 @@
|
||||
#!/bin/env python
|
||||
#----------------------------------------------------------------------------
|
||||
# Name: DialogUnits.py
|
||||
# Purpose: A minimal wxPython program that is a bit smarter than test1.
|
||||
#
|
||||
# Author: Robin Dunn
|
||||
#
|
||||
# Created: A long time ago, in a galaxy far, far away...
|
||||
# RCS-ID: $Id$
|
||||
# Copyright: (c) 1998 by Total Control Software
|
||||
# Licence: wxWindows license
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
|
||||
## import all of the wxPython GUI package
|
||||
from wxPython.wx import *
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
## Create a new frame class, derived from the wxPython Frame.
|
||||
class MyFrame(wxFrame):
|
||||
|
||||
def __init__(self, parent, id, title):
|
||||
# First, call the base class' __init__ method to create the frame
|
||||
wxFrame.__init__(self, parent, id, title,
|
||||
wxPoint(100, 100), wxSize(160, 100))
|
||||
|
||||
# Associate some events with methods of this class
|
||||
EVT_SIZE(self, self.OnSize)
|
||||
EVT_MOVE(self, self.OnMove)
|
||||
|
||||
# Add a panel and some controls to display the size and position
|
||||
panel = wxPanel(self, -1)
|
||||
wxStaticText(panel, -1, "Size:",
|
||||
wxDLG_PNT(panel, wxPoint(4, 4)), wxDefaultSize)
|
||||
wxStaticText(panel, -1, "Pos:",
|
||||
wxDLG_PNT(panel, wxPoint(4, 16)), wxDefaultSize)
|
||||
self.sizeCtrl = wxTextCtrl(panel, -1, "",
|
||||
wxDLG_PNT(panel, wxPoint(24, 4)),
|
||||
wxDLG_SZE(panel, wxSize(36, -1)),
|
||||
wxTE_READONLY)
|
||||
|
||||
self.posCtrl = wxTextCtrl(panel, -1, "",
|
||||
wxDLG_PNT(panel, wxPoint(24, 16)),
|
||||
wxDLG_SZE(panel, wxSize(36, -1)),
|
||||
wxTE_READONLY)
|
||||
|
||||
|
||||
# This method is called automatically when the CLOSE event is
|
||||
# sent to this window
|
||||
def OnCloseWindow(self, event):
|
||||
# tell the window to kill itself
|
||||
self.Destroy()
|
||||
|
||||
|
||||
# This method is called by the System when the window is resized,
|
||||
# because of the association above.
|
||||
def OnSize(self, event):
|
||||
size = event.GetSize()
|
||||
self.sizeCtrl.SetValue("%s, %s" % (size.width, size.height))
|
||||
|
||||
# tell the event system to continue looking for an event handler,
|
||||
# so the default handler will get called.
|
||||
event.Skip()
|
||||
|
||||
# This method is called by the System when the window is moved,
|
||||
# because of the association above.
|
||||
def OnMove(self, event):
|
||||
pos = event.GetPosition()
|
||||
self.posCtrl.SetValue("%s, %s" % (pos.x, pos.y))
|
||||
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# if running standalone
|
||||
|
||||
if __name__ == "__main__":
|
||||
# Every wxWindows application must have a class derived from wxApp
|
||||
class MyApp(wxApp):
|
||||
|
||||
# wxWindows calls this method to initialize the application
|
||||
def OnInit(self):
|
||||
|
||||
# Create an instance of our customized Frame class
|
||||
frame = MyFrame(NULL, -1, "This is a test")
|
||||
frame.Show(true)
|
||||
|
||||
# Tell wxWindows that this is our main window
|
||||
self.SetTopWindow(frame)
|
||||
|
||||
# Return a success flag
|
||||
return true
|
||||
|
||||
|
||||
app = MyApp(0) # Create an instance of the application class
|
||||
app.MainLoop() # Tell it to start processing events
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# if running as part of the Demo Framework...
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
win = MyFrame(frame, -1, "This is a test")
|
||||
frame.otherWin = win
|
||||
win.Show(true)
|
||||
|
||||
|
||||
overview = """\
|
||||
A simple example that shows how to use Dialog Units.
|
||||
"""
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
#
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@@ -1,62 +0,0 @@
|
||||
|
||||
from wxPython.wx import *
|
||||
from wxPython.lib.layoutf import Layoutf
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
class TestLayoutf(wxPanel):
|
||||
def __init__(self, parent):
|
||||
wxPanel.__init__(self, parent, -1)
|
||||
|
||||
self.SetAutoLayout(true)
|
||||
EVT_BUTTON(self, 100, self.OnButton)
|
||||
|
||||
self.panelA = wxWindow(self, -1, wxPyDefaultPosition, wxPyDefaultSize, wxSIMPLE_BORDER)
|
||||
self.panelA.SetBackgroundColour(wxBLUE)
|
||||
self.panelA.SetConstraints(Layoutf('t=t10#1;l=l10#1;b=b10#1;r%r50#1',(self,)))
|
||||
|
||||
self.panelB = wxWindow(self, -1, wxPyDefaultPosition, wxPyDefaultSize, wxSIMPLE_BORDER)
|
||||
self.panelB.SetBackgroundColour(wxRED)
|
||||
self.panelB.SetConstraints(Layoutf('t=t10#1;r=r10#1;b%b30#1;l>10#2', (self,self.panelA)))
|
||||
|
||||
self.panelC = wxWindow(self, -1, wxPyDefaultPosition, wxPyDefaultSize, wxSIMPLE_BORDER)
|
||||
self.panelC.SetBackgroundColour(wxWHITE)
|
||||
self.panelC.SetConstraints(Layoutf('t_10#3;r=r10#1;b=b10#1;l>10#2', (self,self.panelA,self.panelB)))
|
||||
|
||||
b = wxButton(self.panelA, 100, ' Panel A ')
|
||||
b.SetConstraints(Layoutf('X=X#1;Y=Y#1;h*;w%w50#1', (self.panelA,)))
|
||||
|
||||
b = wxButton(self.panelB, 100, ' Panel B ')
|
||||
b.SetConstraints(Layoutf('t=t2#1;r=r4#1;h*;w*', (self.panelB,)))
|
||||
|
||||
self.panelD = wxWindow(self.panelC, -1, wxPyDefaultPosition, wxPyDefaultSize, wxSIMPLE_BORDER)
|
||||
self.panelD.SetBackgroundColour(wxGREEN)
|
||||
self.panelD.SetConstraints(Layoutf('b%h50#1;r%w50#1;h=h#2;w=w#2', (self.panelC, b)))
|
||||
|
||||
b = wxButton(self.panelC, 100, ' Panel C ')
|
||||
b.SetConstraints(Layoutf('t_#1;l>#1;h*;w*', (self.panelD,)))
|
||||
|
||||
wxStaticText(self.panelD, -1, "Panel D", wxPoint(4, 4)).SetBackgroundColour(wxGREEN)
|
||||
|
||||
def OnButton(self, event):
|
||||
wxBell()
|
||||
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
win = TestLayoutf(nb)
|
||||
return win
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
overview = Layoutf.__doc__
|
@@ -1,336 +0,0 @@
|
||||
#!/bin/env python
|
||||
#----------------------------------------------------------------------------
|
||||
# Name: Main.py
|
||||
# Purpose: Testing lots of stuff, controls, window types, etc.
|
||||
#
|
||||
# Author: Robin Dunn & Gary Dumer
|
||||
#
|
||||
# Created:
|
||||
# RCS-ID: $Id$
|
||||
# Copyright: (c) 1999 by Total Control Software
|
||||
# Licence: wxWindows license
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
import sys, os
|
||||
from wxPython.wx import *
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
||||
_treeList = [
|
||||
('Managed Windows', ['wxFrame', 'wxDialog', 'wxMiniFrame']),
|
||||
|
||||
('Miscellaneous Windows', ['wxGrid', 'wxSashWindow',
|
||||
'wxScrolledWindow', 'wxSplitterWindow',
|
||||
'wxStatusBar', 'wxToolBar', 'wxNotebook']),
|
||||
|
||||
('Common Dialogs', ['wxColourDialog', 'wxDirDialog', 'wxFileDialog',
|
||||
'wxSingleChoiceDialog', 'wxTextEntryDialog',
|
||||
'wxFontDialog', 'wxPageSetupDialog', 'wxPrintDialog',
|
||||
'wxMessageDialog', 'wxProgressDialog']),
|
||||
|
||||
('Controls', ['wxButton', 'wxCheckBox', 'wxCheckListBox', 'wxChoice',
|
||||
'wxComboBox', 'wxGauge', 'wxListBox', 'wxListCtrl', 'wxTextCtrl',
|
||||
'wxTreeCtrl', 'wxSpinButton', 'wxStaticText', 'wxStaticBitmap',
|
||||
'wxRadioBox', 'wxSlider']),
|
||||
|
||||
('Window Layout', ['wxLayoutConstraints', 'Sizers']),
|
||||
|
||||
('Miscellaneous', ['wxTimer', 'wxGLCanvas', 'DialogUnits', 'wxImage',
|
||||
'PrintFramework']),
|
||||
|
||||
('wxPython Library', ['Sizers', 'Layoutf', 'wxScrolledMessageDialog',
|
||||
'wxMultipleChoiceDialog', 'wxPlotCanvas']),
|
||||
|
||||
('Cool Contribs', ['pyTree', 'hangman', 'SlashDot']),
|
||||
|
||||
]
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
class wxPythonDemo(wxFrame):
|
||||
def __init__(self, parent, id, title):
|
||||
wxFrame.__init__(self, parent, -1, title,
|
||||
wxDefaultPosition, wxSize(700, 550))
|
||||
if wxPlatform == '__WXMSW__':
|
||||
self.icon = wxIcon('bitmaps/mondrian.ico', wxBITMAP_TYPE_ICO)
|
||||
self.SetIcon(self.icon)
|
||||
|
||||
self.otherWin = None
|
||||
EVT_IDLE(self, self.OnIdle)
|
||||
|
||||
self.Centre(wxBOTH)
|
||||
self.CreateStatusBar(1, wxST_SIZEGRIP)
|
||||
splitter = wxSplitterWindow(self, -1)
|
||||
splitter2 = wxSplitterWindow(splitter, -1)
|
||||
|
||||
# Prevent TreeCtrl from displaying all items after destruction
|
||||
self.dying = false
|
||||
|
||||
# Make a File menu
|
||||
self.mainmenu = wxMenuBar()
|
||||
menu = wxMenu()
|
||||
mID = NewId()
|
||||
menu.Append(mID, 'E&xit', 'Get the heck outta here!')
|
||||
EVT_MENU(self, mID, self.OnFileExit)
|
||||
self.mainmenu.Append(menu, '&File')
|
||||
|
||||
# Make a Help menu
|
||||
mID = NewId()
|
||||
menu = wxMenu()
|
||||
menu.Append(mID, '&About', 'wxPython RULES!!!')
|
||||
EVT_MENU(self, mID, self.OnHelpAbout)
|
||||
self.mainmenu.Append(menu, '&Help')
|
||||
self.SetMenuBar(self.mainmenu)
|
||||
|
||||
selectedDemo = None
|
||||
selectedDemoName = "Nada"
|
||||
if len(sys.argv) == 2:
|
||||
selectedDemoName = sys.argv[1]
|
||||
|
||||
# Create a TreeCtrl
|
||||
tID = NewId()
|
||||
self.tree = wxTreeCtrl(splitter, tID)
|
||||
root = self.tree.AddRoot("Overview")
|
||||
for item in _treeList:
|
||||
child = self.tree.AppendItem(root, item[0])
|
||||
for childItem in item[1]:
|
||||
theDemo = self.tree.AppendItem(child, childItem)
|
||||
if childItem == selectedDemoName:
|
||||
selectedDemo = theDemo
|
||||
|
||||
self.tree.Expand(root)
|
||||
EVT_TREE_ITEM_EXPANDED (self.tree, tID, self.OnItemExpanded)
|
||||
EVT_TREE_ITEM_COLLAPSED (self.tree, tID, self.OnItemCollapsed)
|
||||
EVT_TREE_SEL_CHANGED (self.tree, tID, self.OnSelChanged)
|
||||
|
||||
# Create a Notebook
|
||||
self.nb = wxNotebook(splitter2, -1)
|
||||
|
||||
# Set up a TextCtrl on the Overview Notebook page
|
||||
self.ovr = wxTextCtrl(self.nb, -1, '', wxDefaultPosition, wxDefaultSize,
|
||||
wxTE_MULTILINE|wxTE_READONLY)
|
||||
self.nb.AddPage(self.ovr, "Overview")
|
||||
|
||||
|
||||
# Set up a TextCtrl on the Demo Code Notebook page
|
||||
self.txt = wxTextCtrl(self.nb, -1, '', wxDefaultPosition, wxDefaultSize,
|
||||
wxTE_MULTILINE|wxTE_READONLY|wxHSCROLL)
|
||||
self.txt.SetFont(wxFont(9, wxMODERN, wxNORMAL, wxNORMAL, false))
|
||||
self.nb.AddPage(self.txt, "Demo Code")
|
||||
|
||||
|
||||
# Set up a log on the View Log Notebook page
|
||||
self.log = wxTextCtrl(splitter2, -1, '', wxDefaultPosition, wxDefaultSize,
|
||||
wxTE_MULTILINE|wxTE_READONLY|wxHSCROLL)
|
||||
(w, self.charHeight) = self.log.GetTextExtent('X')
|
||||
#self.WriteText('wxPython Demo Log:\n')
|
||||
|
||||
|
||||
# add the windows to the splitter and split it.
|
||||
splitter.SplitVertically(self.tree, splitter2)
|
||||
splitter.SetSashPosition(180, true)
|
||||
splitter.SetMinimumPaneSize(20)
|
||||
|
||||
splitter2.SplitHorizontally(self.nb, self.log)
|
||||
splitter2.SetSashPosition(360, true)
|
||||
splitter2.SetMinimumPaneSize(20)
|
||||
|
||||
# make our log window be stdout
|
||||
#sys.stdout = self
|
||||
|
||||
# select initial items
|
||||
self.nb.SetSelection(0)
|
||||
self.tree.SelectItem(root)
|
||||
if selectedDemo:
|
||||
self.tree.SelectItem(selectedDemo)
|
||||
self.tree.EnsureVisible(selectedDemo)
|
||||
|
||||
#---------------------------------------------
|
||||
def WriteText(self, text):
|
||||
self.log.WriteText(text)
|
||||
w, h = self.log.GetClientSizeTuple()
|
||||
numLines = h/self.charHeight
|
||||
x, y = self.log.PositionToXY(self.log.GetLastPosition())
|
||||
self.log.ShowPosition(self.log.XYToPosition(x, y-numLines+1))
|
||||
self.log.SetInsertionPointEnd()
|
||||
|
||||
def write(self, txt):
|
||||
self.WriteText(txt)
|
||||
|
||||
#---------------------------------------------
|
||||
def OnItemExpanded(self, event):
|
||||
item = event.GetItem()
|
||||
self.log.WriteText("OnItemExpanded: %s\n" % self.tree.GetItemText(item))
|
||||
|
||||
#---------------------------------------------
|
||||
def OnItemCollapsed(self, event):
|
||||
item = event.GetItem()
|
||||
self.log.WriteText("OnItemCollapsed: %s\n" % self.tree.GetItemText(item))
|
||||
|
||||
#---------------------------------------------
|
||||
def OnSelChanged(self, event):
|
||||
if self.dying:
|
||||
return
|
||||
|
||||
if self.nb.GetPageCount() == 3:
|
||||
if self.nb.GetSelection() == 2:
|
||||
self.nb.SetSelection(0)
|
||||
self.nb.DeletePage(2)
|
||||
|
||||
item = event.GetItem()
|
||||
itemText = self.tree.GetItemText(item)
|
||||
|
||||
if itemText == 'Overview':
|
||||
self.GetDemoFile('Main.py')
|
||||
self.SetOverview('Overview', overview)
|
||||
#self.nb.ResizeChildren();
|
||||
self.nb.Refresh();
|
||||
#wxYield()
|
||||
|
||||
else:
|
||||
if os.path.exists(itemText + '.py'):
|
||||
self.GetDemoFile(itemText + '.py')
|
||||
module = __import__(itemText, globals())
|
||||
self.SetOverview(itemText, module.overview)
|
||||
|
||||
# in case runTest is modal, make sure things look right...
|
||||
self.nb.Refresh();
|
||||
wxYield()
|
||||
|
||||
window = module.runTest(self, self.nb, self)
|
||||
if window:
|
||||
self.nb.AddPage(window, 'Demo')
|
||||
self.nb.SetSelection(2)
|
||||
self.nb.ResizeChildren();
|
||||
|
||||
else:
|
||||
self.ovr.Clear()
|
||||
self.txt.Clear()
|
||||
|
||||
|
||||
#---------------------------------------------
|
||||
# Get the Demo files
|
||||
def GetDemoFile(self, filename):
|
||||
self.txt.Clear()
|
||||
#if not self.txt.LoadFile(filename):
|
||||
# self.txt.WriteText("Cannot open %s file." % filename)
|
||||
try:
|
||||
self.txt.SetValue(open(filename).read())
|
||||
except IOException:
|
||||
self.txt.WriteText("Cannot open %s file." % filename)
|
||||
|
||||
|
||||
self.txt.SetInsertionPoint(0)
|
||||
self.txt.ShowPosition(0)
|
||||
|
||||
#---------------------------------------------
|
||||
def SetOverview(self, name, text):
|
||||
self.ovr.Clear()
|
||||
self.ovr.WriteText(text)
|
||||
self.nb.SetPageText(0, name)
|
||||
self.ovr.SetInsertionPoint(0)
|
||||
self.ovr.ShowPosition(0)
|
||||
|
||||
#---------------------------------------------
|
||||
# Menu methods
|
||||
def OnFileExit(self, event):
|
||||
self.Close()
|
||||
|
||||
|
||||
def OnHelpAbout(self, event):
|
||||
about = wxMessageDialog(self,
|
||||
"wxPython is a Python extension module that\n"
|
||||
"encapsulates the wxWindows GUI classes.\n\n"
|
||||
"This demo shows off some of the capabilities\n"
|
||||
"of wxPython.\n\n"
|
||||
" Developed by Robin Dunn",
|
||||
"About wxPython", wxOK)
|
||||
about.ShowModal()
|
||||
about.Destroy()
|
||||
|
||||
|
||||
#---------------------------------------------
|
||||
def OnCloseWindow(self, event):
|
||||
self.dying = true
|
||||
self.Destroy()
|
||||
|
||||
#---------------------------------------------
|
||||
def OnIdle(self, event):
|
||||
if self.otherWin:
|
||||
self.otherWin.Raise()
|
||||
self.otherWin = None
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
class MyApp(wxApp):
|
||||
def OnInit(self):
|
||||
wxImage_AddHandler(wxJPEGHandler())
|
||||
wxImage_AddHandler(wxPNGHandler())
|
||||
wxImage_AddHandler(wxGIFHandler())
|
||||
frame = wxPythonDemo(NULL, -1, "wxPython: (A Demonstration)")
|
||||
frame.Show(true)
|
||||
self.SetTopWindow(frame)
|
||||
return true
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
def main():
|
||||
app = MyApp(0)
|
||||
app.MainLoop()
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
overview = """\
|
||||
Python
|
||||
------------
|
||||
|
||||
Python is an interpreted, interactive, object-oriented programming language often compared to Tcl, Perl, Scheme, or Java.
|
||||
|
||||
Python combines remarkable power with very clear syntax. It has modules, classes, exceptions, very high level dynamic data types, and dynamic typing. There are interfaces to many system calls and libraries, and new built-in modules are easily written in C or C++. Python is also usable as an extension language for applications that need a programmable interface.
|
||||
|
||||
wxWindows
|
||||
--------------------
|
||||
|
||||
wxWindows is a free C++ framework designed to make cross-platform programming child's play. Well, almost. wxWindows 2 supports Windows 3.1/95/98/NT, Unix with GTK/Motif/Lesstif, with a Mac version underway. Other ports are under consideration.
|
||||
|
||||
wxWindows is a set of libraries that allows C++ applications to compile and run on several different types of computers, with minimal source code changes. There is one library per supported GUI (such as Motif, or Windows). As well as providing a common API (Application Programming Interface) for GUI functionality, it provides functionality for accessing some commonly-used operating system facilities, such as copying or deleting files. wxWindows is a 'framework' in the sense that it provides a lot of built-in functionality, which the application can use or replace as required, thus saving a great deal of coding effort. Basic data structures such as strings, linked lists and hash tables are also supported.
|
||||
|
||||
wxPython
|
||||
----------------
|
||||
|
||||
wxPython is a Python extension module that encapsulates the wxWindows GUI classes. Currently it is only available for the Win32 and GTK ports of wxWindows, but as soon as the other ports are brought up to the same level as Win32 and GTK, it should be fairly trivial to enable wxPython to be used with the new GUI.
|
||||
|
||||
The wxPython extension module attempts to mirror the class heiarchy of wxWindows as closely as possible. This means that there is a wxFrame class in wxPython that looks, smells, tastes and acts almost the same as the wxFrame class in the C++ version. Unfortunately, because of differences in the languages, wxPython doesn't match wxWindows exactly, but the differences should be easy to absorb because they are natural to Python. For example, some methods that return multiple values via argument pointers in C++ will return a tuple of values in Python.
|
||||
|
||||
There is still much to be done for wxPython, many classes still need to be mirrored. Also, wxWindows is still somewhat of a moving target so it is a bit of an effort just keeping wxPython up to date. On the other hand, there are enough of the core classes completed that useful applications can be written.
|
||||
|
||||
wxPython is close enough to the C++ version that the majority of the wxPython documentation is actually just notes attached to the C++ documents that describe the places where wxPython is different. There is also a series of sample programs included, and a series of documentation pages that assist the programmer in getting started with wxPython.
|
||||
"""
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@@ -1,179 +0,0 @@
|
||||
|
||||
from wxPython.wx import *
|
||||
from wxPython.lib.sizers import *
|
||||
from wxScrolledWindow import MyCanvas
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
class MyPrintout(wxPrintout):
|
||||
def __init__(self, canvas, log):
|
||||
wxPrintout.__init__(self)
|
||||
self.canvas = canvas
|
||||
self.log = log
|
||||
|
||||
def OnBeginDocument(self, start, end):
|
||||
self.log.WriteText("wxPrintout.OnBeginDocument\n")
|
||||
return self.base_OnBeginDocument(start, end)
|
||||
|
||||
def OnEndDocument(self):
|
||||
self.log.WriteText("wxPrintout.OnEndDocument\n")
|
||||
self.base_OnEndDocument()
|
||||
|
||||
def OnBeginPrinting(self):
|
||||
self.log.WriteText("wxPrintout.OnBeginPrinting\n")
|
||||
self.base_OnBeginPrinting()
|
||||
|
||||
def OnEndPrinting(self):
|
||||
self.log.WriteText("wxPrintout.OnEndPrinting\n")
|
||||
self.base_OnEndPrinting()
|
||||
|
||||
def OnPreparePrinting(self):
|
||||
self.log.WriteText("wxPrintout.OnPreparePrinting\n")
|
||||
self.base_OnPreparePrinting()
|
||||
|
||||
def HasPage(self, page):
|
||||
self.log.WriteText("wxPrintout.HasPage\n")
|
||||
if page == 1:
|
||||
return true
|
||||
else:
|
||||
return false
|
||||
|
||||
def GetPageInfo(self):
|
||||
self.log.WriteText("wxPrintout.GetPageInfo\n")
|
||||
return (1, 1, 1, 1)
|
||||
|
||||
def OnPrintPage(self, page):
|
||||
self.log.WriteText("wxPrintout.OnPrintPage\n")
|
||||
dc = self.GetDC()
|
||||
|
||||
#-------------------------------------------
|
||||
# One possible method of setting scaling factors...
|
||||
|
||||
maxX = self.canvas.getWidth()
|
||||
maxY = self.canvas.getHeight()
|
||||
|
||||
# Let's have at least 50 device units margin
|
||||
marginX = 50
|
||||
marginY = 50
|
||||
|
||||
# Add the margin to the graphic size
|
||||
maxX = maxX + (2 * marginX)
|
||||
maxY = maxY + (2 * marginY)
|
||||
|
||||
# Get the size of the DC in pixels
|
||||
(w, h) = dc.GetSizeTuple()
|
||||
|
||||
# Calculate a suitable scaling factor
|
||||
scaleX = float(w) / maxX
|
||||
scaleY = float(h) / maxY
|
||||
|
||||
# Use x or y scaling factor, whichever fits on the DC
|
||||
actualScale = min(scaleX, scaleY)
|
||||
|
||||
# Calculate the position on the DC for centring the graphic
|
||||
posX = (w - (self.canvas.getWidth() * actualScale)) / 2.0
|
||||
posY = (h - (self.canvas.getHeight() * actualScale)) / 2.0
|
||||
|
||||
# Set the scale and origin
|
||||
dc.SetUserScale(actualScale, actualScale)
|
||||
dc.SetDeviceOrigin(int(posX), int(posY))
|
||||
|
||||
#-------------------------------------------
|
||||
|
||||
self.canvas.DoDrawing(dc)
|
||||
return true
|
||||
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
|
||||
class TestPrintPanel(wxPanel):
|
||||
def __init__(self, parent, frame, log):
|
||||
wxPanel.__init__(self, parent, -1)
|
||||
self.log = log
|
||||
self.frame = frame
|
||||
|
||||
|
||||
self.printData = wxPrintData()
|
||||
self.printData.SetPaperId(wxPAPER_LETTER)
|
||||
|
||||
self.box = box.wxBoxSizer(wxVERTICAL)
|
||||
self.canvas = MyCanvas(self)
|
||||
self.box.Add(self.canvas, 1)
|
||||
|
||||
subbox = wxBoxSizer(wxHORIZONTAL)
|
||||
btn = wxButton(self, 1201, "Print Setup")
|
||||
EVT_BUTTON(self, 1201, self.OnPrintSetup)
|
||||
subbox.Add(btn, 1)
|
||||
|
||||
btn = wxButton(self, 1202, "Print Preview")
|
||||
EVT_BUTTON(self, 1202, self.OnPrintPreview)
|
||||
subbox.Add(btn, 1)
|
||||
|
||||
btn = wxButton(self, 1203, "Print")
|
||||
EVT_BUTTON(self, 1203, self.OnDoPrint)
|
||||
subbox.Add(btn, 1)
|
||||
|
||||
self.box.Add(subbox)
|
||||
|
||||
|
||||
|
||||
def OnSize(self, event):
|
||||
size = self.GetClientSize()
|
||||
self.box.Layout(size)
|
||||
|
||||
def OnPrintSetup(self, event):
|
||||
printerDialog = wxPrintDialog(self)
|
||||
printerDialog.GetPrintDialogData().SetPrintData(self.printData)
|
||||
printerDialog.GetPrintDialogData().SetSetupDialog(true)
|
||||
printerDialog.ShowModal();
|
||||
self.printData = printerDialog.GetPrintDialogData().GetPrintData()
|
||||
printerDialog.Destroy()
|
||||
|
||||
|
||||
def OnPrintPreview(self, event):
|
||||
self.log.WriteText("OnPrintPreview\n")
|
||||
printout = MyPrintout(self.canvas, self.log)
|
||||
printout2 = MyPrintout(self.canvas, self.log)
|
||||
self.preview = wxPrintPreview(printout, printout2, self.printData)
|
||||
if not self.preview.Ok():
|
||||
self.log.WriteText("Houston, we have a problem...\n")
|
||||
return
|
||||
|
||||
frame = wxPreviewFrame(self.preview, self.frame, "This is a print preview")
|
||||
|
||||
frame.Initialize()
|
||||
frame.SetPosition(self.frame.GetPosition())
|
||||
frame.SetSize(self.frame.GetSize())
|
||||
frame.Show(true)
|
||||
|
||||
|
||||
|
||||
def OnDoPrint(self, event):
|
||||
pdd = wxPrintDialogData()
|
||||
pdd.SetPrintData(self.printData)
|
||||
printer = wxPrinter(pdd)
|
||||
printout = MyPrintout(self.canvas, self.log)
|
||||
if not printer.Print(self.frame, printout):
|
||||
wxMessageBox("There was a problem printing.\nPerhaps your current printer is not set correctly?", "Printing", wxOK)
|
||||
else:
|
||||
self.printData = printer.GetPrintDialogData().GetPrintData()
|
||||
printout.Destroy()
|
||||
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
win = TestPrintPanel(nb, frame, log)
|
||||
return win
|
||||
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
overview = """\
|
||||
"""
|
||||
|
@@ -1,7 +0,0 @@
|
||||
To run the main demo in this directory, execute demo.py. In other
|
||||
words, one of the following commands should do it:
|
||||
|
||||
demo.py
|
||||
python demo.py
|
||||
pythonw demo.py
|
||||
|
@@ -1,370 +0,0 @@
|
||||
#----------------------------------------------------------------------
|
||||
# sizer test code
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
from wxPython.wx import *
|
||||
from wxPython.lib.sizers import *
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
def makeSimpleBox1(win):
|
||||
box = wxBoxSizer(wxHORIZONTAL)
|
||||
box.Add(wxButton(win, 1010, "one"), 0)
|
||||
box.Add(wxButton(win, 1010, "two"), 0)
|
||||
box.Add(wxButton(win, 1010, "three"), 0)
|
||||
box.Add(wxButton(win, 1010, "four"), 0)
|
||||
|
||||
return box
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
def makeSimpleBox2(win):
|
||||
box = wxBoxSizer(wxVERTICAL)
|
||||
box.Add(wxButton(win, 1010, "one"), 0)
|
||||
box.Add(wxButton(win, 1010, "two"), 0)
|
||||
box.Add(wxButton(win, 1010, "three"), 0)
|
||||
box.Add(wxButton(win, 1010, "four"), 0)
|
||||
|
||||
return box
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
def makeSimpleBox3(win):
|
||||
box = wxBoxSizer(wxHORIZONTAL)
|
||||
box.Add(wxButton(win, 1010, "one"), 0)
|
||||
box.Add(wxButton(win, 1010, "two"), 0)
|
||||
box.Add(wxButton(win, 1010, "three"), 0)
|
||||
box.Add(wxButton(win, 1010, "four"), 0)
|
||||
box.Add(wxButton(win, 1010, "five"), 1)
|
||||
|
||||
return box
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
def makeSimpleBox4(win):
|
||||
box = wxBoxSizer(wxHORIZONTAL)
|
||||
box.Add(wxButton(win, 1010, "one"), 0)
|
||||
box.Add(wxButton(win, 1010, "two"), 0)
|
||||
box.Add(wxButton(win, 1010, "three"), 1)
|
||||
box.Add(wxButton(win, 1010, "four"), 1)
|
||||
box.Add(wxButton(win, 1010, "five"), 1)
|
||||
|
||||
return box
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
def makeSimpleBox5(win):
|
||||
box = wxBoxSizer(wxHORIZONTAL)
|
||||
box.Add(wxButton(win, 1010, "one"), 0)
|
||||
box.Add(wxButton(win, 1010, "two"), 0)
|
||||
box.Add(wxButton(win, 1010, "three"), 3)
|
||||
box.Add(wxButton(win, 1010, "four"), 1)
|
||||
box.Add(wxButton(win, 1010, "five"), 1)
|
||||
|
||||
return box
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
def makeSimpleBox6(win):
|
||||
box = wxBoxSizer(wxHORIZONTAL, wxSize(250, 50))
|
||||
box.Add(wxButton(win, 1010, "10"), 10)
|
||||
box.Add(wxButton(win, 1010, "20"), 20)
|
||||
box.Add(wxButton(win, 1010, "30"), 30)
|
||||
box.Add(wxButton(win, 1010, "15"), 15)
|
||||
box.Add(wxButton(win, 1010, "5"), 5)
|
||||
|
||||
return box
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
def makeSimpleBorder1(win):
|
||||
bdr = wxBorderSizer(wxALL)
|
||||
btn = wxButton(win, 1010, "border")
|
||||
btn.SetSize(wxSize(80, 80))
|
||||
bdr.Add(btn, 15)
|
||||
|
||||
return bdr
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
def makeSimpleBorder2(win):
|
||||
bdr = wxBorderSizer(wxEAST | wxWEST)
|
||||
btn = wxButton(win, 1010, "border")
|
||||
btn.SetSize(wxSize(80, 80))
|
||||
bdr.Add(btn, 15)
|
||||
|
||||
return bdr
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
def makeSimpleBorder3(win):
|
||||
bdr = wxBorderSizer(wxNORTH | wxWEST)
|
||||
btn = wxButton(win, 1010, "border")
|
||||
btn.SetSize(wxSize(80, 80))
|
||||
bdr.Add(btn, 15)
|
||||
|
||||
return bdr
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
def makeBoxInBox(win):
|
||||
box = wxBoxSizer(wxVERTICAL)
|
||||
|
||||
btn = wxButton(win, 1010, "one")
|
||||
box.Add(btn)
|
||||
|
||||
box2 = wxBoxSizer(wxHORIZONTAL)
|
||||
btn = wxButton(win, 1010, "two")
|
||||
box2.Add(btn)
|
||||
btn = wxButton(win, 1010, "three")
|
||||
box2.Add(btn)
|
||||
btn = wxButton(win, 1010, "four")
|
||||
box2.Add(btn)
|
||||
btn = wxButton(win, 1010, "five")
|
||||
box2.Add(btn)
|
||||
|
||||
box3 = wxBoxSizer(wxVERTICAL)
|
||||
box3.AddMany([ (wxButton(win, 1010, "six"), 1),
|
||||
(wxButton(win, 1010, "seven"), 2),
|
||||
(wxButton(win, 1010, "eight"), 1),
|
||||
(wxButton(win, 1010, "nine"), 1),
|
||||
])
|
||||
|
||||
box2.Add(box3, 1)
|
||||
box.Add(box2, 1)
|
||||
|
||||
btn = wxButton(win, 1010, "ten")
|
||||
box.Add(btn)
|
||||
|
||||
return box
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
def makeBoxInBorder(win):
|
||||
bdr = wxBorderSizer(wxALL)
|
||||
box = makeSimpleBox3(win)
|
||||
bdr.Add(box, 15)
|
||||
|
||||
return bdr
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
def makeBorderInBox(win):
|
||||
insideBox = wxBoxSizer(wxHORIZONTAL)
|
||||
|
||||
box2 = wxBoxSizer(wxHORIZONTAL)
|
||||
box2.AddMany([ (wxButton(win, 1010, "one"), 0),
|
||||
(wxButton(win, 1010, "two"), 0),
|
||||
(wxButton(win, 1010, "three"), 0),
|
||||
(wxButton(win, 1010, "four"), 0),
|
||||
(wxButton(win, 1010, "five"), 0),
|
||||
])
|
||||
|
||||
insideBox.Add(box2, 0)
|
||||
|
||||
bdr = wxBorderSizer(wxALL)
|
||||
bdr.Add(wxButton(win, 1010, "border"), 20)
|
||||
insideBox.Add(bdr, 1)
|
||||
|
||||
box3 = wxBoxSizer(wxVERTICAL)
|
||||
box3.AddMany([ (wxButton(win, 1010, "six"), 1),
|
||||
(wxButton(win, 1010, "seven"), 2),
|
||||
(wxButton(win, 1010, "eight"), 1),
|
||||
(wxButton(win, 1010, "nine"), 1),
|
||||
])
|
||||
insideBox.Add(box3, 1)
|
||||
|
||||
outsideBox = wxBoxSizer(wxVERTICAL)
|
||||
outsideBox.Add(wxButton(win, 1010, "top"))
|
||||
outsideBox.Add(insideBox, 1)
|
||||
outsideBox.Add(wxButton(win, 1010, "bottom"))
|
||||
|
||||
return outsideBox
|
||||
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
theTests = [
|
||||
("Simple horizontal boxes", makeSimpleBox1,
|
||||
"This is a HORIZONTAL box sizer with four non-stretchable buttons held "
|
||||
"within it. Notice that the buttons are added and aligned in the horizontal "
|
||||
"dimension. Also notice that they are fixed size in the horizontal dimension, "
|
||||
"but will stretch vertically."
|
||||
),
|
||||
|
||||
("Simple vertical boxes", makeSimpleBox2,
|
||||
"Exactly the same as the previous sample but using a VERTICAL box sizer "
|
||||
"instead of a HORIZONTAL one."
|
||||
),
|
||||
|
||||
("Add a stretchable", makeSimpleBox3,
|
||||
"We've added one more button with the strechable flag turned on. Notice "
|
||||
"how it grows to fill the extra space in the otherwise fixed dimension."
|
||||
),
|
||||
|
||||
("More than one stretchable", makeSimpleBox4,
|
||||
"Here there are several items that are stretchable, they all divide up the "
|
||||
"extra space evenly."
|
||||
),
|
||||
|
||||
("Weighting factor", makeSimpleBox5,
|
||||
"This one shows more than one strechable, but one of them has a weighting "
|
||||
"factor so it gets more of the free space."
|
||||
),
|
||||
|
||||
# ("Percent Sizer", makeSimpleBox6,
|
||||
# "You can use the wxBoxSizer like a Percent Sizer. Just make sure that all "
|
||||
# "the weighting factors add up to 100!"
|
||||
# ),
|
||||
|
||||
("", None, ""),
|
||||
|
||||
("Simple border sizer", makeSimpleBorder1,
|
||||
"The wxBorderSizer leaves empty space around its contents. This one "
|
||||
"gives a border all the way around."
|
||||
),
|
||||
|
||||
("East and West border", makeSimpleBorder2,
|
||||
"You can pick and choose which sides have borders."
|
||||
),
|
||||
|
||||
("North and West border", makeSimpleBorder3,
|
||||
"You can pick and choose which sides have borders."
|
||||
),
|
||||
|
||||
("", None, ""),
|
||||
|
||||
("Boxes inside of boxes", makeBoxInBox,
|
||||
"This one shows nesting of boxes within boxes within boxes, using both "
|
||||
"orientations. Notice also that button seven has a greater weighting "
|
||||
"factor than its siblings."
|
||||
),
|
||||
|
||||
("Boxes inside a Border", makeBoxInBorder,
|
||||
"Sizers of different types can be nested withing each other as well. "
|
||||
"Here is a box sizer with several buttons embedded within a border sizer."
|
||||
),
|
||||
|
||||
("Border in a Box", makeBorderInBox,
|
||||
"Another nesting example. This one has Boxes and a Border inside another Box."
|
||||
),
|
||||
|
||||
]
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
class TestFrame(wxFrame):
|
||||
def __init__(self, parent, title, sizerFunc):
|
||||
wxFrame.__init__(self, parent, -1, title)
|
||||
EVT_BUTTON(self, 1010, self.OnButton)
|
||||
|
||||
self.sizer = sizerFunc(self)
|
||||
self.CreateStatusBar()
|
||||
self.SetStatusText("Resize this frame to see how the sizers respond...")
|
||||
self.sizer.FitWindow(self)
|
||||
|
||||
|
||||
def OnSize(self, event):
|
||||
size = self.GetClientSize()
|
||||
self.sizer.Layout(size)
|
||||
|
||||
def OnCloseWindow(self, event):
|
||||
self.MakeModal(false)
|
||||
self.Destroy()
|
||||
|
||||
def OnButton(self, event):
|
||||
self.Close(true)
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
class TestSelectionPanel(wxPanel):
|
||||
def __init__(self, parent, frame):
|
||||
wxPanel.__init__(self, parent, -1)
|
||||
self.frame = frame
|
||||
|
||||
self.list = wxListBox(self, 401,
|
||||
wxDLG_PNT(self, 10, 10), wxDLG_SZE(self, 100, 60),
|
||||
[])
|
||||
EVT_LISTBOX(self, 401, self.OnSelect)
|
||||
EVT_LISTBOX_DCLICK(self, 401, self.OnDClick)
|
||||
|
||||
wxButton(self, 402, "Try it!", wxDLG_PNT(self, 120, 10)).SetDefault()
|
||||
EVT_BUTTON(self, 402, self.OnDClick)
|
||||
|
||||
self.text = wxTextCtrl(self, -1, "",
|
||||
wxDLG_PNT(self, 10, 80),
|
||||
wxDLG_SZE(self, 200, 60),
|
||||
wxTE_MULTILINE | wxTE_READONLY)
|
||||
|
||||
for item in theTests:
|
||||
self.list.Append(item[0])
|
||||
|
||||
|
||||
|
||||
def OnSelect(self, event):
|
||||
pos = self.list.GetSelection()
|
||||
self.text.SetValue(theTests[pos][2])
|
||||
|
||||
|
||||
def OnDClick(self, event):
|
||||
pos = self.list.GetSelection()
|
||||
title = theTests[pos][0]
|
||||
func = theTests[pos][1]
|
||||
|
||||
if func:
|
||||
win = TestFrame(self, title, func)
|
||||
win.CentreOnParent(wxBOTH)
|
||||
win.Show(true)
|
||||
win.MakeModal(true)
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
win = TestSelectionPanel(nb, frame)
|
||||
return win
|
||||
|
||||
overview = wxSizer.__doc__ + '\n' + '-' * 80 + '\n' + \
|
||||
wxBoxSizer.__doc__ + '\n' + '-' * 80 + '\n' + \
|
||||
wxBorderSizer.__doc__
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
class MainFrame(wxFrame):
|
||||
def __init__(self):
|
||||
wxFrame.__init__(self, NULL, -1, "Testing...")
|
||||
|
||||
self.CreateStatusBar()
|
||||
mainmenu = wxMenuBar()
|
||||
menu = wxMenu()
|
||||
menu.Append(200, 'E&xit', 'Get the heck outta here!')
|
||||
mainmenu.Append(menu, "&File")
|
||||
self.SetMenuBar(mainmenu)
|
||||
EVT_MENU(self, 200, self.OnExit)
|
||||
self.panel = TestSelectionPanel(self)
|
||||
self.SetSize(wxSize(400, 380))
|
||||
|
||||
def OnCloseWindow(self, event):
|
||||
self.Destroy()
|
||||
|
||||
def OnExit(self, event):
|
||||
self.Close(true)
|
||||
|
||||
|
||||
class TestApp(wxApp):
|
||||
def OnInit(self):
|
||||
frame = MainFrame()
|
||||
frame.Show(true)
|
||||
self.SetTopWindow(frame)
|
||||
return true
|
||||
|
||||
app = TestApp(0)
|
||||
app.MainLoop()
|
||||
|
||||
|
||||
#----------------------------------------------------------------------
|
@@ -1,378 +0,0 @@
|
||||
#!/usr/bin/python
|
||||
"""This is SlashDot 1.2
|
||||
|
||||
It's the obligatory Slashdot.org headlines reader that
|
||||
any modern widget set/library must have in order to be taken
|
||||
seriously :-)
|
||||
|
||||
Usage is quite simple; wxSlash attempts to download the
|
||||
'ultramode.txt' file from http://slashdot.org, which
|
||||
contains the headlines in a computer friendly format. It
|
||||
then displays said headlines in a wxWindows list control.
|
||||
|
||||
You can read articles using either Python's html library
|
||||
or an external browser. Uncheck the 'browser->internal' menu
|
||||
item to use the latter option. Use the settings dialog box
|
||||
to set which external browser is started.
|
||||
|
||||
This code is available under the wxWindows license, see
|
||||
elsewhere. If you modify this code, be aware of the fact
|
||||
that slashdot.org's maintainer, CmdrTaco, explicitly asks
|
||||
'ultramode.txt' downloaders not to do this automatically
|
||||
more than twice per hour. If this feature is abused,
|
||||
CmdrTaco may remove the ultramode file completely and that
|
||||
will make a *lot* of people unhappy.
|
||||
|
||||
I want to thank Alex Shnitman whose slashes.pl
|
||||
(Perl/GTK) script gave me the idea for this applet.
|
||||
|
||||
Have fun with it,
|
||||
|
||||
Harm van der Heijden (H.v.d.Heijden@phys.tue.nl)
|
||||
"""
|
||||
|
||||
from wxPython.wx import *
|
||||
from httplib import HTTP
|
||||
from htmllib import HTMLParser
|
||||
import os
|
||||
import re
|
||||
import formatter
|
||||
|
||||
class HTMLTextView(wxFrame):
|
||||
def __init__(self, parent, id, title='HTMLTextView', url=None):
|
||||
wxFrame.__init__(self, parent, id, title, wxPyDefaultPosition,
|
||||
wxSize(600,400))
|
||||
|
||||
self.mainmenu = wxMenuBar()
|
||||
|
||||
menu = wxMenu()
|
||||
menu.Append(201, '&Open URL...', 'Open URL')
|
||||
EVT_MENU(self, 201, self.OnFileOpen)
|
||||
menu.Append(209, 'E&xit', 'Exit viewer')
|
||||
EVT_MENU(self, 209, self.OnFileExit)
|
||||
|
||||
self.mainmenu.Append(menu, '&File')
|
||||
self.SetMenuBar(self.mainmenu)
|
||||
self.CreateStatusBar(1)
|
||||
|
||||
self.text = wxTextCtrl(self, -1, "", wxPyDefaultPosition,
|
||||
wxPyDefaultSize, wxTE_MULTILINE | wxTE_READONLY)
|
||||
|
||||
if (url):
|
||||
self.OpenURL(url)
|
||||
|
||||
def logprint(self, x):
|
||||
self.SetStatusText(x)
|
||||
|
||||
def OpenURL(self, url):
|
||||
self.url = url
|
||||
m = re.match('file:(\S+)\s*', url)
|
||||
if m:
|
||||
f = open(m.groups()[0],'r')
|
||||
else:
|
||||
m = re.match('http://([^/]+)(/\S*)\s*', url)
|
||||
if m:
|
||||
host = m.groups()[0]
|
||||
path = m.groups()[1]
|
||||
else:
|
||||
m = re.match('http://(\S+)\s*', url)
|
||||
if not m:
|
||||
# Invalid URL
|
||||
self.logprint("Invalid or unsupported URL: %s" % (url))
|
||||
return
|
||||
host = m.groups()[0]
|
||||
path = ''
|
||||
f = RetrieveAsFile(host,path,self.logprint)
|
||||
if not f:
|
||||
self.logprint("Could not open %s" % (url))
|
||||
return
|
||||
self.logprint("Receiving data...")
|
||||
data = f.read()
|
||||
tmp = open('tmphtml.txt','w')
|
||||
fmt = formatter.AbstractFormatter(formatter.DumbWriter(tmp))
|
||||
p = HTMLParser(fmt)
|
||||
self.logprint("Parsing data...")
|
||||
p.feed(data)
|
||||
p.close()
|
||||
tmp.close()
|
||||
tmp = open('tmphtml.txt', 'r')
|
||||
self.text.SetValue(tmp.read())
|
||||
self.SetTitle(url)
|
||||
self.logprint(url)
|
||||
|
||||
def OnFileOpen(self, event):
|
||||
dlg = wxTextEntryDialog(self, "Enter URL to open:", "")
|
||||
if dlg.ShowModal() == wxID_OK:
|
||||
url = dlg.GetValue()
|
||||
else:
|
||||
url = None
|
||||
if url:
|
||||
self.OpenURL(url)
|
||||
|
||||
def OnFileExit(self, event):
|
||||
self.Close()
|
||||
|
||||
def OnCloseWindow(self, event):
|
||||
self.Destroy()
|
||||
|
||||
|
||||
def ParseSlashdot(f):
|
||||
art_sep = re.compile('%%\r?\n')
|
||||
line_sep = re.compile('\r?\n')
|
||||
data = f.read()
|
||||
list = art_sep.split(data)
|
||||
art_list = []
|
||||
for i in range(1,len(list)-1):
|
||||
art_list.append(line_sep.split(list[i]))
|
||||
return art_list
|
||||
|
||||
def myprint(x):
|
||||
print x
|
||||
|
||||
def RetrieveAsFile(host, path='', logprint = myprint):
|
||||
try:
|
||||
h = HTTP(host)
|
||||
except:
|
||||
logprint("Failed to create HTTP connection to %s... is the network available?" % (host))
|
||||
return None
|
||||
h.putrequest('GET',path)
|
||||
h.putheader('Accept','text/html')
|
||||
h.putheader('Accept','text/plain')
|
||||
h.endheaders()
|
||||
errcode, errmsg, headers = h.getreply()
|
||||
if errcode != 200:
|
||||
logprint("HTTP error code %d: %s" % (errcode, errmsg))
|
||||
return None
|
||||
f = h.getfile()
|
||||
# f = open('/home/harm/ultramode.txt','r')
|
||||
return f
|
||||
|
||||
|
||||
class AppStatusBar(wxStatusBar):
|
||||
def __init__(self, parent):
|
||||
wxStatusBar.__init__(self,parent, -1)
|
||||
self.SetFieldsCount(2)
|
||||
self.SetStatusWidths([-1, 100])
|
||||
self.but = wxButton(self, 1001, "Refresh")
|
||||
EVT_BUTTON(self, 1001, parent.OnViewRefresh)
|
||||
self.OnSize(None)
|
||||
|
||||
def logprint(self,x):
|
||||
self.SetStatusText(x,0)
|
||||
|
||||
def OnSize(self, event):
|
||||
rect = self.GetFieldRect(1)
|
||||
self.but.SetPosition(wxPoint(rect.x+2, rect.y+2))
|
||||
self.but.SetSize(wxSize(rect.width-4, rect.height-4))
|
||||
|
||||
# This is a simple timer class to start a function after a short delay;
|
||||
class QuickTimer(wxTimer):
|
||||
def __init__(self, func, wait=100):
|
||||
wxTimer.__init__(self)
|
||||
self.callback = func
|
||||
self.Start(wait); # wait .1 second (.001 second doesn't work. why?)
|
||||
def Notify(self):
|
||||
self.Stop();
|
||||
apply(self.callback, ());
|
||||
|
||||
class AppFrame(wxFrame):
|
||||
def __init__(self, parent, id, title):
|
||||
wxFrame.__init__(self, parent, id, title, wxPyDefaultPosition,
|
||||
wxSize(650, 250))
|
||||
|
||||
# if the window manager closes the window:
|
||||
EVT_CLOSE(self, self.OnCloseWindow);
|
||||
|
||||
# Now Create the menu bar and items
|
||||
self.mainmenu = wxMenuBar()
|
||||
|
||||
menu = wxMenu()
|
||||
menu.Append(209, 'E&xit', 'Enough of this already!')
|
||||
EVT_MENU(self, 209, self.OnFileExit)
|
||||
self.mainmenu.Append(menu, '&File')
|
||||
menu = wxMenu()
|
||||
menu.Append(210, '&Refresh', 'Refresh headlines')
|
||||
EVT_MENU(self, 210, self.OnViewRefresh)
|
||||
menu.Append(211, '&Slashdot Index', 'View Slashdot index')
|
||||
EVT_MENU(self, 211, self.OnViewIndex)
|
||||
menu.Append(212, 'Selected &Article', 'View selected article')
|
||||
EVT_MENU(self, 212, self.OnViewArticle)
|
||||
self.mainmenu.Append(menu, '&View')
|
||||
menu = wxMenu()
|
||||
menu.Append(220, '&Internal', 'Use internal text browser',TRUE)
|
||||
menu.Check(220, true)
|
||||
self.UseInternal = 1;
|
||||
EVT_MENU(self, 220, self.OnBrowserInternal)
|
||||
menu.Append(222, '&Settings...', 'External browser Settings')
|
||||
EVT_MENU(self, 222, self.OnBrowserSettings)
|
||||
self.mainmenu.Append(menu, '&Browser')
|
||||
menu = wxMenu()
|
||||
menu.Append(230, '&About', 'Some documentation');
|
||||
EVT_MENU(self, 230, self.OnAbout)
|
||||
self.mainmenu.Append(menu, '&Help')
|
||||
|
||||
self.SetMenuBar(self.mainmenu)
|
||||
|
||||
if wxPlatform == '__WXGTK__':
|
||||
# I like lynx. Also Netscape 4.5 doesn't react to my cmdline opts
|
||||
self.BrowserSettings = "xterm -e lynx %s &"
|
||||
elif wxPlatform == '__WXMSW__':
|
||||
# netscape 4.x likes to hang out here...
|
||||
self.BrowserSettings = '\\progra~1\\Netscape\\Communicator\\Program\\netscape.exe %s'
|
||||
else:
|
||||
# a wild guess...
|
||||
self.BrowserSettings = 'netscape %s'
|
||||
|
||||
# A status bar to tell people what's happening
|
||||
self.sb = AppStatusBar(self)
|
||||
self.SetStatusBar(self.sb)
|
||||
|
||||
self.list = wxListCtrl(self, 1100)
|
||||
self.list.SetSingleStyle(wxLC_REPORT)
|
||||
self.list.InsertColumn(0, 'Subject')
|
||||
self.list.InsertColumn(1, 'Date')
|
||||
self.list.InsertColumn(2, 'Posted by')
|
||||
self.list.InsertColumn(3, 'Comments')
|
||||
self.list.SetColumnWidth(0, 300)
|
||||
self.list.SetColumnWidth(1, 150)
|
||||
self.list.SetColumnWidth(2, 100)
|
||||
self.list.SetColumnWidth(3, 100)
|
||||
|
||||
EVT_LIST_ITEM_SELECTED(self, 1100, self.OnItemSelected)
|
||||
EVT_LEFT_DCLICK(self.list, self.OnLeftDClick)
|
||||
|
||||
self.logprint("Connecting to slashdot... Please wait.")
|
||||
# wxYield doesn't yet work here. That's why we use a timer
|
||||
# to make sure that we see some GUI stuff before the slashdot
|
||||
# file is transfered.
|
||||
self.timer = QuickTimer(self.DoRefresh, 1000)
|
||||
|
||||
def logprint(self, x):
|
||||
self.sb.logprint(x)
|
||||
|
||||
def OnFileExit(self, event):
|
||||
self.Destroy()
|
||||
|
||||
def DoRefresh(self):
|
||||
f = RetrieveAsFile('slashdot.org','/ultramode.txt',self.sb.logprint)
|
||||
art_list = ParseSlashdot(f)
|
||||
self.list.DeleteAllItems()
|
||||
self.url = []
|
||||
self.current = -1
|
||||
i = 0;
|
||||
for article in art_list:
|
||||
self.list.InsertStringItem(i, article[0])
|
||||
self.list.SetStringItem(i, 1, article[2])
|
||||
self.list.SetStringItem(i, 2, article[3])
|
||||
self.list.SetStringItem(i, 3, article[6])
|
||||
self.url.append(article[1])
|
||||
i = i + 1
|
||||
self.logprint("File retrieved OK.")
|
||||
|
||||
def OnViewRefresh(self, event):
|
||||
self.logprint("Connecting to slashdot... Please wait.");
|
||||
wxYield()
|
||||
self.DoRefresh()
|
||||
|
||||
def DoViewIndex(self):
|
||||
if self.UseInternal:
|
||||
self.view = HTMLTextView(self, -1, 'slashdot.org',
|
||||
'http://slashdot.org')
|
||||
self.view.Show(true)
|
||||
else:
|
||||
self.logprint(self.BrowserSettings % ('http://slashdot.org'))
|
||||
#os.system(self.BrowserSettings % ('http://slashdot.org'))
|
||||
wxExecute(self.BrowserSettings % ('http://slashdot.org'))
|
||||
self.logprint("OK")
|
||||
|
||||
def OnViewIndex(self, event):
|
||||
self.logprint("Starting browser... Please wait.")
|
||||
wxYield()
|
||||
self.DoViewIndex()
|
||||
|
||||
def DoViewArticle(self):
|
||||
if self.current<0: return
|
||||
url = self.url[self.current]
|
||||
if self.UseInternal:
|
||||
self.view = HTMLTextView(self, -1, url, url)
|
||||
self.view.Show(true)
|
||||
else:
|
||||
self.logprint(self.BrowserSettings % (url))
|
||||
os.system(self.BrowserSettings % (url))
|
||||
self.logprint("OK")
|
||||
|
||||
def OnViewArticle(self, event):
|
||||
self.logprint("Starting browser... Please wait.")
|
||||
wxYield()
|
||||
self.DoViewArticle()
|
||||
|
||||
def OnBrowserInternal(self, event):
|
||||
if self.mainmenu.Checked(220):
|
||||
self.UseInternal = 1
|
||||
else:
|
||||
self.UseInternal = 0
|
||||
|
||||
def OnBrowserSettings(self, event):
|
||||
dlg = wxTextEntryDialog(self, "Enter command to view URL.\nUse %s as a placeholder for the URL.", "", self.BrowserSettings);
|
||||
if dlg.ShowModal() == wxID_OK:
|
||||
self.BrowserSettings = dlg.GetValue()
|
||||
|
||||
def OnAbout(self, event):
|
||||
dlg = wxMessageDialog(self, __doc__, "wxSlash", wxOK | wxICON_INFORMATION)
|
||||
dlg.ShowModal()
|
||||
|
||||
def OnItemSelected(self, event):
|
||||
self.current = event.m_itemIndex
|
||||
self.logprint("URL: %s" % (self.url[self.current]))
|
||||
|
||||
def OnLeftDClick(self, event):
|
||||
(x,y) = event.Position();
|
||||
# Actually, we should convert x,y to logical coords using
|
||||
# a dc, but only for a wxScrolledWindow widget.
|
||||
# Now wxGTK derives wxListCtrl from wxScrolledWindow,
|
||||
# and wxMSW from wxControl... So that doesn't work.
|
||||
#dc = wxClientDC(self.list)
|
||||
##self.list.PrepareDC(dc)
|
||||
#x = dc.DeviceToLogicalX( event.GetX() )
|
||||
#y = dc.DeviceToLogicalY( event.GetY() )
|
||||
id = self.list.HitTest(wxPoint(x,y))
|
||||
#print "Double click at %d %d" % (x,y), id
|
||||
# Okay, we got a double click. Let's assume it's the current selection
|
||||
wxYield()
|
||||
self.OnViewArticle(event)
|
||||
|
||||
def OnCloseWindow(self, event):
|
||||
self.Destroy()
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# if running standalone
|
||||
|
||||
if __name__ == '__main__':
|
||||
class MyApp(wxApp):
|
||||
def OnInit(self):
|
||||
frame = AppFrame(NULL, -1, "Slashdot Breaking News")
|
||||
frame.Show(true)
|
||||
self.SetTopWindow(frame)
|
||||
return true
|
||||
|
||||
app = MyApp(0)
|
||||
app.MainLoop()
|
||||
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# if running as part of the Demo Framework...
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
win = AppFrame(NULL, -1, "Slashdot Breaking News")
|
||||
frame.otherWin = win
|
||||
win.Show(true)
|
||||
|
||||
|
||||
overview = __doc__
|
||||
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
|
Before Width: | Height: | Size: 238 B |
Before Width: | Height: | Size: 56 KiB |
Before Width: | Height: | Size: 6.9 KiB |
Before Width: | Height: | Size: 7.9 KiB |
Before Width: | Height: | Size: 18 KiB |
Before Width: | Height: | Size: 766 B |
Before Width: | Height: | Size: 238 B |
Before Width: | Height: | Size: 238 B |
Before Width: | Height: | Size: 238 B |
Before Width: | Height: | Size: 246 B |
Before Width: | Height: | Size: 766 B |
Before Width: | Height: | Size: 12 KiB |
Before Width: | Height: | Size: 238 B |
Before Width: | Height: | Size: 238 B |
@@ -1,4 +0,0 @@
|
||||
#!/bin/env python
|
||||
|
||||
import Main
|
||||
Main.main()
|
@@ -1,465 +0,0 @@
|
||||
"""Hangman.py, a simple wxPython game, inspired by the
|
||||
old bsd game by Ken Arnold.
|
||||
From the original man page:
|
||||
|
||||
In hangman, the computer picks a word from the on-line
|
||||
word list and you must try to guess it. The computer
|
||||
keeps track of which letters have been guessed and how
|
||||
many wrong guesses you have made on the screen in a
|
||||
graphic fashion.
|
||||
|
||||
That says it all, doesn't it?
|
||||
|
||||
Have fun with it,
|
||||
|
||||
Harm van der Heijden (H.v.d.Heijden@phys.tue.nl)"""
|
||||
|
||||
import random,re,string
|
||||
from wxPython.wx import *
|
||||
|
||||
|
||||
|
||||
class WordFetcher:
|
||||
builtin_words = ' albatros banana electrometer eggshell'
|
||||
|
||||
def __init__(self, filename, min_length = 5):
|
||||
self.min_length = min_length
|
||||
print "Trying to open file %s" % (filename,)
|
||||
try:
|
||||
f = open(filename, "r")
|
||||
except:
|
||||
print "Couldn't open dictionary file %s, using builtins" % (filename,)
|
||||
self.words = self.builtin_words
|
||||
self.filename = None
|
||||
return
|
||||
self.words = f.read()
|
||||
self.filename = filename
|
||||
print "Got %d bytes." % (len(self.words),)
|
||||
|
||||
def SetMinLength(min_length):
|
||||
self.min_length = min_length
|
||||
|
||||
def Get(self):
|
||||
reg = re.compile('\s+([a-zA-Z]+)\s+')
|
||||
n = 50 # safety valve; maximum number of tries to find a suitable word
|
||||
while n:
|
||||
index = int(random.random()*len(self.words))
|
||||
m = reg.search(self.words[index:])
|
||||
if m and len(m.groups()[0]) >= self.min_length: break
|
||||
n = n - 1
|
||||
if n: return string.lower(m.groups()[0])
|
||||
return "error"
|
||||
|
||||
|
||||
|
||||
def stdprint(x):
|
||||
print x
|
||||
|
||||
|
||||
|
||||
class URLWordFetcher(WordFetcher):
|
||||
def __init__(self, url):
|
||||
self.OpenURL(url)
|
||||
WordFetcher.__init__(self, "hangman_dict.txt")
|
||||
|
||||
def logprint(self,x):
|
||||
print x
|
||||
|
||||
def RetrieveAsFile(self, host, path=''):
|
||||
from httplib import HTTP
|
||||
try:
|
||||
h = HTTP(host)
|
||||
except:
|
||||
self.logprint("Failed to create HTTP connection to %s... is the network available?" % (host))
|
||||
return None
|
||||
h.putrequest('GET',path)
|
||||
h.putheader('Accept','text/html')
|
||||
h.putheader('Accept','text/plain')
|
||||
h.endheaders()
|
||||
errcode, errmsg, headers = h.getreply()
|
||||
if errcode != 200:
|
||||
self.logprint("HTTP error code %d: %s" % (errcode, errmsg))
|
||||
return None
|
||||
f = h.getfile()
|
||||
return f
|
||||
|
||||
def OpenURL(self,url):
|
||||
from htmllib import HTMLParser
|
||||
import formatter
|
||||
self.url = url
|
||||
m = re.match('http://([^/]+)(/\S*)\s*', url)
|
||||
if m:
|
||||
host = m.groups()[0]
|
||||
path = m.groups()[1]
|
||||
else:
|
||||
m = re.match('http://(\S+)\s*', url)
|
||||
if not m:
|
||||
# Invalid URL
|
||||
self.logprint("Invalid or unsupported URL: %s" % (url))
|
||||
return
|
||||
host = m.groups()[0]
|
||||
path = ''
|
||||
f = self.RetrieveAsFile(host,path)
|
||||
if not f:
|
||||
self.logprint("Could not open %s" % (url))
|
||||
return
|
||||
self.logprint("Receiving data...")
|
||||
data = f.read()
|
||||
tmp = open('hangman_dict.txt','w')
|
||||
fmt = formatter.AbstractFormatter(formatter.DumbWriter(tmp))
|
||||
p = HTMLParser(fmt)
|
||||
self.logprint("Parsing data...")
|
||||
p.feed(data)
|
||||
p.close()
|
||||
tmp.close()
|
||||
|
||||
|
||||
|
||||
class HangmanWnd(wxWindow):
|
||||
def __init__(self, parent, id, pos=wxDefaultPosition, size=wxDefaultSize):
|
||||
wxWindow.__init__(self, parent, id, pos, size)
|
||||
self.SetBackgroundColour(wxNamedColour('white'))
|
||||
if wxPlatform == '__WXGTK__':
|
||||
self.font = wxFont(12, wxMODERN, wxNORMAL, wxNORMAL)
|
||||
else:
|
||||
self.font = wxFont(10, wxMODERN, wxNORMAL, wxNORMAL)
|
||||
self.SetFocus()
|
||||
|
||||
def StartGame(self, word):
|
||||
self.word = word
|
||||
self.guess = []
|
||||
self.tries = 0
|
||||
self.misses = 0
|
||||
self.Draw()
|
||||
|
||||
def EndGame(self):
|
||||
self.misses = 7;
|
||||
self.guess = map(chr, range(ord('a'),ord('z')+1))
|
||||
self.Draw()
|
||||
|
||||
def HandleKey(self, key):
|
||||
self.message = ""
|
||||
if self.guess.count(key):
|
||||
self.message = 'Already guessed %s' % (key,)
|
||||
return 0
|
||||
self.guess.append(key)
|
||||
self.guess.sort()
|
||||
self.tries = self.tries+1
|
||||
if not key in self.word:
|
||||
self.misses = self.misses+1
|
||||
if self.misses == 7:
|
||||
self.EndGame()
|
||||
return 1
|
||||
has_won = 1
|
||||
for letter in self.word:
|
||||
if not self.guess.count(letter):
|
||||
has_won = 0
|
||||
break
|
||||
if has_won:
|
||||
self.Draw()
|
||||
return 2
|
||||
self.Draw()
|
||||
return 0
|
||||
|
||||
def Draw(self, dc = None):
|
||||
if not dc:
|
||||
dc = wxClientDC(self)
|
||||
dc.SetFont(self.font)
|
||||
dc.Clear()
|
||||
(x,y) = self.GetSizeTuple()
|
||||
x1 = x-200; y1 = 20
|
||||
for letter in self.word:
|
||||
if self.guess.count(letter):
|
||||
dc.DrawText(letter, x1, y1)
|
||||
else:
|
||||
dc.DrawText('.', x1, y1)
|
||||
x1 = x1 + 10
|
||||
x1 = x-200
|
||||
dc.DrawText("tries %d misses %d" % (self.tries,self.misses),x1,50)
|
||||
guesses = ""
|
||||
for letter in self.guess:
|
||||
guesses = guesses + letter
|
||||
dc.DrawText("guessed:", x1, 70)
|
||||
dc.DrawText(guesses[:13], x1+80, 70)
|
||||
dc.DrawText(guesses[13:], x1+80, 90)
|
||||
dc.SetUserScale(x/1000.0, y/1000.0)
|
||||
self.DrawVictim(dc)
|
||||
|
||||
def DrawVictim(self, dc):
|
||||
dc.SetPen(wxPen(wxNamedColour('black'), 20))
|
||||
dc.DrawLines([(10, 980), (10,900), (700,900), (700,940), (720,940),
|
||||
(720,980), (900,980)])
|
||||
dc.DrawLines([(100,900), (100, 100), (300,100)])
|
||||
dc.DrawLine(100,200,200,100)
|
||||
if ( self.misses == 0 ): return
|
||||
dc.SetPen(wxPen(wxNamedColour('blue'), 10))
|
||||
dc.DrawLine(300,100,300,200)
|
||||
if ( self.misses == 1 ): return
|
||||
dc.DrawEllipse(250,200,100,100)
|
||||
if ( self.misses == 2 ): return
|
||||
dc.DrawLine(300,300,300,600)
|
||||
if ( self.misses == 3) : return
|
||||
dc.DrawLine(300,300,250,550)
|
||||
if ( self.misses == 4) : return
|
||||
dc.DrawLine(300,300,350,550)
|
||||
if ( self.misses == 5) : return
|
||||
dc.DrawLine(300,600,350,850)
|
||||
if ( self.misses == 6) : return
|
||||
dc.DrawLine(300,600,250,850)
|
||||
|
||||
def OnPaint(self, event):
|
||||
dc = wxPaintDC(self)
|
||||
self.Draw(dc)
|
||||
|
||||
|
||||
|
||||
class HangmanDemo(HangmanWnd):
|
||||
def __init__(self, wf, parent, id, pos, size):
|
||||
HangmanWnd.__init__(self, parent, id, pos, size)
|
||||
self.StartGame("dummy")
|
||||
self.start_new = 1
|
||||
self.wf = wf
|
||||
self.delay = 500
|
||||
self.timer = self.PlayTimer(self.MakeMove)
|
||||
|
||||
def MakeMove(self):
|
||||
self.timer.Stop()
|
||||
if self.start_new:
|
||||
self.StartGame(self.wf.Get())
|
||||
self.start_new = 0
|
||||
self.left = list('aaaabcdeeeeefghiiiiijklmnnnoooopqrssssttttuuuuvwxyz')
|
||||
else:
|
||||
key = self.left[int(random.random()*len(self.left))]
|
||||
while self.left.count(key): self.left.remove(key)
|
||||
self.start_new = self.HandleKey(key)
|
||||
self.timer.Start(self.delay)
|
||||
|
||||
def Stop(self):
|
||||
self.timer.Stop()
|
||||
|
||||
class PlayTimer(wxTimer):
|
||||
def __init__(self,func):
|
||||
wxTimer.__init__(self)
|
||||
self.func = func
|
||||
self.Start(1000)
|
||||
|
||||
def Notify(self):
|
||||
apply(self.func, ())
|
||||
|
||||
|
||||
|
||||
class HangmanDemoFrame(wxFrame):
|
||||
def __init__(self, wf, parent, id, pos, size):
|
||||
wxFrame.__init__(self, parent, id, "Hangman demo", pos, size)
|
||||
self.demo = HangmanDemo(wf, self, -1, wxDefaultPosition, wxDefaultSize)
|
||||
|
||||
def OnCloseWindow(self, event):
|
||||
self.demo.timer.Stop()
|
||||
self.Destroy()
|
||||
|
||||
|
||||
|
||||
class AboutBox(wxDialog):
|
||||
def __init__(self, parent,wf):
|
||||
wxDialog.__init__(self, parent, -1, "About Hangman", wxDefaultPosition, wxSize(350,450))
|
||||
self.wnd = HangmanDemo(wf, self, -1, wxPoint(1,1), wxSize(350,150))
|
||||
self.static = wxStaticText(self, -1, __doc__, wxPoint(1,160), wxSize(350, 250))
|
||||
self.button = wxButton(self, 2001, "OK", wxPoint(150,420), wxSize(50,-1))
|
||||
EVT_BUTTON(self, 2001, self.OnOK)
|
||||
|
||||
def OnOK(self, event):
|
||||
self.wnd.Stop()
|
||||
self.EndModal(wxID_OK)
|
||||
|
||||
|
||||
|
||||
class MyFrame(wxFrame):
|
||||
def __init__(self, parent, wf):
|
||||
self.wf = wf
|
||||
wxFrame.__init__(self, parent, -1, "hangman", wxDefaultPosition, wxSize(400,300))
|
||||
self.wnd = HangmanWnd(self, -1)
|
||||
menu = wxMenu()
|
||||
menu.Append(1001, "New")
|
||||
menu.Append(1002, "End")
|
||||
menu.AppendSeparator()
|
||||
menu.Append(1003, "Reset")
|
||||
menu.Append(1004, "Demo...")
|
||||
menu.AppendSeparator()
|
||||
menu.Append(1005, "Exit")
|
||||
menubar = wxMenuBar()
|
||||
menubar.Append(menu, "Game")
|
||||
menu = wxMenu()
|
||||
#menu.Append(1010, "Internal", "Use internal dictionary", TRUE)
|
||||
menu.Append(1011, "ASCII File...")
|
||||
urls = [ 'wxPython home', 'http://alldunn.com/wxPython/main.html',
|
||||
'slashdot.org', 'http://slashdot.org/',
|
||||
'cnn.com', 'http://cnn.com',
|
||||
'The New York Times', 'http://www.nytimes.com',
|
||||
'De Volkskrant', 'http://www.volkskrant.nl/frameless/25000006.html',
|
||||
'Gnu GPL', 'http://www.fsf.org/copyleft/gpl.html',
|
||||
'Bijbel: Genesis', 'http://www.coas.com/bijbel/gn1.htm']
|
||||
urlmenu = wxMenu()
|
||||
for item in range(0,len(urls),2):
|
||||
urlmenu.Append(1020+item/2, urls[item], urls[item+1])
|
||||
urlmenu.Append(1080, 'Other...', 'Enter an URL')
|
||||
menu.AppendMenu(1012, 'URL', urlmenu, 'Use a webpage')
|
||||
menu.Append(1013, 'Dump', 'Write contents to stdout')
|
||||
menubar.Append(menu, "Dictionary")
|
||||
self.urls = urls
|
||||
self.urloffset = 1020
|
||||
menu = wxMenu()
|
||||
menu.Append(1090, "About...")
|
||||
menubar.Append(menu, "Help")
|
||||
self.SetMenuBar(menubar)
|
||||
self.CreateStatusBar(2)
|
||||
EVT_MENU(self, 1001, self.OnGameNew)
|
||||
EVT_MENU(self, 1002, self.OnGameEnd)
|
||||
EVT_MENU(self, 1003, self.OnGameReset)
|
||||
EVT_MENU(self, 1004, self.OnGameDemo)
|
||||
EVT_MENU(self, 1005, self.OnWindowClose)
|
||||
EVT_MENU(self, 1011, self.OnDictFile)
|
||||
EVT_MENU_RANGE(self, 1020, 1020+len(urls)/2, self.OnDictURL)
|
||||
EVT_MENU(self, 1080, self.OnDictURLSel)
|
||||
EVT_MENU(self, 1013, self.OnDictDump)
|
||||
EVT_MENU(self, 1090, self.OnHelpAbout)
|
||||
EVT_CHAR(self.wnd, self.OnChar)
|
||||
self.OnGameReset()
|
||||
|
||||
def OnGameNew(self, event):
|
||||
word = self.wf.Get()
|
||||
self.in_progress = 1
|
||||
self.SetStatusText("",0)
|
||||
self.wnd.StartGame(word)
|
||||
|
||||
def OnGameEnd(self, event):
|
||||
self.UpdateAverages(0)
|
||||
self.in_progress = 0
|
||||
self.SetStatusText("",0)
|
||||
self.wnd.EndGame()
|
||||
|
||||
def OnGameReset(self, event=None):
|
||||
self.played = 0
|
||||
self.won = 0
|
||||
self.history = []
|
||||
self.average = 0.0
|
||||
self.OnGameNew(None)
|
||||
|
||||
def OnGameDemo(self, event):
|
||||
frame = HangmanDemoFrame(self.wf, self, -1, wxDefaultPosition, self.GetSize())
|
||||
frame.Show(TRUE)
|
||||
|
||||
def OnDictFile(self, event):
|
||||
fd = wxFileDialog(self)
|
||||
if (self.wf.filename):
|
||||
fd.SetFilename(self.wf.filename)
|
||||
if fd.ShowModal() == wxID_OK:
|
||||
file = fd.GetPath()
|
||||
self.wf = WordFetcher(file)
|
||||
|
||||
def OnDictURL(self, event):
|
||||
item = (event.GetId() - self.urloffset)*2
|
||||
print "Trying to open %s at %s" % (self.urls[item], self.urls[item+1])
|
||||
self.wf = URLWordFetcher(self.urls[item+1])
|
||||
|
||||
def OnDictURLSel(self, event):
|
||||
msg = wxTextEntryDialog(self, "Enter the URL of the dictionary document", "Enter URL")
|
||||
if msg.ShowModal() == wxID_OK:
|
||||
url = msg.GetValue()
|
||||
self.wf = URLWordFetcher(url)
|
||||
def OnDictDump(self, event):
|
||||
print self.wf.words
|
||||
|
||||
def OnHelpAbout(self, event):
|
||||
about = AboutBox(self, self.wf)
|
||||
about.ShowModal()
|
||||
about.wnd.Stop() # that damn timer won't stop!
|
||||
|
||||
def UpdateAverages(self, has_won):
|
||||
if has_won:
|
||||
self.won = self.won + 1
|
||||
self.played = self.played+1
|
||||
self.history.append(self.wnd.misses) # ugly
|
||||
total = 0.0
|
||||
for m in self.history:
|
||||
total = total + m
|
||||
self.average = float(total/len(self.history))
|
||||
|
||||
def OnChar(self, event):
|
||||
if not self.in_progress:
|
||||
#print "new"
|
||||
self.OnGameNew(None)
|
||||
return
|
||||
key = event.KeyCode();
|
||||
#print key
|
||||
if key >= ord('A') and key <= ord('Z'):
|
||||
key = key + ord('a') - ord('A')
|
||||
key = chr(key)
|
||||
if key < 'a' or key > 'z':
|
||||
event.Skip()
|
||||
return
|
||||
res = self.wnd.HandleKey(key)
|
||||
if res == 0:
|
||||
self.SetStatusText(self.wnd.message)
|
||||
elif res == 1:
|
||||
self.UpdateAverages(0)
|
||||
self.SetStatusText("Too bad, you're dead!",0)
|
||||
self.in_progress = 0
|
||||
elif res == 2:
|
||||
self.in_progress = 0
|
||||
self.UpdateAverages(1)
|
||||
self.SetStatusText("Congratulations!",0)
|
||||
if self.played:
|
||||
percent = (100.*self.won)/self.played
|
||||
else:
|
||||
percent = 0.0
|
||||
self.SetStatusText("p %d, w %d (%g %%), av %g" % (self.played,self.won, percent, self.average),1)
|
||||
|
||||
def OnWindowClose(self, event):
|
||||
self.Destroy()
|
||||
|
||||
|
||||
|
||||
class MyApp(wxApp):
|
||||
def OnInit(self):
|
||||
if wxPlatform == '__WXGTK__':
|
||||
defaultfile = "/usr/share/games/hangman-words"
|
||||
elif wxPlatform == '__WXMSW__':
|
||||
defaultfile = "c:\\windows\\hardware.txt"
|
||||
else:
|
||||
defaultfile = ""
|
||||
wf = WordFetcher(defaultfile)
|
||||
frame = MyFrame(NULL, wf)
|
||||
self.SetTopWindow(frame)
|
||||
frame.Show(TRUE)
|
||||
return TRUE
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
app = MyApp(0)
|
||||
app.MainLoop()
|
||||
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
overview = __doc__
|
||||
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
if wxPlatform == '__WXGTK__' or wxPlatform == '__WXMOTIF__':
|
||||
defaultfile = "/usr/share/games/hangman-words"
|
||||
elif wxPlatform == '__WXMSW__':
|
||||
defaultfile = "c:\\windows\\hardware.txt"
|
||||
else:
|
||||
defaultfile = ""
|
||||
wf = WordFetcher(defaultfile)
|
||||
win = MyFrame(frame, wf)
|
||||
frame.otherWin = win
|
||||
win.Show(true)
|
||||
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
@@ -1,211 +0,0 @@
|
||||
"""
|
||||
Hello, and welcome to this test of the wxTreeItemData
|
||||
class.
|
||||
|
||||
The wxTreeItemData class can be used to associate a python
|
||||
object with a wxTreeCtrl item. In this sample, its use is
|
||||
demonstrated via a tree control that shows the contents of a
|
||||
python namespace according to the standard dir()
|
||||
command. Every item in the tree has its label taken from the
|
||||
dir() output, and 'behind it' a reference to the python
|
||||
object is stored in a wxTreeItemData object.
|
||||
|
||||
As you may have guessed by now, this sample automatically
|
||||
displays '__doc__' strings if the selected python object
|
||||
happens to have one. Please expand the pyTree object to
|
||||
learn more about the implementation.
|
||||
|
||||
Version 1.0, April 4 1999.
|
||||
Harm van der Heijden (H.v.d.Heijden@phys.tue.nl)
|
||||
|
||||
P.S. Check out the string module. It's imported in this
|
||||
sample not because it's used, but because it's so
|
||||
beautifully documented...
|
||||
"""
|
||||
|
||||
from wxPython import wx
|
||||
import string # Don't use it, but it's fun expanding :-)
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
def _getindent(line):
|
||||
"""Returns the indentation level of the given line."""
|
||||
indent = 0
|
||||
for c in line:
|
||||
if c == ' ': indent = indent + 1
|
||||
elif c == '\t': indent = indent + 8
|
||||
else: break
|
||||
return indent
|
||||
|
||||
def _sourcefinder(func):
|
||||
"""Given a func_code object, this function tries to find and return
|
||||
the python source code of the function."""
|
||||
try:
|
||||
f = open(func.co_filename,"r")
|
||||
except:
|
||||
return "(could not open file %s)" % (func.co_filename,)
|
||||
|
||||
for i in range(func.co_firstlineno):
|
||||
line = f.readline()
|
||||
ind = _getindent(line)
|
||||
msg = ""
|
||||
while line:
|
||||
msg = msg + line
|
||||
line = f.readline()
|
||||
# the following should be <= ind, but then we get
|
||||
# confused by multiline docstrings. Using == works most of
|
||||
# the time... but not always!
|
||||
if _getindent(line) == ind: break
|
||||
return msg
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
class pyTree(wx.wxTreeCtrl):
|
||||
"""
|
||||
This wxTreeCtrl derivative displays a tree view of a Python namespace.
|
||||
Anything from which the dir() command returns a non-empty list is a branch
|
||||
in this tree.
|
||||
"""
|
||||
|
||||
def __init__(self, parent, id, root):
|
||||
"""
|
||||
Initialize function; because we insert branches into the tree
|
||||
as needed, we use the ITEM_EXPANDING event handler. The
|
||||
ITEM_COLLAPSED handler removes the stuff afterwards. The
|
||||
SEL_CHANGED handler attempts to display interesting
|
||||
information about the selected object.
|
||||
"""
|
||||
wx.wxTreeCtrl.__init__(self, parent, id)
|
||||
self.root = self.AddRoot(str(root), -1, -1, wx.wxTreeItemData(root))
|
||||
if dir(root):
|
||||
self.SetItemHasChildren(self.root, wx.TRUE)
|
||||
wx.EVT_TREE_ITEM_EXPANDING(self, self.GetId(), self.OnItemExpanding)
|
||||
wx.EVT_TREE_ITEM_COLLAPSED(self, self.GetId(), self.OnItemCollapsed)
|
||||
wx.EVT_TREE_SEL_CHANGED(self, self.GetId(), self.OnSelChanged)
|
||||
self.output = None
|
||||
|
||||
|
||||
def SetOutput(self, output):
|
||||
"""
|
||||
Set output function (accepts single string). Used to display string
|
||||
representation of the selected object by OnSelChanged.
|
||||
"""
|
||||
self.output = output
|
||||
|
||||
|
||||
def OnItemExpanding(self,event):
|
||||
"""
|
||||
The real workhorse of this class. First we retrieve the object
|
||||
(parent) belonging to the branch that is to be expanded. This
|
||||
is done by calling GetPyData(parent), which is a short-cut for
|
||||
GetPyItemData(parent).Get().
|
||||
|
||||
Then we get the dir() list of that object. For each item in
|
||||
this list, a tree item is created with associated
|
||||
wxTreeItemData referencing the child object. We get this
|
||||
object using child = getattr(parent, item).
|
||||
|
||||
Finally, we check wether the child returns a non-empty dir()
|
||||
list. If so, it is labeled as 'having children', so that it
|
||||
may be expanded. When it actually is expanded, this function
|
||||
will again figure out what the offspring is.
|
||||
"""
|
||||
item = event.GetItem()
|
||||
obj = self.GetPyData( item )
|
||||
lst = dir(obj)
|
||||
for key in lst:
|
||||
new_obj = getattr(obj,key)
|
||||
new_item = self.AppendItem( item, key, -1, -1,
|
||||
wx.wxTreeItemData(new_obj) )
|
||||
if dir(new_obj):
|
||||
self.SetItemHasChildren(new_item, wx.TRUE)
|
||||
|
||||
def OnItemCollapsed(self, event):
|
||||
"""
|
||||
We need to remove all children here, otherwise we'll see all
|
||||
that old rubbish again after the next expansion.
|
||||
"""
|
||||
item = event.GetItem()
|
||||
self.DeleteChildren(item)
|
||||
|
||||
def OnSelChanged(self, event):
|
||||
"""
|
||||
If an output function is defined, we try to print some
|
||||
informative, interesting and thought-provoking stuff to it.
|
||||
If it has a __doc__ string, we print it. If it's a function or
|
||||
unbound class method, we attempt to find the python source.
|
||||
"""
|
||||
if not self.output:
|
||||
return
|
||||
obj = self.GetPyData( event.GetItem() )
|
||||
msg = str(obj)
|
||||
if hasattr(obj, '__doc__'):
|
||||
msg = msg+"\n\nDocumentation string:\n\n%s" % ( getattr(obj, '__doc__'),)
|
||||
# Is it a function?
|
||||
func = None
|
||||
if hasattr(obj, "func_code"): # normal function
|
||||
func = getattr(obj, "func_code")
|
||||
elif hasattr(obj, "im_func"): # unbound class method
|
||||
func = getattr(getattr(obj, "im_func"), "func_code")
|
||||
if func: # if we found one, let's try to print the source
|
||||
msg = msg+"\n\nFunction source:\n\n" + _sourcefinder(func)
|
||||
|
||||
apply(self.output, (msg,))
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
overview = __doc__
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
"""
|
||||
This method is used by the wxPython Demo Framework for integrating
|
||||
this demo with the rest.
|
||||
"""
|
||||
thisModule = __import__(__name__, globals())
|
||||
win = wx.wxFrame(frame, -1, "PyTreeItemData Test")
|
||||
split = wx.wxSplitterWindow(win, -1)
|
||||
tree = pyTree(split, -1, thisModule)
|
||||
text = wx.wxTextCtrl(split, -1, "", wx.wxDefaultPosition,
|
||||
wx.wxDefaultSize, wx.wxTE_MULTILINE)
|
||||
split.SplitVertically(tree, text, 200)
|
||||
tree.SetOutput(text.SetValue)
|
||||
tree.SelectItem(tree.root)
|
||||
win.SetSize(wx.wxSize(800,500))
|
||||
frame.otherWin = win
|
||||
win.Show(1)
|
||||
|
||||
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
if __name__ == '__main__':
|
||||
|
||||
class MyFrame(wx.wxFrame):
|
||||
"""Very standard Frame class. Nothing special here!"""
|
||||
|
||||
def __init__(self):
|
||||
"""Make a splitter window; left a tree, right a textctrl. Wow."""
|
||||
import __main__
|
||||
wx.wxFrame.__init__(self, wx.NULL, -1, "PyTreeItemData Test",
|
||||
wx.wxDefaultPosition, wx.wxSize(800,500))
|
||||
split = wx.wxSplitterWindow(self, -1)
|
||||
tree = pyTree(split, -1, __main__)
|
||||
text = wx.wxTextCtrl(split, -1, "", wx.wxDefaultPosition,
|
||||
wx.wxDefaultSize, wx.wxTE_MULTILINE)
|
||||
split.SplitVertically(tree, text, 200)
|
||||
tree.SetOutput(text.SetValue)
|
||||
tree.SelectItem(tree.root)
|
||||
|
||||
class MyApp(wx.wxApp):
|
||||
"""This class is even less interesting than MyFrame."""
|
||||
|
||||
def OnInit(self):
|
||||
"""OnInit. Boring, boring, boring!"""
|
||||
frame = MyFrame()
|
||||
frame.Show(wx.TRUE)
|
||||
self.SetTopWindow(frame)
|
||||
return wx.TRUE
|
||||
|
||||
app = MyApp(0)
|
||||
app.MainLoop()
|
||||
|
||||
|
@@ -1,47 +0,0 @@
|
||||
|
||||
from wxPython.wx import *
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
class TestPanel(wxPanel):
|
||||
def __init__(self, parent, log):
|
||||
wxPanel.__init__(self, parent, -1)
|
||||
self.log = log
|
||||
|
||||
wxButton(self, 10, "Hello", wxPoint(20, 20)).SetDefault()
|
||||
EVT_BUTTON(self, 10, self.OnClick)
|
||||
|
||||
wxButton(self, 20, "HELLO AGAIN!", wxPoint(20, 60), wxSize(90, 45))
|
||||
EVT_BUTTON(self, 20, self.OnClick)
|
||||
|
||||
bmp = wxBitmap('bitmaps/test2.bmp', wxBITMAP_TYPE_BMP)
|
||||
wxBitmapButton(self, 30, bmp, wxPoint(140, 20),
|
||||
wxSize(bmp.GetWidth()+10, bmp.GetHeight()+10))
|
||||
EVT_BUTTON(self, 30, self.OnClick)
|
||||
|
||||
|
||||
def OnClick(self, event):
|
||||
self.log.WriteText("Click! (%d)\n" % event.GetId())
|
||||
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
win = TestPanel(nb, log)
|
||||
return win
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
overview = """\
|
||||
"""
|
||||
|
||||
|
@@ -1,80 +0,0 @@
|
||||
|
||||
from wxPython.wx import *
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
class TestCheckBox(wxPanel):
|
||||
def __init__(self, parent, log):
|
||||
self.log = log
|
||||
wxPanel.__init__(self, parent, -1)
|
||||
|
||||
wxStaticText(self, -1, "This example uses the wxCheckBox control.",
|
||||
wxPoint(10, 10))
|
||||
|
||||
cID = NewId()
|
||||
cb1 = wxCheckBox(self, cID, " Apples", wxPoint(65, 40), wxSize(150, 20), wxNO_BORDER)
|
||||
cb2 = wxCheckBox(self, cID+1, " Oranges", wxPoint(65, 60), wxSize(150, 20), wxNO_BORDER)
|
||||
cb2.SetValue(true)
|
||||
cb3 = wxCheckBox(self, cID+2, " Pears", wxPoint(65, 80), wxSize(150, 20), wxNO_BORDER)
|
||||
|
||||
EVT_CHECKBOX(self, cID, self.EvtCheckBox)
|
||||
EVT_CHECKBOX(self, cID+1, self.EvtCheckBox)
|
||||
EVT_CHECKBOX(self, cID+2, self.EvtCheckBox)
|
||||
|
||||
|
||||
def EvtCheckBox(self, event):
|
||||
self.log.WriteText('EvtCheckBox: %d\n' % event.Checked())
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
win = TestCheckBox(nb, log)
|
||||
return win
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
overview = """\
|
||||
A checkbox is a labelled box which is either on (checkmark is visible) or off (no checkmark).
|
||||
|
||||
wxCheckBox()
|
||||
-----------------------
|
||||
|
||||
Default constructor.
|
||||
|
||||
wxCheckBox(wxWindow* parent, wxWindowID id, const wxString& label, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = 0, const wxValidator& val, const wxString& name = "checkBox")
|
||||
|
||||
Constructor, creating and showing a checkbox.
|
||||
|
||||
Parameters
|
||||
-------------------
|
||||
|
||||
parent = Parent window. Must not be NULL.
|
||||
|
||||
id = Checkbox identifier. A value of -1 indicates a default value.
|
||||
|
||||
label = Text to be displayed next to the checkbox.
|
||||
|
||||
pos = Checkbox position. If the position (-1, -1) is specified then a default position is chosen.
|
||||
|
||||
size = Checkbox size. If the default size (-1, -1) is specified then a default size is chosen.
|
||||
|
||||
style = Window style. See wxCheckBox.
|
||||
|
||||
validator = Window validator.
|
||||
|
||||
name = Window name.
|
||||
"""
|
@@ -1,53 +0,0 @@
|
||||
|
||||
from wxPython.wx import *
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
class TestPanel(wxPanel):
|
||||
def __init__(self, parent, log):
|
||||
wxPanel.__init__(self, parent, -1)
|
||||
self.log = log
|
||||
|
||||
sampleList = ['zero', 'one', 'two', 'three', 'four', 'five',
|
||||
'six', 'seven', 'eight', 'nine', 'ten', 'eleven',
|
||||
'twelve', 'thirteen', 'fourteen']
|
||||
|
||||
wxStaticText(self, -1, "This example uses the wxCheckListBox control.",
|
||||
wxPoint(45, 15))
|
||||
|
||||
lb = wxCheckListBox(self, 60, wxPoint(80, 50), wxSize(80, 120),
|
||||
sampleList)
|
||||
EVT_LISTBOX(self, 60, self.EvtListBox)
|
||||
EVT_LISTBOX_DCLICK(self, 60, self.EvtListBoxDClick)
|
||||
lb.SetSelection(0)
|
||||
|
||||
|
||||
def EvtListBox(self, event):
|
||||
self.log.WriteText('EvtListBox: %s\n' % event.GetString())
|
||||
|
||||
def EvtListBoxDClick(self, event):
|
||||
self.log.WriteText('EvtListBoxDClick:\n')
|
||||
|
||||
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
win = TestPanel(nb, log)
|
||||
return win
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
overview = """\
|
||||
"""
|
||||
|
||||
|
@@ -1,76 +0,0 @@
|
||||
|
||||
from wxPython.wx import *
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
class TestChoice(wxPanel):
|
||||
def __init__(self, parent, log):
|
||||
self.log = log
|
||||
wxPanel.__init__(self, parent, -1)
|
||||
|
||||
sampleList = ['zero', 'one', 'two', 'three', 'four', 'five',
|
||||
'six', 'seven', 'eight']
|
||||
|
||||
wxStaticText(self, -1, "This example uses the wxChoice control.",
|
||||
wxPoint(15, 10))
|
||||
|
||||
wxStaticText(self, -1, "Select one:", wxPoint(15, 50), wxSize(75, 20))
|
||||
wxChoice(self, 40, wxPoint(80, 50), wxSize(95, 20), #wxDefaultSize,
|
||||
sampleList)
|
||||
EVT_CHOICE(self, 40, self.EvtChoice)
|
||||
|
||||
def EvtChoice(self, event):
|
||||
self.log.WriteText('EvtChoice: %s\n' % event.GetString())
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
win = TestChoice(nb, log)
|
||||
return win
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
overview = """\
|
||||
A choice item is used to select one of a list of strings. Unlike a listbox, only the selection is visible until the user pulls down the menu of choices.
|
||||
|
||||
wxChoice()
|
||||
-------------------
|
||||
|
||||
Default constructor.
|
||||
|
||||
wxChoice(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size, int n, const wxString choices[], long style = 0, const wxValidator& validator = wxDefaultValidator, const wxString& name = "choice")
|
||||
|
||||
Constructor, creating and showing a choice.
|
||||
|
||||
Parameters
|
||||
-------------------
|
||||
|
||||
parent = Parent window. Must not be NULL.
|
||||
|
||||
id = Window identifier. A value of -1 indicates a default value.
|
||||
|
||||
pos = Window position.
|
||||
|
||||
size = Window size. If the default size (-1, -1) is specified then the choice is sized appropriately.
|
||||
|
||||
n = Number of strings with which to initialise the choice control.
|
||||
|
||||
choices = An array of strings with which to initialise the choice control.
|
||||
|
||||
style = Window style. See wxChoice.
|
||||
|
||||
validator = Window validator.
|
||||
|
||||
name = Window name.
|
||||
"""
|
@@ -1,38 +0,0 @@
|
||||
|
||||
from wxPython.wx import *
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
data = wxColourData()
|
||||
data.SetChooseFull(true)
|
||||
dlg = wxColourDialog(frame, data)
|
||||
if dlg.ShowModal() == wxID_OK:
|
||||
data = dlg.GetColourData()
|
||||
log.WriteText('You selected: %s\n' % str(data.GetColour().Get()))
|
||||
dlg.Destroy()
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
overview = """\
|
||||
This class represents the colour chooser dialog.
|
||||
|
||||
wxColourDialog()
|
||||
------------------------------
|
||||
|
||||
wxColourDialog(wxWindow* parent, wxColourData* data = NULL)
|
||||
|
||||
Constructor. Pass a parent window, and optionally a pointer to a block of colour data, which will be copied to the colour dialog's colour data.
|
||||
|
||||
"""
|
@@ -1,79 +0,0 @@
|
||||
|
||||
from wxPython.wx import *
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
class TestComboBox(wxPanel):
|
||||
def __init__(self, parent, log):
|
||||
self.log = log
|
||||
wxPanel.__init__(self, parent, -1)
|
||||
|
||||
sampleList = ['zero', 'one', 'two', 'three', 'four', 'five',
|
||||
'six', 'seven', 'eight']
|
||||
|
||||
wxStaticText(self, -1, "This example uses the wxComboBox control.",
|
||||
wxPoint(8, 10))
|
||||
|
||||
wxStaticText(self, -1, "Select one:", wxPoint(15, 50), wxSize(75, 18))
|
||||
wxComboBox(self, 50, "default value", wxPoint(80, 50), wxSize(95, 20),
|
||||
sampleList, wxCB_DROPDOWN)
|
||||
EVT_COMBOBOX(self, 50, self.EvtComboBox)
|
||||
|
||||
|
||||
def EvtComboBox(self, event):
|
||||
self.log.WriteText('EvtComboBox: %s\n' % event.GetString())
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
win = TestComboBox(nb, log)
|
||||
return win
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
overview = """\
|
||||
A combobox is like a combination of an edit control and a listbox. It can be displayed as static list with editable or read-only text field; or a drop-down list with text field; or a drop-down list without a text field.
|
||||
|
||||
A combobox permits a single selection only. Combobox items are numbered from zero.
|
||||
|
||||
wxComboBox()
|
||||
-----------------------
|
||||
|
||||
Default constructor.
|
||||
|
||||
wxComboBox(wxWindow* parent, wxWindowID id, const wxString& value = "", const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, int n, const wxString choices[], long style = 0, const wxValidator& validator = wxDefaultValidator, const wxString& name = "comboBox")
|
||||
|
||||
Constructor, creating and showing a combobox.
|
||||
|
||||
Parameters
|
||||
-------------------
|
||||
|
||||
parent = Parent window. Must not be NULL.
|
||||
|
||||
id = Window identifier. A value of -1 indicates a default value.
|
||||
|
||||
pos = Window position.
|
||||
|
||||
size = Window size. If the default size (-1, -1) is specified then the window is sized appropriately.
|
||||
|
||||
n = Number of strings with which to initialise the control.
|
||||
|
||||
choices = An array of strings with which to initialise the control.
|
||||
|
||||
style = Window style. See wxComboBox.
|
||||
|
||||
validator = Window validator.
|
||||
|
||||
name = Window name.
|
||||
"""
|
@@ -1,33 +0,0 @@
|
||||
|
||||
from wxPython.wx import *
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
win = wxDialog(frame, -1, "This is a wxDialog", wxDefaultPosition, wxSize(350, 200))
|
||||
|
||||
wxStaticText(win, -1, "This is a wxDialog", wxPoint(20, 20))
|
||||
wxButton(win, wxID_OK, " OK ", wxPoint(75, 120), wxDefaultSize).SetDefault()
|
||||
wxButton(win, wxID_CANCEL, " Cancel ", wxPoint(150, 120), wxDefaultSize)
|
||||
|
||||
val = win.ShowModal()
|
||||
if val == wxID_OK:
|
||||
log.WriteText("You pressed OK\n")
|
||||
else:
|
||||
log.WriteText("You pressed Cancel\n")
|
||||
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
overview = """\
|
||||
"""
|
@@ -1,53 +0,0 @@
|
||||
|
||||
from wxPython.wx import *
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
dlg = wxDirDialog(frame)
|
||||
if dlg.ShowModal() == wxID_OK:
|
||||
log.WriteText('You selected: %s\n' % dlg.GetPath())
|
||||
dlg.Destroy()
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
overview = """\
|
||||
This class represents the directory chooser dialog.
|
||||
|
||||
wxDirDialog()
|
||||
------------------------
|
||||
|
||||
wxDirDialog(wxWindow* parent, const wxString& message = "Choose a directory", const wxString& defaultPath = "", long style = 0, const wxPoint& pos = wxDefaultPosition)
|
||||
|
||||
Constructor. Use wxDirDialog::ShowModal to show the dialog.
|
||||
|
||||
Parameters
|
||||
-------------------
|
||||
|
||||
parent = Parent window.
|
||||
|
||||
message = Message to show on the dialog.
|
||||
|
||||
defaultPath = The default path, or the empty string.
|
||||
|
||||
style = A dialog style, currently unused.
|
||||
|
||||
pos = Dialog position.
|
||||
"""
|
@@ -1,62 +0,0 @@
|
||||
|
||||
from wxPython.wx import *
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
dlg = wxFileDialog(frame, "Choose a file", ".", "", "*.*", wxOPEN)
|
||||
if dlg.ShowModal() == wxID_OK:
|
||||
log.WriteText('You selected: %s\n' % dlg.GetPath())
|
||||
dlg.Destroy()
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
overview = """\
|
||||
This class represents the file chooser dialog.
|
||||
|
||||
wxFileDialog()
|
||||
----------------------------
|
||||
|
||||
wxFileDialog(wxWindow* parent, const wxString& message = "Choose a file", const wxString& defaultDir = ""
|
||||
, const wxString& defaultFile = "", const wxString& wildcard = "*.*", long style = 0, const wxPoint& pos = wxDefaultPosition)
|
||||
|
||||
Constructor. Use wxFileDialog::ShowModal to show the dialog.
|
||||
|
||||
Parameters
|
||||
-------------------
|
||||
|
||||
parent = Parent window.
|
||||
|
||||
message = Message to show on the dialog.
|
||||
|
||||
defaultDir = The default directory, or the empty string.
|
||||
|
||||
defaultFile = The default filename, or the empty string.
|
||||
|
||||
wildcard = A wildcard, such as "*.*".
|
||||
|
||||
style = A dialog style. A bitlist of:
|
||||
|
||||
wxOPEN This is an open dialog (Windows only).
|
||||
|
||||
wxSAVE This is a save dialog (Windows only).
|
||||
|
||||
wxHIDE_READONLY Hide read-only files (Windows only).
|
||||
|
||||
wxOVERWRITE_PROMPT Prompt for a conformation if a file will be overridden (Windows only).
|
||||
|
||||
pos = Dialog position.
|
||||
"""
|
@@ -1,39 +0,0 @@
|
||||
|
||||
from wxPython.wx import *
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
dlg = wxFontDialog(frame)
|
||||
if dlg.ShowModal() == wxID_OK:
|
||||
data = dlg.GetFontData()
|
||||
font = data.GetChosenFont()
|
||||
log.WriteText('You selected: "%s", %d points, color %s\n' %
|
||||
(font.GetFaceName(), font.GetPointSize(),
|
||||
data.GetColour().Get()))
|
||||
dlg.Destroy()
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
overview = """\
|
||||
This class represents the font chooser dialog.
|
||||
|
||||
wxFontDialog()
|
||||
----------------------------
|
||||
|
||||
wxFontDialog(wxWindow* parent, wxFontData* data = NULL)
|
||||
|
||||
Constructor. Pass a parent window, and optionally a pointer to a block of font data, which will be copied to the font dialog's font data.
|
||||
"""
|
@@ -1,41 +0,0 @@
|
||||
|
||||
from wxPython.wx import *
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
class MyFrame(wxFrame):
|
||||
def __init__(self, parent, ID, title, pos, size):
|
||||
wxFrame.__init__(self, parent, ID, title, pos, size)
|
||||
panel = wxPanel(self, -1)
|
||||
|
||||
button = wxButton(panel, 1003, "Close Me")
|
||||
button.SetPosition(wxPoint(15, 15))
|
||||
EVT_BUTTON(self, 1003, self.OnCloseMe)
|
||||
|
||||
def OnCloseMe(self, event):
|
||||
self.Close(true)
|
||||
|
||||
def OnCloseWindow(self, event):
|
||||
self.Destroy()
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
win = MyFrame(frame, -1, "This is a wxFrame", wxDefaultPosition, wxSize(350, 200))
|
||||
frame.otherWin = win
|
||||
win.Show(true)
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
overview = """\
|
||||
"""
|
@@ -1,153 +0,0 @@
|
||||
|
||||
from wxPython.wx import *
|
||||
try:
|
||||
from wxPython.glcanvas import *
|
||||
haveGLCanvas = true
|
||||
except ImportError:
|
||||
haveGLCanvas = false
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
if not haveGLCanvas:
|
||||
def runTest(frame, nb, log):
|
||||
dlg = wxMessageDialog(frame, 'The wxGLCanvas has not been included with this build of wxPython!',
|
||||
'Sorry', wxOK | wxICON_INFORMATION)
|
||||
dlg.ShowModal()
|
||||
dlg.Destroy()
|
||||
|
||||
else:
|
||||
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
win = TestGLCanvas(nb)
|
||||
return win
|
||||
|
||||
|
||||
|
||||
class TestGLCanvas(wxGLCanvas):
|
||||
def __init__(self, parent):
|
||||
wxGLCanvas.__init__(self, parent, -1)
|
||||
EVT_ERASE_BACKGROUND(self, self.OnEraseBackground)
|
||||
self.init = false
|
||||
|
||||
def OnEraseBackground(self, event):
|
||||
pass # Do nothing, to avoid flashing.
|
||||
|
||||
|
||||
def OnSize(self, event):
|
||||
size = self.GetClientSize()
|
||||
if self.GetContext() != 'NULL':
|
||||
self.SetCurrent()
|
||||
glViewport(0, 0, size.width, size.height)
|
||||
|
||||
|
||||
def OnPaint(self, event):
|
||||
dc = wxPaintDC(self)
|
||||
|
||||
ctx = self.GetContext()
|
||||
if ctx == "NULL": return
|
||||
|
||||
self.SetCurrent()
|
||||
|
||||
|
||||
if not self.init:
|
||||
self.InitGL()
|
||||
self.init = true
|
||||
|
||||
# clear color and depth buffers
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
# draw six faces of a cube
|
||||
glBegin(GL_QUADS)
|
||||
glNormal3f( 0.0, 0.0, 1.0)
|
||||
glVertex3f( 0.5, 0.5, 0.5)
|
||||
glVertex3f(-0.5, 0.5, 0.5)
|
||||
glVertex3f(-0.5,-0.5, 0.5)
|
||||
glVertex3f( 0.5,-0.5, 0.5)
|
||||
|
||||
glNormal3f( 0.0, 0.0,-1.0)
|
||||
glVertex3f(-0.5,-0.5,-0.5)
|
||||
glVertex3f(-0.5, 0.5,-0.5)
|
||||
glVertex3f( 0.5, 0.5,-0.5)
|
||||
glVertex3f( 0.5,-0.5,-0.5)
|
||||
|
||||
glNormal3f( 0.0, 1.0, 0.0)
|
||||
glVertex3f( 0.5, 0.5, 0.5)
|
||||
glVertex3f( 0.5, 0.5,-0.5)
|
||||
glVertex3f(-0.5, 0.5,-0.5)
|
||||
glVertex3f(-0.5, 0.5, 0.5)
|
||||
|
||||
glNormal3f( 0.0,-1.0, 0.0)
|
||||
glVertex3f(-0.5,-0.5,-0.5)
|
||||
glVertex3f( 0.5,-0.5,-0.5)
|
||||
glVertex3f( 0.5,-0.5, 0.5)
|
||||
glVertex3f(-0.5,-0.5, 0.5)
|
||||
|
||||
glNormal3f( 1.0, 0.0, 0.0)
|
||||
glVertex3f( 0.5, 0.5, 0.5)
|
||||
glVertex3f( 0.5,-0.5, 0.5)
|
||||
glVertex3f( 0.5,-0.5,-0.5)
|
||||
glVertex3f( 0.5, 0.5,-0.5)
|
||||
|
||||
glNormal3f(-1.0, 0.0, 0.0)
|
||||
glVertex3f(-0.5,-0.5,-0.5)
|
||||
glVertex3f(-0.5,-0.5, 0.5)
|
||||
glVertex3f(-0.5, 0.5, 0.5)
|
||||
glVertex3f(-0.5, 0.5,-0.5)
|
||||
glEnd()
|
||||
|
||||
self.SwapBuffers()
|
||||
|
||||
|
||||
def InitGL(self):
|
||||
# set viewing projection
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glFrustum(-0.5, 0.5, -0.5, 0.5, 1.0, 3.0);
|
||||
|
||||
# position viewer
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glTranslatef(0.0, 0.0, -2.0);
|
||||
|
||||
# position object
|
||||
glRotatef(30.0, 1.0, 0.0, 0.0);
|
||||
glRotatef(30.0, 0.0, 1.0, 0.0);
|
||||
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glEnable(GL_LIGHTING);
|
||||
glEnable(GL_LIGHT0);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
overview = """\
|
||||
"""
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
def _test():
|
||||
class MyApp(wxApp):
|
||||
def OnInit(self):
|
||||
frame = wxFrame(NULL, -1, "HELP ME!!")
|
||||
win = TestGLCanvas(frame)
|
||||
frame.Show(TRUE)
|
||||
self.SetTopWindow(frame)
|
||||
return TRUE
|
||||
|
||||
app = MyApp(0)
|
||||
app.MainLoop()
|
||||
|
||||
if __name__ == '__main__':
|
||||
_test()
|
@@ -1,55 +0,0 @@
|
||||
|
||||
from wxPython.wx import *
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
class TestPanel(wxPanel):
|
||||
def __init__(self, parent, log):
|
||||
wxPanel.__init__(self, parent, -1)
|
||||
self.log = log
|
||||
self.count = 0
|
||||
|
||||
wxStaticText(self, -1, "This example uses the wxGauge control.",
|
||||
wxPoint(45, 15))
|
||||
|
||||
#self.g1 = wxGauge(self, -1, 50, wxPoint(40, 50), wxSize(40, 160),
|
||||
# wxGA_VERTICAL)
|
||||
#self.g1.SetBezelFace(3)
|
||||
#self.g1.SetShadowWidth(3)
|
||||
|
||||
self.g2 = wxGauge(self, -1, 50, wxPoint(110, 50), wxSize(250, 25),
|
||||
wxGA_HORIZONTAL)
|
||||
self.g2.SetBezelFace(5)
|
||||
self.g2.SetShadowWidth(5)
|
||||
|
||||
EVT_IDLE(self, self.IdleHandler)
|
||||
|
||||
|
||||
def IdleHandler(self, event):
|
||||
self.count = self.count + 1
|
||||
if self.count >= 50:
|
||||
self.count = 0
|
||||
#self.g1.SetValue(self.count)
|
||||
self.g2.SetValue(self.count)
|
||||
|
||||
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
win = TestPanel(nb, log)
|
||||
return win
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
overview = """\
|
||||
"""
|
@@ -1,77 +0,0 @@
|
||||
|
||||
from wxPython.wx import *
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
class TestGrid(wxGrid):
|
||||
def __init__(self, parent, log):
|
||||
wxGrid.__init__(self, parent, -1)
|
||||
self.log = log
|
||||
|
||||
self.CreateGrid(16, 16)
|
||||
self.SetColumnWidth(3, 200)
|
||||
self.SetRowHeight(4, 45)
|
||||
self.SetCellValue("First cell", 0, 0)
|
||||
self.SetCellValue("Another cell", 1, 1)
|
||||
self.SetCellValue("Yet another cell", 2, 2)
|
||||
self.SetCellTextFont(wxFont(12, wxROMAN, wxITALIC, wxNORMAL), 0, 0)
|
||||
self.SetCellTextColour(wxRED, 1, 1)
|
||||
self.SetCellBackgroundColour(wxCYAN, 2, 2)
|
||||
self.UpdateDimensions()
|
||||
self.AdjustScrollbars()
|
||||
|
||||
EVT_GRID_SELECT_CELL(self, self.OnSelectCell)
|
||||
EVT_GRID_CELL_CHANGE(self, self.OnCellChange)
|
||||
EVT_GRID_CELL_LCLICK(self, self.OnCellClick)
|
||||
EVT_GRID_LABEL_LCLICK(self, self.OnLabelClick)
|
||||
|
||||
|
||||
|
||||
def OnSelectCell(self, event):
|
||||
self.log.WriteText("OnSelectCell: (%d, %d)\n" % (event.m_row, event.m_col))
|
||||
|
||||
def OnCellChange(self, event):
|
||||
self.log.WriteText("OnCellChange: (%d, %d)\n" % (event.m_row, event.m_col))
|
||||
|
||||
def OnCellClick(self, event):
|
||||
self.log.WriteText("OnCellClick: (%d, %d)\n" % (event.m_row, event.m_col))
|
||||
|
||||
def OnLabelClick(self, event):
|
||||
self.log.WriteText("OnLabelClick: (%d, %d)\n" % (event.m_row, event.m_col))
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
win = TestGrid(nb, log)
|
||||
return win
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
overview = """\
|
||||
wxGrid is a class for displaying and editing tabular information.
|
||||
|
||||
wxGrid()
|
||||
-----------------
|
||||
|
||||
wxGrid(wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style=0, const wxString& name="grid")
|
||||
|
||||
Constructor. Before using a wxGrid object, you must call CreateGrid to set up the required rows and columns.
|
||||
"""
|
@@ -1,40 +0,0 @@
|
||||
|
||||
from wxPython.wx import *
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
bmp = wxImage('bitmaps/image.bmp', wxBITMAP_TYPE_BMP).ConvertToBitmap()
|
||||
gif = wxImage('bitmaps/image.gif', wxBITMAP_TYPE_GIF).ConvertToBitmap()
|
||||
png = wxImage('bitmaps/image.png', wxBITMAP_TYPE_PNG).ConvertToBitmap()
|
||||
jpg = wxImage('bitmaps/image.jpg', wxBITMAP_TYPE_JPEG).ConvertToBitmap()
|
||||
|
||||
panel = wxPanel(nb, -1)
|
||||
pos = 10
|
||||
wxStaticBitmap(panel, -1, bmp, wxPoint(10, pos),
|
||||
wxSize(bmp.GetWidth(), bmp.GetHeight()))
|
||||
|
||||
pos = pos + bmp.GetHeight() + 10
|
||||
wxStaticBitmap(panel, -1, gif, wxPoint(10, pos),
|
||||
wxSize(gif.GetWidth(), gif.GetHeight()))
|
||||
|
||||
pos = pos + gif.GetHeight() + 10
|
||||
wxStaticBitmap(panel, -1, png, wxPoint(10, pos),
|
||||
wxSize(png.GetWidth(), png.GetHeight()))
|
||||
|
||||
pos = pos + png.GetHeight() + 10
|
||||
wxStaticBitmap(panel, -1, jpg, wxPoint(10, pos),
|
||||
wxSize(jpg.GetWidth(), jpg.GetHeight()))
|
||||
|
||||
return panel
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
overview = """\
|
||||
"""
|
@@ -1,142 +0,0 @@
|
||||
|
||||
from wxPython.wx import *
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
class TestLayoutConstraints(wxWindow):
|
||||
def __init__(self, parent):
|
||||
wxWindow.__init__(self, parent, -1)
|
||||
self.SetBackgroundColour(wxNamedColour("MEDIUM ORCHID"))
|
||||
|
||||
self.SetAutoLayout(true)
|
||||
EVT_BUTTON(self, 100, self.OnButton)
|
||||
|
||||
self.panelA = wxWindow(self, -1, wxDefaultPosition, wxDefaultSize,
|
||||
wxSIMPLE_BORDER)
|
||||
self.panelA.SetBackgroundColour(wxBLUE)
|
||||
txt = wxStaticText(self.panelA, -1,
|
||||
"Resize the window and see\n"
|
||||
"what happens... Notice that\n"
|
||||
"there is no OnSize handler.",
|
||||
wxPoint(5,5), wxSize(-1, 50))
|
||||
txt.SetBackgroundColour(wxBLUE)
|
||||
txt.SetForegroundColour(wxWHITE)
|
||||
|
||||
lc = wxLayoutConstraints()
|
||||
lc.top.SameAs(self, wxTop, 10)
|
||||
lc.left.SameAs(self, wxLeft, 10)
|
||||
lc.bottom.SameAs(self, wxBottom, 10)
|
||||
lc.right.PercentOf(self, wxRight, 50)
|
||||
self.panelA.SetConstraints(lc)
|
||||
|
||||
self.panelB = wxWindow(self, -1, wxDefaultPosition, wxDefaultSize,
|
||||
wxSIMPLE_BORDER)
|
||||
self.panelB.SetBackgroundColour(wxRED)
|
||||
lc = wxLayoutConstraints()
|
||||
lc.top.SameAs(self, wxTop, 10)
|
||||
lc.right.SameAs(self, wxRight, 10)
|
||||
lc.bottom.PercentOf(self, wxBottom, 30)
|
||||
lc.left.RightOf(self.panelA, 10)
|
||||
self.panelB.SetConstraints(lc)
|
||||
|
||||
self.panelC = wxWindow(self, -1, wxDefaultPosition, wxDefaultSize,
|
||||
wxSIMPLE_BORDER)
|
||||
self.panelC.SetBackgroundColour(wxWHITE)
|
||||
lc = wxLayoutConstraints()
|
||||
lc.top.Below(self.panelB, 10)
|
||||
lc.right.SameAs(self, wxRight, 10)
|
||||
lc.bottom.SameAs(self, wxBottom, 10)
|
||||
lc.left.RightOf(self.panelA, 10)
|
||||
self.panelC.SetConstraints(lc)
|
||||
|
||||
b = wxButton(self.panelA, 100, ' Panel A ')
|
||||
lc = wxLayoutConstraints()
|
||||
lc.centreX.SameAs (self.panelA, wxCentreX)
|
||||
lc.centreY.SameAs (self.panelA, wxCentreY)
|
||||
lc.height.AsIs ()
|
||||
lc.width.PercentOf (self.panelA, wxWidth, 50)
|
||||
b.SetConstraints(lc);
|
||||
|
||||
b = wxButton(self.panelB, 100, ' Panel B ')
|
||||
lc = wxLayoutConstraints()
|
||||
lc.top.SameAs (self.panelB, wxTop, 2)
|
||||
lc.right.SameAs (self.panelB, wxRight, 4)
|
||||
lc.height.AsIs ()
|
||||
lc.width.AsIs ()
|
||||
b.SetConstraints(lc);
|
||||
|
||||
self.panelD = wxWindow(self.panelC, -1, wxDefaultPosition, wxDefaultSize,
|
||||
wxSIMPLE_BORDER)
|
||||
self.panelD.SetBackgroundColour(wxGREEN)
|
||||
wxStaticText(self.panelD, -1, "Panel D", wxPoint(4, 4)).SetBackgroundColour(wxGREEN)
|
||||
|
||||
b = wxButton(self.panelC, 100, ' Panel C ')
|
||||
lc = wxLayoutConstraints()
|
||||
lc.top.Below (self.panelD)
|
||||
lc.left.RightOf (self.panelD)
|
||||
lc.height.AsIs ()
|
||||
lc.width.AsIs ()
|
||||
b.SetConstraints(lc);
|
||||
|
||||
lc = wxLayoutConstraints()
|
||||
lc.bottom.PercentOf (self.panelC, wxHeight, 50)
|
||||
lc.right.PercentOf (self.panelC, wxWidth, 50)
|
||||
lc.height.SameAs (b, wxHeight)
|
||||
lc.width.SameAs (b, wxWidth)
|
||||
self.panelD.SetConstraints(lc);
|
||||
|
||||
|
||||
def OnButton(self, event):
|
||||
wxBell()
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
win = TestLayoutConstraints(nb)
|
||||
return win
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
overview = """\
|
||||
Objects of this class can be associated with a window to define its layout constraints, with respect to siblings or its parent.
|
||||
|
||||
The class consists of the following eight constraints of class wxIndividualLayoutConstraint, some or all of which should be accessed directly to set the appropriate constraints.
|
||||
|
||||
left: represents the left hand edge of the window
|
||||
|
||||
right: represents the right hand edge of the window
|
||||
|
||||
top: represents the top edge of the window
|
||||
|
||||
bottom: represents the bottom edge of the window
|
||||
|
||||
width: represents the width of the window
|
||||
|
||||
height: represents the height of the window
|
||||
|
||||
centreX: represents the horizontal centre point of the window
|
||||
|
||||
centreY: represents the vertical centre point of the window
|
||||
|
||||
Most constraints are initially set to have the relationship wxUnconstrained, which means that their values should be calculated by looking at known constraints. The exceptions are width and height, which are set to wxAsIs to ensure that if the user does not specify a constraint, the existing width and height will be used, to be compatible with panel items which often have take a default size. If the constraint is wxAsIs, the dimension will not be changed.
|
||||
|
||||
wxLayoutConstraints()
|
||||
-------------------------------------------
|
||||
|
||||
Constructor.
|
||||
"""
|
@@ -1,102 +0,0 @@
|
||||
|
||||
from wxPython.wx import *
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
class TestListBox(wxPanel):
|
||||
def __init__(self, parent, log):
|
||||
self.log = log
|
||||
wxPanel.__init__(self, parent, -1)
|
||||
|
||||
sampleList = ['zero', 'one', 'two', 'three', 'four', 'five',
|
||||
'six', 'seven', 'eight', 'nine', 'ten', 'eleven',
|
||||
'twelve', 'thirteen', 'fourteen']
|
||||
|
||||
wxStaticText(self, -1, "This example uses the wxListBox control.",
|
||||
wxPoint(45, 10))
|
||||
|
||||
wxStaticText(self, -1, "Select one:", wxPoint(15, 50), wxSize(65, 18))
|
||||
self.lb1 = wxListBox(self, 60, wxPoint(80, 50), wxSize(80, 120),
|
||||
sampleList, wxLB_SINGLE)
|
||||
EVT_LISTBOX(self, 60, self.EvtListBox)
|
||||
EVT_LISTBOX_DCLICK(self, 60, self.EvtListBoxDClick)
|
||||
EVT_RIGHT_UP(self.lb1, self.EvtRightButton)
|
||||
self.lb1.SetSelection(0)
|
||||
|
||||
|
||||
wxStaticText(self, -1, "Select many:", wxPoint(200, 50), wxSize(65, 18))
|
||||
self.lb2 = wxListBox(self, 70, wxPoint(280, 50), wxSize(80, 120),
|
||||
sampleList, wxLB_EXTENDED)
|
||||
EVT_LISTBOX(self, 70, self.EvtMultiListBox)
|
||||
EVT_LISTBOX_DCLICK(self, 70, self.EvtListBoxDClick)
|
||||
self.lb2.SetSelection(0)
|
||||
|
||||
|
||||
def EvtListBox(self, event):
|
||||
self.log.WriteText('EvtListBox: %s\n' % event.GetString())
|
||||
|
||||
def EvtListBoxDClick(self, event):
|
||||
self.log.WriteText('EvtListBoxDClick: %s\n' % self.lb1.GetSelection())
|
||||
|
||||
def EvtMultiListBox(self, event):
|
||||
self.log.WriteText('EvtMultiListBox: %s\n' % str(self.lb2.GetSelections()))
|
||||
|
||||
def EvtRightButton(self, event):
|
||||
self.log.WriteText('EvtRightButton: %s\n' % event.GetPosition())
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
win = TestListBox(nb, log)
|
||||
return win
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
overview = """\
|
||||
A listbox is used to select one or more of a list of strings. The strings are displayed in a scrolling box, with the selected string(s) marked in reverse video. A listbox can be single selection (if an item is selected, the previous selection is removed) or multiple selection (clicking an item toggles the item on or off independently of other selections).
|
||||
|
||||
List box elements are numbered from zero.
|
||||
|
||||
wxListBox()
|
||||
---------------------
|
||||
|
||||
Default constructor.
|
||||
|
||||
wxListBox(wxWindow* parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, int n, const wxString choices[] = NULL, long style = 0, const wxValidator& validator = wxDefaultValidator, const wxString& name = "listBox")
|
||||
|
||||
Constructor, creating and showing a list box.
|
||||
|
||||
Parameters
|
||||
-------------------
|
||||
|
||||
parent = Parent window. Must not be NULL.
|
||||
|
||||
id = Window identifier. A value of -1 indicates a default value.
|
||||
|
||||
pos = Window position.
|
||||
|
||||
size = Window size. If the default size (-1, -1) is specified then the window is sized appropriately.
|
||||
|
||||
n = Number of strings with which to initialise the control.
|
||||
|
||||
choices = An array of strings with which to initialise the control.
|
||||
|
||||
style = Window style. See wxListBox.
|
||||
|
||||
validator = Window validator.
|
||||
|
||||
name = Window name.
|
||||
"""
|
@@ -1,158 +0,0 @@
|
||||
#!/bin/env python
|
||||
#----------------------------------------------------------------------------
|
||||
# Name: ListCtrl.py
|
||||
# Purpose: Testing lots of stuff, controls, window types, etc.
|
||||
#
|
||||
# Author: Robin Dunn & Gary Dumer
|
||||
#
|
||||
# Created:
|
||||
# RCS-ID: $Id$
|
||||
# Copyright: (c) 1998 by Total Control Software
|
||||
# Licence: wxWindows license
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
from wxPython.wx import *
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
class TestListCtrlPanel(wxPanel):
|
||||
def __init__(self, parent, log):
|
||||
wxPanel.__init__(self, parent, -1)
|
||||
|
||||
self.log = log
|
||||
tID = NewId()
|
||||
|
||||
self.il = wxImageList(16, 16)
|
||||
idx1 = self.il.Add(wxNoRefBitmap('bitmaps/smiles.bmp', wxBITMAP_TYPE_BMP))
|
||||
|
||||
self.list = wxListCtrl(self, tID, wxDefaultPosition, wxDefaultSize,
|
||||
wxLC_REPORT|wxSUNKEN_BORDER)
|
||||
self.list.SetImageList(self.il, wxIMAGE_LIST_SMALL)
|
||||
|
||||
self.list.SetToolTip(wxToolTip("This is a ToolTip!"))
|
||||
wxToolTip_Enable(true)
|
||||
|
||||
self.list.InsertColumn(0, "Column 0")
|
||||
self.list.InsertColumn(1, "Column 1")
|
||||
self.list.InsertColumn(2, "One More Column (2)")
|
||||
for x in range(50):
|
||||
self.list.InsertImageStringItem(x, "This is item %d" % x, idx1)
|
||||
self.list.SetStringItem(x, 1, "Col 1, item %d" % x)
|
||||
self.list.SetStringItem(x, 2, "item %d in column 2" % x)
|
||||
|
||||
self.list.SetColumnWidth(0, wxLIST_AUTOSIZE)
|
||||
self.list.SetColumnWidth(1, wxLIST_AUTOSIZE)
|
||||
self.list.SetColumnWidth(2, wxLIST_AUTOSIZE)
|
||||
|
||||
self.list.SetItemState(5, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED)
|
||||
|
||||
self.currentItem = 0
|
||||
EVT_LIST_ITEM_SELECTED(self, tID, self.OnItemSelected)
|
||||
EVT_LEFT_DCLICK(self.list, self.OnDoubleClick)
|
||||
EVT_RIGHT_DOWN(self.list, self.OnRightDown)
|
||||
|
||||
# for wxMSW
|
||||
EVT_COMMAND_RIGHT_CLICK(self.list, tID, self.OnRightClick)
|
||||
|
||||
# for wxGTK
|
||||
EVT_RIGHT_UP(self.list, self.OnRightClick)
|
||||
|
||||
|
||||
def OnRightDown(self, event):
|
||||
self.x = event.GetX()
|
||||
self.y = event.GetY()
|
||||
self.log.WriteText("x, y = %s\n" % str((self.x, self.y)))
|
||||
event.Skip()
|
||||
|
||||
def OnItemSelected(self, event):
|
||||
self.currentItem = event.m_itemIndex
|
||||
self.log.WriteText("OnItemSelected: %s\n" % self.list.GetItemText(self.currentItem))
|
||||
|
||||
def OnDoubleClick(self, event):
|
||||
self.log.WriteText("OnDoubleClick item %s\n" % self.list.GetItemText(self.currentItem))
|
||||
|
||||
|
||||
def OnRightClick(self, event):
|
||||
self.log.WriteText("OnRightClick %s\n" % self.list.GetItemText(self.currentItem))
|
||||
self.menu = wxMenu()
|
||||
tPopupID1 = 0
|
||||
tPopupID2 = 1
|
||||
tPopupID3 = 2
|
||||
self.menu.Append(tPopupID1, "One")
|
||||
self.menu.Append(tPopupID2, "Two")
|
||||
self.menu.Append(tPopupID3, "Three")
|
||||
EVT_MENU(self, tPopupID1, self.OnPopupOne)
|
||||
EVT_MENU(self, tPopupID2, self.OnPopupTwo)
|
||||
EVT_MENU(self, tPopupID3, self.OnPopupThree)
|
||||
self.PopupMenu(self.menu, self.x, self.y)
|
||||
|
||||
def OnPopupOne(self, event):
|
||||
self.log.WriteText("Popup one\n")
|
||||
|
||||
def OnPopupTwo(self, event):
|
||||
self.log.WriteText("Popup two\n")
|
||||
|
||||
def OnPopupThree(self, event):
|
||||
self.log.WriteText("Popup three\n")
|
||||
|
||||
def OnSize(self, event):
|
||||
w,h = self.GetClientSizeTuple()
|
||||
self.list.SetDimensions(0, 0, w, h)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
win = TestListCtrlPanel(nb, log)
|
||||
return win
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
overview = """\
|
||||
A list control presents lists in a number of formats: list view, report view, icon view and small icon view. Elements are numbered from zero.
|
||||
|
||||
wxListCtrl()
|
||||
------------------------
|
||||
|
||||
Default constructor.
|
||||
|
||||
wxListCtrl(wxWindow* parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxLC_ICON, const wxValidator& validator = wxDefaultValidator, const wxString& name = "listCtrl")
|
||||
|
||||
Constructor, creating and showing a list control.
|
||||
|
||||
Parameters
|
||||
-------------------
|
||||
|
||||
parent = Parent window. Must not be NULL.
|
||||
|
||||
id = Window identifier. A value of -1 indicates a default value.
|
||||
|
||||
pos = Window position.
|
||||
|
||||
size = Window size. If the default size (-1, -1) is specified then the window is sized appropriately.
|
||||
|
||||
style = Window style. See wxListCtrl.
|
||||
|
||||
validator = Window validator.
|
||||
|
||||
name = Window name.
|
||||
"""
|
@@ -1,62 +0,0 @@
|
||||
|
||||
from wxPython.wx import *
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
dlg = wxMessageDialog(frame, 'Hello from Python and wxPython!',
|
||||
'A Message Box', wxOK | wxICON_INFORMATION)
|
||||
dlg.ShowModal()
|
||||
dlg.Destroy()
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
overview = """\
|
||||
wxMessageDialog()
|
||||
----------------------------------
|
||||
|
||||
wxMessageDialog(wxWindow* parent, const wxString& message, const wxString& caption = "Message box", long style = wxOK | wxCANCEL | wxCENTRE, const wxPoint& pos = wxDefaultPosition)
|
||||
|
||||
Constructor. Use wxMessageDialog::ShowModal to show the dialog.
|
||||
|
||||
Parameters
|
||||
-------------------
|
||||
|
||||
parent = Parent window.
|
||||
|
||||
message = Message to show on the dialog.
|
||||
|
||||
caption = The dialog caption.
|
||||
|
||||
style = A dialog style (bitlist) containing flags chosen from the following:
|
||||
|
||||
wxOK Show an OK button.
|
||||
|
||||
wxCANCEL Show a Cancel button.
|
||||
|
||||
wxYES_NO Show Yes and No buttons.
|
||||
|
||||
wxCENTRE Centre the message. Not Windows.
|
||||
|
||||
wxICON_EXCLAMATION Shows an exclamation mark icon. Windows only.
|
||||
|
||||
wxICON_HAND Shows a hand icon. Windows only.
|
||||
|
||||
wxICON_QUESTION Shows a question mark icon. Windows only.
|
||||
|
||||
wxICON_INFORMATION Shows an information (i) icon. Windows only.
|
||||
|
||||
pos = Dialog position.
|
||||
"""
|
@@ -1,42 +0,0 @@
|
||||
|
||||
from wxPython.wx import *
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
class MyMiniFrame(wxMiniFrame):
|
||||
def __init__(self, parent, ID, title, pos, size, style):
|
||||
wxMiniFrame.__init__(self, parent, ID, title, pos, size, style)
|
||||
panel = wxPanel(self, -1)
|
||||
|
||||
button = wxButton(panel, 1003, "Close Me")
|
||||
button.SetPosition(wxPoint(15, 15))
|
||||
EVT_BUTTON(self, 1003, self.OnCloseMe)
|
||||
|
||||
def OnCloseMe(self, event):
|
||||
self.Close(true)
|
||||
|
||||
def OnCloseWindow(self, event):
|
||||
self.Destroy()
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
win = MyMiniFrame(frame, -1, "This is a wxMiniFrame",
|
||||
wxDefaultPosition, wxSize(200, 200),
|
||||
wxDEFAULT_FRAME_STYLE | wxTINY_CAPTION_HORIZ)
|
||||
frame.otherWin = win
|
||||
win.Show(true)
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
overview = """\
|
||||
"""
|
@@ -1,27 +0,0 @@
|
||||
|
||||
from wxPython.wx import *
|
||||
from wxPython.lib.dialogs import wxMultipleChoiceDialog
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
lst = [ 'apple', 'pear', 'banana', 'coconut', 'orange',
|
||||
'etc', 'etc..', 'etc...' ]
|
||||
dlg = wxMultipleChoiceDialog(frame,
|
||||
"Pick some from\n this list\nblah blah...",
|
||||
"m.s.d.", lst)
|
||||
if (dlg.ShowModal() == wxID_OK):
|
||||
print "Selection:", dlg.GetValue(), " -> ", dlg.GetValueString()
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
overview = """\
|
||||
"""
|
@@ -1,84 +0,0 @@
|
||||
|
||||
from wxPython.wx import *
|
||||
import ColorPanel
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
|
||||
testWin = wxNotebook(nb, -1)
|
||||
|
||||
win = ColorPanel.ColoredPanel(testWin, wxBLUE)
|
||||
testWin.AddPage(win, "Blue")
|
||||
st = wxStaticText(win, -1,
|
||||
"You can put nearly any type of window here!",
|
||||
wxPoint(10, 10))
|
||||
st.SetForegroundColour(wxWHITE)
|
||||
st.SetBackgroundColour(wxBLUE)
|
||||
|
||||
win = ColorPanel.ColoredPanel(testWin, wxRED)
|
||||
testWin.AddPage(win, "Red")
|
||||
|
||||
win = ColorPanel.ColoredPanel(testWin, wxGREEN)
|
||||
testWin.AddPage(win, "Green")
|
||||
|
||||
win = ColorPanel.ColoredPanel(testWin, wxCYAN)
|
||||
testWin.AddPage(win, "Cyan")
|
||||
|
||||
win = ColorPanel.ColoredPanel(testWin, wxWHITE)
|
||||
testWin.AddPage(win, "White")
|
||||
|
||||
win = ColorPanel.ColoredPanel(testWin, wxBLACK)
|
||||
testWin.AddPage(win, "Black")
|
||||
|
||||
win = ColorPanel.ColoredPanel(testWin, wxNamedColour('MIDNIGHT BLUE'))
|
||||
testWin.AddPage(win, "MIDNIGHT BLUE")
|
||||
|
||||
win = ColorPanel.ColoredPanel(testWin, wxNamedColour('INDIAN RED'))
|
||||
testWin.AddPage(win, "INDIAN RED")
|
||||
|
||||
return testWin
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
overview = """\
|
||||
This class represents a notebook control, which manages multiple windows with associated tabs.
|
||||
|
||||
To use the class, create a wxNotebook object and call AddPage or InsertPage, passing a window to be used as the page. Do not explicitly delete the window for a page that is currently managed by wxNotebook.
|
||||
|
||||
wxNotebook()
|
||||
-------------------------
|
||||
|
||||
Default constructor.
|
||||
|
||||
wxNotebook(wxWindow* parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size, long style = 0, const wxString& name = "notebook")
|
||||
|
||||
Constructs a notebook control.
|
||||
|
||||
Parameters
|
||||
-------------------
|
||||
|
||||
parent = The parent window. Must be non-NULL.
|
||||
|
||||
id = The window identifier.
|
||||
|
||||
pos = The window position.
|
||||
|
||||
size = The window size.
|
||||
|
||||
style = The window style. Its value is a bit list of zero or more of wxTC_MULTILINE, wxTC_RIGHTJUSTIFY, wxTC_FIXEDWIDTH and wxTC_OWNERDRAW.
|
||||
"""
|
@@ -1,33 +0,0 @@
|
||||
|
||||
from wxPython.wx import *
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
data = wxPageSetupDialogData()
|
||||
data.SetMarginTopLeft(wxPoint(50,50))
|
||||
data.SetMarginBottomRight(wxPoint(50,50))
|
||||
dlg = wxPageSetupDialog(frame, data)
|
||||
if dlg.ShowModal() == wxID_OK:
|
||||
data = dlg.GetPageSetupData()
|
||||
tl = data.GetMarginTopLeft()
|
||||
br = data.GetMarginBottomRight()
|
||||
log.WriteText('Margins are: %s %s\n' % (str(tl), str(br)))
|
||||
dlg.Destroy()
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
overview = """\
|
||||
"""
|
@@ -1,39 +0,0 @@
|
||||
|
||||
from wxPython.lib.wxPlotCanvas import *
|
||||
from wxPython.lib import wxPlotCanvas
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
def _InitObjects():
|
||||
# 100 points sin function, plotted as green circles
|
||||
data1 = 2.*Numeric.pi*Numeric.arange(200)/200.
|
||||
data1.shape = (100, 2)
|
||||
data1[:,1] = Numeric.sin(data1[:,0])
|
||||
markers1 = PolyMarker(data1, color='green', marker='circle',size=1)
|
||||
|
||||
# 50 points cos function, plotted as red line
|
||||
data1 = 2.*Numeric.pi*Numeric.arange(100)/100.
|
||||
data1.shape = (50,2)
|
||||
data1[:,1] = Numeric.cos(data1[:,0])
|
||||
lines = PolyLine(data1, color='red')
|
||||
|
||||
# A few more points...
|
||||
pi = Numeric.pi
|
||||
markers2 = PolyMarker([(0., 0.), (pi/4., 1.), (pi/2, 0.),
|
||||
(3.*pi/4., -1)], color='blue',
|
||||
fillcolor='green', marker='cross')
|
||||
|
||||
return PlotGraphics([markers1, lines, markers2])
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
win = PlotCanvas(nb)
|
||||
win.draw(_InitObjects(),'automatic','automatic');
|
||||
return win
|
||||
|
||||
overview = wxPlotCanvas.__doc__
|
||||
|
||||
#---------------------------------------------------------------------------
|
@@ -1,31 +0,0 @@
|
||||
|
||||
from wxPython.wx import *
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
data = wxPrintDialogData()
|
||||
data.EnablePrintToFile(true)
|
||||
data.EnablePageNumbers(true)
|
||||
data.EnableSelection(true)
|
||||
dlg = wxPrintDialog(frame, data)
|
||||
if dlg.ShowModal() == wxID_OK:
|
||||
log.WriteText('\n')
|
||||
dlg.Destroy()
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
overview = """\
|
||||
"""
|
@@ -1,38 +0,0 @@
|
||||
|
||||
from wxPython.wx import *
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
max = 20
|
||||
dlg = wxProgressDialog("Progress dialog example",
|
||||
"An informative message",
|
||||
max,
|
||||
frame,
|
||||
wxPD_CAN_ABORT | wxPD_APP_MODAL)
|
||||
|
||||
keepGoing = true
|
||||
count = 0
|
||||
while keepGoing and count <= max:
|
||||
count = count + 1
|
||||
wxSleep(1)
|
||||
|
||||
if count == max / 2:
|
||||
keepGoing = dlg.Update(count, "Half-time!")
|
||||
else:
|
||||
keepGoing = dlg.Update(count)
|
||||
|
||||
dlg.Destroy()
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
overview = """\
|
||||
"""
|
@@ -1,76 +0,0 @@
|
||||
|
||||
from wxPython.wx import *
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
class TestRadioButtons(wxPanel):
|
||||
def __init__(self, parent, log):
|
||||
self.log = log
|
||||
wxPanel.__init__(self, parent, -1)
|
||||
|
||||
sampleList = ['zero', 'one', 'two', 'three', 'four', 'five',
|
||||
'six', 'seven', 'eight']
|
||||
|
||||
rb = wxRadioBox(self, 30, "wxRadioBox", wxPoint(35, 30), wxDefaultSize,
|
||||
sampleList, 3, wxRA_SPECIFY_COLS | wxNO_BORDER)
|
||||
EVT_RADIOBOX(self, 30, self.EvtRadioBox)
|
||||
|
||||
|
||||
def EvtRadioBox(self, event):
|
||||
self.log.WriteText('EvtRadioBox: %d\n' % event.GetInt())
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
win = TestRadioButtons(nb, log)
|
||||
return win
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
overview = """\
|
||||
A radio box item is used to select one of number of mutually exclusive choices. It is displayed as a vertical column or horizontal row of labelled buttons.
|
||||
|
||||
wxRadioBox()
|
||||
----------------------
|
||||
|
||||
Default constructor.
|
||||
|
||||
wxRadioBox(wxWindow* parent, wxWindowID id, const wxString& label, const wxPoint& point = wxDefaultPosition, const wxSize& size = wxDefaultSize, int n = 0, const wxString choices[] = NULL, int majorDimension = 0, long style = wxRA_SPECIFY_COLS, const wxValidator& validator = wxDefaultValidator, const wxString& name = "radioBox")
|
||||
|
||||
Constructor, creating and showing a radiobox.
|
||||
|
||||
Parameters
|
||||
-------------------
|
||||
|
||||
parent = Parent window. Must not be NULL.
|
||||
|
||||
id = Window identifier. A value of -1 indicates a default value.
|
||||
|
||||
label = Label for the static box surrounding the radio buttons.
|
||||
|
||||
pos = Window position. If the position (-1, -1) is specified then a default position is chosen.
|
||||
|
||||
size = Window size. If the default size (-1, -1) is specified then a default size is chosen.
|
||||
|
||||
n = Number of choices with which to initialize the radiobox.
|
||||
|
||||
choices = An array of choices with which to initialize the radiobox.
|
||||
|
||||
majorDimension = Specifies the maximum number of rows (if style contains wxRA_SPECIFY_ROWS) or columns (if style contains wxRA_SPECIFY_COLS) for a two-dimensional radiobox.
|
||||
|
||||
style = Window style. See wxRadioBox.
|
||||
|
||||
validator = Window validator.
|
||||
|
||||
name = Window name.
|
||||
"""
|
@@ -1,152 +0,0 @@
|
||||
|
||||
from wxPython.wx import *
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
class TestSashWindow(wxPanel):
|
||||
ID_WINDOW_TOP = 5100
|
||||
ID_WINDOW_LEFT1 = 5101
|
||||
ID_WINDOW_LEFT2 = 5102
|
||||
ID_WINDOW_BOTTOM = 5103
|
||||
|
||||
|
||||
def __init__(self, parent, log):
|
||||
wxPanel.__init__(self, parent, -1)
|
||||
|
||||
self.log = log
|
||||
|
||||
EVT_SASH_DRAGGED_RANGE(self, self.ID_WINDOW_TOP,
|
||||
self.ID_WINDOW_BOTTOM, self.OnSashDrag)
|
||||
|
||||
|
||||
# Create some layout windows
|
||||
# A window like a toolbar
|
||||
win = wxSashLayoutWindow(self, self.ID_WINDOW_TOP, wxDefaultPosition,
|
||||
wxSize(200, 30), wxNO_BORDER|wxSW_3D)
|
||||
win.SetDefaultSize(wxSize(1000, 30))
|
||||
win.SetOrientation(wxLAYOUT_HORIZONTAL)
|
||||
win.SetAlignment(wxLAYOUT_TOP)
|
||||
win.SetBackgroundColour(wxColour(255, 0, 0))
|
||||
win.SetSashVisible(wxSASH_BOTTOM, true)
|
||||
|
||||
self.topWindow = win
|
||||
|
||||
|
||||
# A window like a statusbar
|
||||
win = wxSashLayoutWindow(self, self.ID_WINDOW_BOTTOM,
|
||||
wxDefaultPosition, wxSize(200, 30),
|
||||
wxNO_BORDER|wxSW_3D)
|
||||
win.SetDefaultSize(wxSize(1000, 30))
|
||||
win.SetOrientation(wxLAYOUT_HORIZONTAL)
|
||||
win.SetAlignment(wxLAYOUT_BOTTOM)
|
||||
win.SetBackgroundColour(wxColour(0, 0, 255))
|
||||
win.SetSashVisible(wxSASH_TOP, true)
|
||||
|
||||
self.bottomWindow = win
|
||||
|
||||
|
||||
# A window to the left of the client window
|
||||
win = wxSashLayoutWindow(self, self.ID_WINDOW_LEFT1,
|
||||
wxDefaultPosition, wxSize(200, 30),
|
||||
wxNO_BORDER|wxSW_3D)
|
||||
win.SetDefaultSize(wxSize(120, 1000))
|
||||
win.SetOrientation(wxLAYOUT_VERTICAL)
|
||||
win.SetAlignment(wxLAYOUT_LEFT)
|
||||
win.SetBackgroundColour(wxColour(0, 255, 0))
|
||||
win.SetSashVisible(wxSASH_RIGHT, TRUE)
|
||||
win.SetExtraBorderSize(10)
|
||||
|
||||
textWindow = wxTextCtrl(win, -1, "", wxDefaultPosition, wxDefaultSize,
|
||||
wxTE_MULTILINE|wxSUNKEN_BORDER)
|
||||
textWindow.SetValue("A help window")
|
||||
|
||||
self.leftWindow1 = win
|
||||
|
||||
|
||||
# Another window to the left of the client window
|
||||
win = wxSashLayoutWindow(self, self.ID_WINDOW_LEFT2,
|
||||
wxDefaultPosition, wxSize(200, 30),
|
||||
wxNO_BORDER|wxSW_3D)
|
||||
win.SetDefaultSize(wxSize(120, 1000))
|
||||
win.SetOrientation(wxLAYOUT_VERTICAL)
|
||||
win.SetAlignment(wxLAYOUT_LEFT)
|
||||
win.SetBackgroundColour(wxColour(0, 255, 255))
|
||||
win.SetSashVisible(wxSASH_RIGHT, TRUE)
|
||||
|
||||
self.leftWindow2 = win
|
||||
|
||||
|
||||
def OnSashDrag(self, event):
|
||||
if event.GetDragStatus() == wxSASH_STATUS_OUT_OF_RANGE:
|
||||
return
|
||||
|
||||
eID = event.GetId()
|
||||
if eID == self.ID_WINDOW_TOP:
|
||||
self.topWindow.SetDefaultSize(wxSize(1000, event.GetDragRect().height))
|
||||
|
||||
elif eID == self.ID_WINDOW_LEFT1:
|
||||
self.leftWindow1.SetDefaultSize(wxSize(event.GetDragRect().width, 1000))
|
||||
|
||||
|
||||
elif eID == self.ID_WINDOW_LEFT2:
|
||||
self.leftWindow2.SetDefaultSize(wxSize(event.GetDragRect().width, 1000))
|
||||
|
||||
elif eID == self.ID_WINDOW_BOTTOM:
|
||||
self.bottomWindow.SetDefaultSize(wxSize(1000, event.GetDragRect().height))
|
||||
|
||||
wxLayoutAlgorithm().LayoutWindow(self)
|
||||
|
||||
|
||||
def OnSize(self, event):
|
||||
wxLayoutAlgorithm().LayoutWindow(self)
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
win = TestSashWindow(nb, log)
|
||||
return win
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
overview = """\
|
||||
wxSashLayoutWindow responds to OnCalculateLayout events generated by wxLayoutAlgorithm. It allows the application to use simple accessors to specify how the window should be laid out, rather than having to respond to events. The fact that the class derives from wxSashWindow allows sashes to be used if required, to allow the windows to be user-resizable.
|
||||
|
||||
wxSashLayoutWindow()
|
||||
-------------------------------------------
|
||||
|
||||
Default constructor.
|
||||
|
||||
wxSashLayoutWindow(wxSashLayoutWindow* parent, wxSashLayoutWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxCLIP_CHILDREN | wxSW_3D, const wxString& name = "layoutWindow")
|
||||
|
||||
Constructs a sash layout window, which can be a child of a frame, dialog or any other non-control window.
|
||||
|
||||
Parameters
|
||||
-------------------
|
||||
|
||||
parent = Pointer to a parent window.
|
||||
|
||||
id = Window identifier. If -1, will automatically create an identifier.
|
||||
|
||||
pos = Window position. wxDefaultPosition is (-1, -1) which indicates that wxSashLayoutWindows should generate a default position for the window. If using the wxSashLayoutWindow class directly, supply an actual position.
|
||||
|
||||
size = Window size. wxDefaultSize is (-1, -1) which indicates that wxSashLayoutWindows should generate a default size for the window.
|
||||
|
||||
style = Window style. For window styles, please see wxSashLayoutWindow.
|
||||
|
||||
name = Window name.
|
||||
"""
|
@@ -1,24 +0,0 @@
|
||||
|
||||
from wxPython.wx import *
|
||||
from wxPython.lib.dialogs import wxScrolledMessageDialog
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
f = open("Main.py", "r")
|
||||
msg = f.read()
|
||||
dlg = wxScrolledMessageDialog(frame, msg, "message test")
|
||||
dlg.ShowModal()
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
overview = """\
|
||||
"""
|
@@ -1,129 +0,0 @@
|
||||
|
||||
from wxPython.wx import *
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
class MyCanvas(wxScrolledWindow):
|
||||
def __init__(self, parent):
|
||||
wxScrolledWindow.__init__(self, parent, -1, wxPoint(0, 0), wxPyDefaultSize, wxSUNKEN_BORDER)
|
||||
|
||||
self.lines = []
|
||||
self.maxWidth = 1000
|
||||
self.maxHeight = 1000
|
||||
|
||||
self.SetBackgroundColour(wxNamedColor("WHITE"))
|
||||
self.Connect(-1, -1, wxEVT_LEFT_DOWN, self.OnLeftButtonEvent)
|
||||
self.Connect(-1, -1, wxEVT_LEFT_UP, self.OnLeftButtonEvent)
|
||||
self.Connect(-1, -1, wxEVT_MOTION, self.OnLeftButtonEvent)
|
||||
|
||||
self.SetCursor(wxStockCursor(wxCURSOR_PENCIL))
|
||||
bmp = wxBitmap('bitmaps/test2.bmp', wxBITMAP_TYPE_BMP)
|
||||
self.bmp = bmp
|
||||
|
||||
self.SetScrollbars(20, 20, self.maxWidth/20, self.maxHeight/20)
|
||||
|
||||
def getWidth(self):
|
||||
return self.maxWidth
|
||||
|
||||
def getHeight(self):
|
||||
return self.maxHeight
|
||||
|
||||
|
||||
def OnPaint(self, event):
|
||||
dc = wxPaintDC(self)
|
||||
self.PrepareDC(dc)
|
||||
self.DoDrawing(dc)
|
||||
|
||||
|
||||
def DoDrawing(self, dc):
|
||||
dc.BeginDrawing()
|
||||
pen1 = wxPen(wxNamedColour('RED'))
|
||||
dc.SetPen(pen1)
|
||||
dc.DrawRectangle(5, 5, 50, 50)
|
||||
|
||||
dc.SetBrush(wxLIGHT_GREY_BRUSH)
|
||||
dc.SetPen(wxPen(wxNamedColour('BLUE'), 4))
|
||||
dc.DrawRectangle(15, 15, 50, 50)
|
||||
|
||||
font = wxFont(14, wxSWISS, wxNORMAL, wxNORMAL)
|
||||
dc.SetFont(font)
|
||||
dc.SetTextForeground(wxColour(0xFF, 0x20, 0xFF))
|
||||
te = dc.GetTextExtent("Hello World")
|
||||
dc.DrawText("Hello World", 60, 65)
|
||||
|
||||
dc.SetPen(wxPen(wxNamedColour('VIOLET'), 4))
|
||||
dc.DrawLine(5, 65+te[1], 60+te[0], 65+te[1])
|
||||
|
||||
lst = [(100,110), (150,110), (150,160), (100,160)]
|
||||
dc.DrawLines(lst, -60)
|
||||
dc.SetPen(wxGREY_PEN)
|
||||
dc.DrawPolygon(lst, 75)
|
||||
dc.SetPen(wxGREEN_PEN)
|
||||
dc.DrawSpline(lst+[(100,100)])
|
||||
|
||||
dc.DrawBitmap(self.bmp, 200, 20)
|
||||
dc.SetTextForeground(wxColour(0, 0xFF, 0x80))
|
||||
dc.DrawText("a bitmap", 200, 85)
|
||||
|
||||
self.DrawSavedLines(dc)
|
||||
dc.EndDrawing()
|
||||
|
||||
|
||||
def DrawSavedLines(self, dc):
|
||||
dc.SetPen(wxPen(wxNamedColour('MEDIUM FOREST GREEN'), 4))
|
||||
for line in self.lines:
|
||||
for coords in line:
|
||||
apply(dc.DrawLine, coords)
|
||||
|
||||
|
||||
def SetXY(self, event):
|
||||
self.x, self.y = self.ConvertEventCoords(event)
|
||||
|
||||
def ConvertEventCoords(self, event):
|
||||
xView, yView = self.ViewStart()
|
||||
xDelta, yDelta = self.GetScrollPixelsPerUnit()
|
||||
return (event.GetX() + (xView * xDelta),
|
||||
event.GetY() + (yView * yDelta))
|
||||
|
||||
def OnLeftButtonEvent(self, event):
|
||||
if event.LeftDown():
|
||||
self.SetXY(event)
|
||||
self.curLine = []
|
||||
|
||||
elif event.Dragging():
|
||||
dc = wxClientDC(self)
|
||||
self.PrepareDC(dc)
|
||||
dc.BeginDrawing()
|
||||
dc.SetPen(wxPen(wxNamedColour('MEDIUM FOREST GREEN'), 4))
|
||||
coords = (self.x, self.y) + self.ConvertEventCoords(event)
|
||||
self.curLine.append(coords)
|
||||
apply(dc.DrawLine, coords)
|
||||
self.SetXY(event)
|
||||
dc.EndDrawing()
|
||||
|
||||
elif event.LeftUp():
|
||||
self.lines.append(self.curLine)
|
||||
self.curLine = []
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
win = MyCanvas(nb)
|
||||
return win
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
overview = """\
|
||||
"""
|
@@ -1,59 +0,0 @@
|
||||
|
||||
from wxPython.wx import *
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
dlg = wxSingleChoiceDialog(frame, 'Test Single Choice', 'The Caption',
|
||||
['zero', 'one', 'two', 'three', 'four', 'five',
|
||||
'six', 'seven', 'eight'])
|
||||
if dlg.ShowModal() == wxID_OK:
|
||||
log.WriteText('You selected: %s\n' % dlg.GetStringSelection())
|
||||
dlg.Destroy()
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
overview = """\
|
||||
This class represents a dialog that shows a list of strings, and allows the user to select one. Double-clicking on a list item is equivalent to single-clicking and then pressing OK.
|
||||
|
||||
wxSingleChoiceDialog()
|
||||
---------------------------------------------
|
||||
|
||||
wxSingleChoiceDialog(wxWindow* parent, const wxString& message, const wxString& caption, int n, const wxString* choices, char** clientData = NULL, long style = wxOK | wxCANCEL | wxCENTRE, const wxPoint& pos = wxDefaultPosition)
|
||||
|
||||
Constructor, taking an array of wxString choices and optional client data.
|
||||
|
||||
Parameters
|
||||
-------------------
|
||||
|
||||
parent = Parent window.
|
||||
|
||||
message = Message to show on the dialog.
|
||||
|
||||
caption = The dialog caption.
|
||||
n = The number of choices.
|
||||
|
||||
choices = An array of strings, or a string list, containing the choices.
|
||||
|
||||
style = A dialog style (bitlist) containing flags chosen from the following:
|
||||
|
||||
wxOK Show an OK button.
|
||||
|
||||
wxCANCEL Show a Cancel button.
|
||||
|
||||
wxCENTRE Centre the message. Not Windows.
|
||||
|
||||
pos = Dialog position.
|
||||
"""
|
@@ -1,41 +0,0 @@
|
||||
|
||||
from wxPython.wx import *
|
||||
|
||||
import string
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
class TestPanel(wxPanel):
|
||||
def __init__(self, parent, log):
|
||||
wxPanel.__init__(self, parent, -1)
|
||||
self.log = log
|
||||
self.count = 0
|
||||
|
||||
wxStaticText(self, -1, "This is a wxSlider.", wxPoint(45, 15))
|
||||
|
||||
slider = wxSlider(self, 100, 25, 1, 100, wxPoint(30, 60),
|
||||
wxSize(250, -1),
|
||||
wxSL_HORIZONTAL | wxSL_AUTOTICKS | wxSL_LABELS )
|
||||
slider.SetTickFreq(5, 1)
|
||||
|
||||
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
win = TestPanel(nb, log)
|
||||
return win
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
overview = """\
|
||||
"""
|
@@ -1,49 +0,0 @@
|
||||
|
||||
from wxPython.wx import *
|
||||
|
||||
import string
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
class TestPanel(wxPanel):
|
||||
def __init__(self, parent, log):
|
||||
wxPanel.__init__(self, parent, -1)
|
||||
self.log = log
|
||||
self.count = 0
|
||||
|
||||
wxStaticText(self, -1, "This example uses the wxSpinButton control.",
|
||||
wxPoint(45, 15))
|
||||
|
||||
|
||||
self.text = wxTextCtrl(self, -1, "1", wxPoint(30, 50), wxSize(60, -1))
|
||||
h = self.text.GetSize().height
|
||||
self.spin = wxSpinButton(self, 20, wxPoint(92, 50), wxSize(h*2, h))
|
||||
self.spin.SetRange(1, 100)
|
||||
self.spin.SetValue(1)
|
||||
|
||||
EVT_SPIN(self, 20, self.OnSpin)
|
||||
|
||||
|
||||
def OnSpin(self, event):
|
||||
self.text.SetValue(str(event.GetPosition()))
|
||||
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
win = TestPanel(nb, log)
|
||||
return win
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
overview = """\
|
||||
"""
|
@@ -1,67 +0,0 @@
|
||||
|
||||
from wxPython.wx import *
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
splitter = wxSplitterWindow(nb, -1)
|
||||
|
||||
p1 = wxWindow(splitter, -1)
|
||||
p1.SetBackgroundColour(wxRED)
|
||||
wxStaticText(p1, -1, "Panel One", wxPoint(5,5)).SetBackgroundColour(wxRED)
|
||||
|
||||
p2 = wxWindow(splitter, -1)
|
||||
p2.SetBackgroundColour(wxBLUE)
|
||||
wxStaticText(p2, -1, "Panel Two", wxPoint(5,5)).SetBackgroundColour(wxBLUE)
|
||||
|
||||
splitter.SplitVertically(p1, p2)
|
||||
splitter.SetSashPosition(100)
|
||||
splitter.SetMinimumPaneSize(20)
|
||||
|
||||
return splitter
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
overview = """\
|
||||
This class manages up to two subwindows. The current view can be split into two programmatically (perhaps from a menu command), and unsplit either programmatically or via the wxSplitterWindow user interface.
|
||||
|
||||
wxSplitterWindow()
|
||||
-----------------------------------
|
||||
|
||||
Default constructor.
|
||||
|
||||
wxSplitterWindow(wxWindow* parent, wxWindowID id, int x, const wxPoint& point = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style=wxSP_3D, const wxString& name = "splitterWindow")
|
||||
|
||||
Constructor for creating the window.
|
||||
|
||||
Parameters
|
||||
-------------------
|
||||
|
||||
parent = The parent of the splitter window.
|
||||
|
||||
id = The window identifier.
|
||||
|
||||
pos = The window position.
|
||||
|
||||
size = The window size.
|
||||
|
||||
style = The window style. See wxSplitterWindow.
|
||||
|
||||
name = The window name.
|
||||
"""
|
@@ -1,41 +0,0 @@
|
||||
|
||||
from wxPython.wx import *
|
||||
|
||||
import string
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
class TestPanel(wxPanel):
|
||||
def __init__(self, parent, log):
|
||||
wxPanel.__init__(self, parent, -1)
|
||||
self.log = log
|
||||
self.count = 0
|
||||
|
||||
wxStaticText(self, -1, "This is a wxStaticBitmap.", wxPoint(45, 15))
|
||||
|
||||
bmp = wxBitmap('bitmaps/test2.bmp', wxBITMAP_TYPE_BMP)
|
||||
wxStaticBitmap(self, -1, bmp, wxPoint(80, 50),
|
||||
wxSize(bmp.GetWidth(), bmp.GetHeight()))
|
||||
|
||||
|
||||
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
win = TestPanel(nb, log)
|
||||
return win
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
overview = """\
|
||||
"""
|
@@ -1,73 +0,0 @@
|
||||
|
||||
from wxPython.wx import *
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
class TestPanel(wxPanel):
|
||||
def __init__(self, parent):
|
||||
wxPanel.__init__(self, parent, -1)
|
||||
|
||||
wxStaticText(self, -1, "This is an example of static text",
|
||||
wxPoint(20, 10))
|
||||
|
||||
wxStaticText(self, -1, "using the wxStaticText Control.",
|
||||
wxPoint(20, 30))
|
||||
|
||||
wxStaticText(self, -1, "Is this yellow?",
|
||||
wxPoint(20, 70)).SetBackgroundColour(wxNamedColour('Yellow'))
|
||||
|
||||
str = "This is a different font."
|
||||
text = wxStaticText(self, -1, str, wxPoint(20, 100))
|
||||
font = wxFont(20, wxSWISS, wxNORMAL, wxNORMAL, false, "Arial")
|
||||
w, h, d, e = self.GetFullTextExtent(str, font)
|
||||
text.SetFont(font)
|
||||
text.SetSize(wxSize(w, h))
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
panel = TestPanel(nb)
|
||||
return panel
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
overview = '''\
|
||||
A static text control displays one or more lines of read-only text.
|
||||
|
||||
wxStaticText()
|
||||
-------------------------
|
||||
|
||||
Default constructor.
|
||||
|
||||
wxStaticText(wxWindow* parent, wxWindowID id, const wxString& label = "", const wxPoint& pos, const wxSize& size = wxDefaultSize, long style = 0, const wxString& name = "staticText")
|
||||
|
||||
Constructor, creating and showing a text control.
|
||||
|
||||
Parameters
|
||||
-------------------
|
||||
|
||||
parent = Parent window. Should not be NULL.
|
||||
|
||||
id = Control identifier. A value of -1 denotes a default value.
|
||||
|
||||
label = Text label.
|
||||
|
||||
pos = Window position.
|
||||
|
||||
size = Window size.
|
||||
|
||||
style = Window style. See wxStaticText.
|
||||
|
||||
name = Window name.
|
||||
'''
|
||||
|
||||
#---------------------------------------------------------------------------
|
@@ -1,114 +0,0 @@
|
||||
|
||||
from wxPython.wx import *
|
||||
|
||||
import time
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
class CustomStatusBar(wxStatusBar):
|
||||
def __init__(self, parent, log):
|
||||
wxStatusBar.__init__(self, parent, -1)
|
||||
self.SetFieldsCount(3)
|
||||
self.log = log
|
||||
|
||||
self.SetStatusText("A Custom StatusBar...", 0)
|
||||
|
||||
self.cb = wxCheckBox(self, 1001, "toggle clock")
|
||||
EVT_CHECKBOX(self, 1001, self.OnToggleClock)
|
||||
self.cb.SetValue(true)
|
||||
|
||||
# figure out how tall to make it.
|
||||
dc = wxClientDC(self)
|
||||
dc.SetFont(self.GetFont())
|
||||
(w,h) = dc.GetTextExtent('X')
|
||||
h = int(h * 1.8)
|
||||
self.SetSize(wxSize(100, h))
|
||||
|
||||
# start our timer
|
||||
self.timer = wxPyTimer(self.Notify)
|
||||
self.timer.Start(1000)
|
||||
self.Notify()
|
||||
|
||||
|
||||
# Time-out handler
|
||||
def Notify(self):
|
||||
t = time.localtime(time.time())
|
||||
st = time.strftime("%d-%b-%Y %I:%M:%S", t)
|
||||
self.SetStatusText(st, 2)
|
||||
self.log.WriteText("tick...\n")
|
||||
|
||||
# the checkbox was clicked
|
||||
def OnToggleClock(self, event):
|
||||
if self.cb.GetValue():
|
||||
self.timer.Start(1000)
|
||||
self.Notify()
|
||||
else:
|
||||
self.timer.Stop()
|
||||
|
||||
|
||||
# reposition the checkbox
|
||||
def OnSize(self, event):
|
||||
rect = self.GetFieldRect(1)
|
||||
self.cb.SetPosition(wxPoint(rect.x+2, rect.y+2))
|
||||
self.cb.SetSize(wxSize(rect.width-4, rect.height-4))
|
||||
|
||||
|
||||
|
||||
class TestCustomStatusBar(wxFrame):
|
||||
def __init__(self, parent, log):
|
||||
wxFrame.__init__(self, parent, -1, 'Test Custom StatusBar',
|
||||
wxPoint(0,0), wxSize(500, 300))
|
||||
wxWindow(self, -1).SetBackgroundColour(wxNamedColour("WHITE"))
|
||||
|
||||
self.sb = CustomStatusBar(self, log)
|
||||
self.SetStatusBar(self.sb)
|
||||
|
||||
def OnCloseWindow(self, event):
|
||||
self.sb.timer.Stop()
|
||||
del self.sb.timer
|
||||
self.Destroy()
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
win = TestCustomStatusBar(frame, log)
|
||||
frame.otherWin = win
|
||||
win.Show(true)
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
overview = """\
|
||||
A status bar is a narrow window that can be placed along the bottom of a frame to give small amounts of status information. It can contain one or more fields, one or more of which can be variable length according to the size of the window.
|
||||
|
||||
wxStatusBar()
|
||||
----------------------------
|
||||
|
||||
Default constructor.
|
||||
|
||||
wxStatusBar(wxWindow* parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = 0, const wxString& name = "statusBar")
|
||||
|
||||
Constructor, creating the window.
|
||||
|
||||
Parameters
|
||||
-------------------
|
||||
|
||||
parent = The window parent, usually a frame.
|
||||
|
||||
id = The window identifier. It may take a value of -1 to indicate a default value.
|
||||
|
||||
pos = The window position. A value of (-1, -1) indicates a default position, chosen by either the windowing system or wxWindows, depending on platform.
|
||||
|
||||
size = The window size. A value of (-1, -1) indicates a default size, chosen by either the windowing system or wxWindows, depending on platform.
|
||||
|
||||
style = The window style. See wxStatusBar.
|
||||
|
||||
name = The name of the window. This parameter is used to associate a name with the item, allowing the application user to set Motif resource values for individual windows.
|
||||
"""
|
@@ -1,40 +0,0 @@
|
||||
|
||||
from wxPython.wx import *
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
class TestPanel(wxPanel):
|
||||
def __init__(self, parent, log):
|
||||
wxPanel.__init__(self, parent, -1)
|
||||
self.log = log
|
||||
|
||||
wxStaticText(self, -1, "wxTextCtrl", wxPoint(5, 25), wxSize(75, 20))
|
||||
wxTextCtrl(self, 10, "", wxPoint(80, 25), wxSize(150, 20))
|
||||
EVT_TEXT(self, 10, self.EvtText)
|
||||
|
||||
wxStaticText(self, -1, "Passsword", wxPoint(5, 50), wxSize(75, 20))
|
||||
wxTextCtrl(self, 20, "", wxPoint(80, 50), wxSize(150, 20), wxTE_PASSWORD)
|
||||
EVT_TEXT(self, 20, self.EvtText)
|
||||
|
||||
wxStaticText(self, -1, "Multi-line", wxPoint(5, 75), wxSize(75, 20))
|
||||
wxTextCtrl(self, 30, "", wxPoint(80, 75), wxSize(200, 150), wxTE_MULTILINE)
|
||||
EVT_TEXT(self, 30, self.EvtText)
|
||||
|
||||
def EvtText(self, event):
|
||||
self.log.WriteText('EvtText: %s\n' % event.GetString())
|
||||
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
win = TestPanel(nb, log)
|
||||
return win
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
overview = """\
|
||||
"""
|
@@ -1,50 +0,0 @@
|
||||
|
||||
from wxPython.wx import *
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
dlg = wxTextEntryDialog(frame, 'What is your favorite programming language?',
|
||||
'Duh??', 'Python')
|
||||
dlg.SetValue("Python is the best!") #### this doesn't work?
|
||||
if dlg.ShowModal() == wxID_OK:
|
||||
log.WriteText('You entered: %s\n' % dlg.GetValue())
|
||||
dlg.Destroy()
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
overview = """\
|
||||
This class represents a dialog that requests a one-line text string from the user. It is implemented as a generic wxWindows dialog.
|
||||
|
||||
wxTextEntryDialog()
|
||||
----------------------------------
|
||||
|
||||
wxTextEntryDialog(wxWindow* parent, const wxString& message, const wxString& caption = "Please enter text", const wxString& defaultValue = "", long style = wxOK | wxCANCEL | wxCENTRE, const wxPoint& pos = wxDefaultPosition)
|
||||
|
||||
Constructor. Use wxTextEntryDialog::ShowModal to show the dialog.
|
||||
|
||||
Parameters
|
||||
-------------------
|
||||
|
||||
parent = Parent window.
|
||||
|
||||
message = Message to show on the dialog.
|
||||
|
||||
defaultValue = The default value, which may be the empty string.
|
||||
|
||||
style = A dialog style, specifying the buttons (wxOK, wxCANCEL) and an optional wxCENTRE style.
|
||||
|
||||
pos = Dialog position.
|
||||
"""
|
@@ -1,67 +0,0 @@
|
||||
|
||||
from wxPython.wx import *
|
||||
|
||||
import time
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
class TestTimer(wxTimer):
|
||||
def __init__(self, log = None):
|
||||
wxTimer.__init__(self)
|
||||
self.log = log
|
||||
|
||||
def Notify(self):
|
||||
wxBell()
|
||||
if self.log:
|
||||
self.log.WriteText('beep!\n')
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
_timer = TestTimer()
|
||||
|
||||
|
||||
class TestTimerWin(wxPanel):
|
||||
def __init__(self, parent, log):
|
||||
_timer.log = log
|
||||
wxPanel.__init__(self, parent, -1)
|
||||
|
||||
wxStaticText(self, -1, "This is a timer example",
|
||||
wxPoint(15, 30))
|
||||
|
||||
wxButton(self, 11101, ' Start ', wxPoint(15, 75), wxDefaultSize)
|
||||
wxButton(self, 11102, ' Stop ', wxPoint(77, 75), wxDefaultSize)
|
||||
EVT_BUTTON(self, 11101, self.OnStart)
|
||||
EVT_BUTTON(self, 11102, self.OnStop)
|
||||
|
||||
def OnStart(self, event):
|
||||
_timer.Start(1000)
|
||||
|
||||
def OnStop(self, event):
|
||||
_timer.Stop()
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
win = TestTimerWin(nb, log)
|
||||
return win
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
overview = """\
|
||||
The wxTimer class allows you to execute code at specified intervals. To use it, derive a new class and override the Notify member to perform the required action. Start with Start, stop with Stop, it's as simple as that.
|
||||
|
||||
wxTimer()
|
||||
------------------
|
||||
|
||||
Constructor.
|
||||
"""
|
@@ -1,125 +0,0 @@
|
||||
|
||||
from wxPython.wx import *
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
class TestToolBar(wxFrame):
|
||||
def __init__(self, parent, log):
|
||||
wxFrame.__init__(self, parent, -1, 'Test ToolBar',
|
||||
wxPoint(0,0), wxSize(500, 300))
|
||||
self.log = log
|
||||
|
||||
wxWindow(self, -1).SetBackgroundColour(wxNamedColour("WHITE"))
|
||||
|
||||
tb = self.CreateToolBar(wxTB_HORIZONTAL|wxNO_BORDER)
|
||||
#tb = wxToolBar(self, -1, wxDefaultPosition, wxDefaultSize,
|
||||
# wxTB_HORIZONTAL | wxNO_BORDER | wxTB_FLAT)
|
||||
#self.SetToolBar(tb)
|
||||
|
||||
self.CreateStatusBar()
|
||||
|
||||
tb.AddTool(10, wxNoRefBitmap('bitmaps/new.bmp', wxBITMAP_TYPE_BMP),
|
||||
wxNullBitmap, false, -1, -1, "New", "Long help for 'New'")
|
||||
EVT_TOOL(self, 10, self.OnToolClick)
|
||||
EVT_TOOL_RCLICKED(self, 10, self.OnToolRClick)
|
||||
|
||||
tb.AddTool(20, wxNoRefBitmap('bitmaps/open.bmp', wxBITMAP_TYPE_BMP),
|
||||
wxNullBitmap, false, -1, -1, "Open")
|
||||
EVT_TOOL(self, 20, self.OnToolClick)
|
||||
EVT_TOOL_RCLICKED(self, 20, self.OnToolRClick)
|
||||
|
||||
tb.AddSeparator()
|
||||
tb.AddTool(30, wxNoRefBitmap('bitmaps/copy.bmp', wxBITMAP_TYPE_BMP),
|
||||
wxNullBitmap, false, -1, -1, "Copy")
|
||||
EVT_TOOL(self, 30, self.OnToolClick)
|
||||
EVT_TOOL_RCLICKED(self, 30, self.OnToolRClick)
|
||||
|
||||
tb.AddTool(40, wxNoRefBitmap('bitmaps/paste.bmp', wxBITMAP_TYPE_BMP),
|
||||
wxNullBitmap, false, -1, -1, "Paste")
|
||||
EVT_TOOL(self, 40, self.OnToolClick)
|
||||
EVT_TOOL_RCLICKED(self, 40, self.OnToolRClick)
|
||||
|
||||
tb.AddSeparator()
|
||||
|
||||
tb.AddTool(50, wxNoRefBitmap('bitmaps/tog1.bmp', wxBITMAP_TYPE_BMP),
|
||||
wxNullBitmap, true, -1, -1, "Toggle this")
|
||||
EVT_TOOL(self, 50, self.OnToolClick)
|
||||
EVT_TOOL_RCLICKED(self, 50, self.OnToolRClick)
|
||||
|
||||
tb.AddTool(60, wxNoRefBitmap('bitmaps/tog1.bmp', wxBITMAP_TYPE_BMP),
|
||||
wxNoRefBitmap('bitmaps/tog2.bmp', wxBITMAP_TYPE_BMP),
|
||||
true, -1, -1, "Toggle with 2 bitmaps")
|
||||
EVT_TOOL(self, 60, self.OnToolClick)
|
||||
EVT_TOOL_RCLICKED(self, 60, self.OnToolRClick)
|
||||
|
||||
tb.Realize()
|
||||
|
||||
|
||||
def OnCloseWindow(self, event):
|
||||
self.Destroy()
|
||||
|
||||
def OnToolClick(self, event):
|
||||
self.log.WriteText("tool %s clicked\n" % event.GetId())
|
||||
|
||||
def OnToolRClick(self, event):
|
||||
self.log.WriteText("tool %s right-clicked\n" % event.GetId())
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
win = TestToolBar(frame, log)
|
||||
frame.otherWin = win
|
||||
win.Show(true)
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
overview = """\
|
||||
The name wxToolBar is defined to be a synonym for one of the following classes:
|
||||
|
||||
wxToolBar95 The native Windows 95 toolbar. Used on Windows 95, NT 4 and above.
|
||||
|
||||
wxToolBarMSW A Windows implementation. Used on 16-bit Windows.
|
||||
|
||||
wxToolBarGTK The GTK toolbar.
|
||||
|
||||
wxToolBarSimple A simple implementation, with scrolling. Used on platforms with no native toolbar control, or where scrolling is required.
|
||||
|
||||
wxToolBar()
|
||||
-----------------------
|
||||
|
||||
Default constructor.
|
||||
|
||||
wxToolBar(wxWindow* parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxTB_HORIZONTAL | wxNO_BORDER, const wxString& name = wxPanelNameStr)
|
||||
|
||||
Constructs a toolbar.
|
||||
|
||||
Parameters
|
||||
-------------------
|
||||
|
||||
parent = Pointer to a parent window.
|
||||
|
||||
id = Window identifier. If -1, will automatically create an identifier.
|
||||
|
||||
pos = Window position. wxDefaultPosition is (-1, -1) which indicates that wxWindows should generate a default position for the window. If using the wxWindow class directly, supply an actual position.
|
||||
|
||||
size = Window size. wxDefaultSize is (-1, -1) which indicates that wxWindows should generate a default size for the window.
|
||||
|
||||
style = Window style. See wxToolBar for details.
|
||||
|
||||
name = Window name.
|
||||
"""
|
@@ -1,118 +0,0 @@
|
||||
|
||||
from wxPython.wx import *
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
class TestTreeCtrlPanel(wxPanel):
|
||||
def __init__(self, parent, log):
|
||||
wxPanel.__init__(self, parent, -1)
|
||||
|
||||
self.log = log
|
||||
tID = NewId()
|
||||
|
||||
self.tree = wxTreeCtrl(self, tID)
|
||||
root = self.tree.AddRoot("The Root Item")
|
||||
for x in range(15):
|
||||
child = self.tree.AppendItem(root, "Item %d" % x)
|
||||
for y in range(5):
|
||||
last = self.tree.AppendItem(child, "item %d-%s" % (x, chr(ord("a")+y)))
|
||||
for z in range(5):
|
||||
self.tree.AppendItem(last, "item %d-%s-%d" % (x, chr(ord("a")+y), z))
|
||||
|
||||
self.tree.Expand(root)
|
||||
EVT_TREE_ITEM_EXPANDED (self, tID, self.OnItemExpanded)
|
||||
EVT_TREE_ITEM_COLLAPSED (self, tID, self.OnItemCollapsed)
|
||||
EVT_TREE_SEL_CHANGED (self, tID, self.OnSelChanged)
|
||||
|
||||
EVT_LEFT_DCLICK(self.tree, self.OnLeftDClick)
|
||||
EVT_RIGHT_DOWN(self.tree, self.OnRightClick)
|
||||
EVT_RIGHT_UP(self.tree, self.OnRightUp)
|
||||
|
||||
def OnRightClick(self, event):
|
||||
(x,y) = event.Position();
|
||||
item = self.tree.HitTest(wxPoint(x,y))
|
||||
self.log.WriteText("OnRightClick: %s\n" % self.tree.GetItemText(item))
|
||||
self.tree.SelectItem(item)
|
||||
|
||||
def OnRightUp(self, event):
|
||||
(x,y) = event.Position();
|
||||
item = self.tree.HitTest(wxPoint(x,y))
|
||||
self.log.WriteText("OnRightUp: %s\n" % self.tree.GetItemText(item))
|
||||
|
||||
def OnLeftDClick(self, event):
|
||||
(x,y) = event.Position();
|
||||
item = self.tree.HitTest(wxPoint(x,y))
|
||||
self.log.WriteText("OnLeftDClick: %s\n" % self.tree.GetItemText(item))
|
||||
|
||||
|
||||
def OnSize(self, event):
|
||||
w,h = self.GetClientSizeTuple()
|
||||
self.tree.SetDimensions(0, 0, w, h)
|
||||
|
||||
|
||||
def OnItemExpanded(self, event):
|
||||
item = event.GetItem()
|
||||
self.log.WriteText("OnItemExpanded: %s\n" % self.tree.GetItemText(item))
|
||||
|
||||
def OnItemCollapsed(self, event):
|
||||
item = event.GetItem()
|
||||
self.log.WriteText("OnItemCollapsed: %s\n" % self.tree.GetItemText(item))
|
||||
|
||||
def OnSelChanged(self, event):
|
||||
item = event.GetItem()
|
||||
self.log.WriteText("OnSelChanged: %s\n" % self.tree.GetItemText(item))
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
win = TestTreeCtrlPanel(nb, log)
|
||||
return win
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
overview = """\
|
||||
A tree control presents information as a hierarchy, with items that may be expanded to show further items. Items in a tree control are referenced by wxTreeItemId handles.
|
||||
|
||||
wxTreeCtrl()
|
||||
-------------------------
|
||||
|
||||
Default constructor.
|
||||
|
||||
wxTreeCtrl(wxWindow* parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxTR_HAS_BUTTONS, const wxValidator& validator = wxDefaultValidator, const wxString& name = "listCtrl")
|
||||
|
||||
Constructor, creating and showing a tree control.
|
||||
|
||||
Parameters
|
||||
-------------------
|
||||
|
||||
parent = Parent window. Must not be NULL.
|
||||
|
||||
id = Window identifier. A value of -1 indicates a default value.
|
||||
|
||||
pos = Window position.
|
||||
|
||||
size = Window size. If the default size (-1, -1) is specified then the window is sized appropriately.
|
||||
|
||||
style = Window style. See wxTreeCtrl.
|
||||
|
||||
validator = Window validator.
|
||||
|
||||
name = Window name.
|
||||
"""
|
@@ -1,6 +0,0 @@
|
||||
*.gz
|
||||
*.rpm
|
||||
*.zip
|
||||
filelist
|
||||
wxPython.spec
|
||||
wxp2.wse
|
@@ -1,5 +0,0 @@
|
||||
sourcedir : .
|
||||
builddir : .
|
||||
rpmdir : .
|
||||
srcrpmdir : .
|
||||
|
@@ -1,26 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [ -z $1 ]; then
|
||||
echo "Please specify a version number on the command line."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -f wxPython.spec.in ]; then
|
||||
echo "Please run this script from the directory containing the wxPython.spec.in file."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
|
||||
strip /usr/lib/python1.5/site-packages/wxPython/wxcmodule.so
|
||||
|
||||
cat wxPython.spec.in | sed s/__VERSION__/$1/g > wxPython.spec
|
||||
|
||||
mkdir /usr/doc/wxPython-$1
|
||||
cp ../README.txt /usr/doc/wxPython-$1
|
||||
|
||||
rpm -bb wxPython.spec
|
||||
|
||||
mv /usr/src/redhat/RPMS/*/wxPython*.rpm .
|
||||
|
||||
rm -r /usr/doc/wxPython-$1
|
@@ -1,36 +0,0 @@
|
||||
#!/bin/bash
|
||||
#----------------------------------------------------------------------
|
||||
# Make a source distribution as a tar.gz file. This script should be
|
||||
# run from the directory that holds the wxPython dir (../..) and be
|
||||
# given a version number as an parameter. The best way to do this is
|
||||
# run "make dist" in the wxPython/src/ directory.
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
if [ -z $1 ]; then
|
||||
echo "Please specify a version number on the command line."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -d wxPython ]; then
|
||||
echo "Please run this script from the directory containing the wxPython sources."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
rm -f wxPython/distrib/filelist
|
||||
for x in `cat wxPython/distrib/wxPython.rsp`; do
|
||||
ls $x >> wxPython/distrib/filelist
|
||||
done
|
||||
|
||||
|
||||
tar cf wxPython/distrib/dist-temp.tar -T wxPython/distrib/filelist
|
||||
cd wxPython/distrib
|
||||
tar xf dist-temp.tar
|
||||
rm dist-temp.tar
|
||||
mv wxPython wxPython-$1
|
||||
|
||||
tar cvf wxPython-$1.tar wxPython-$1
|
||||
gzip wxPython-$1.tar
|
||||
|
||||
rm -rf wxPython-$1
|
||||
|
Before Width: | Height: | Size: 128 KiB |
@@ -1,44 +0,0 @@
|
||||
wxPython/*.txt
|
||||
|
||||
wxPython/demo/*.py
|
||||
wxPython/demo/bitmaps/*.bmp
|
||||
wxPython/demo/bitmaps/*.ico
|
||||
wxPython/demo/bitmaps/*.gif
|
||||
wxPython/demo/bitmaps/*.png
|
||||
wxPython/demo/bitmaps/*.jpg
|
||||
wxPython/demo/README.txt
|
||||
|
||||
wxPython/lib/*.py
|
||||
wxPython/lib/*.txt
|
||||
wxPython/lib/sizers/*.py
|
||||
wxPython/lib/sizers/*.txt
|
||||
|
||||
|
||||
wxPython/src/*.i
|
||||
wxPython/src/*.py
|
||||
wxPython/src/*.cpp
|
||||
wxPython/src/*.h
|
||||
wxPython/src/*.ico
|
||||
wxPython/src/*.def
|
||||
wxPython/src/*.rc
|
||||
wxPython/src/makefile.*
|
||||
wxPython/src/Makefile.pre.in
|
||||
wxPython/src/Setup.*
|
||||
|
||||
wxPython/src/msw/*.cpp
|
||||
wxPython/src/msw/*.h
|
||||
wxPython/src/msw/*.py
|
||||
|
||||
wxPython/src/gtk/*.cpp
|
||||
wxPython/src/gtk/*.h
|
||||
wxPython/src/gtk/*.py
|
||||
|
||||
wxpython/src/motif/*.cpp
|
||||
wxPython/src/motif/*.h
|
||||
wxPython/src/motif/*.py
|
||||
|
||||
wxPython/src/qt/*.cpp
|
||||
wxPython/src/qt/*.h
|
||||
wxPython/src/qt/*.py
|
||||
|
||||
wxPython/SWIG.patches/*.patch
|
@@ -1,41 +0,0 @@
|
||||
Summary: Cross platform GUI toolkit for use with the Python language.
|
||||
Name: wxPython
|
||||
Version: __VERSION__
|
||||
Release: 1
|
||||
Copyright: wxWindows
|
||||
Group: Development/Languages/Python
|
||||
Source: http://alldunn.com/wxPython/wxPython-__VERSION__.tar.gz
|
||||
Packager: Robin Dunn <robin@alldunn.com>
|
||||
Vendor: Total Control Software
|
||||
Requires: python >= 1.5.1
|
||||
Prefix: /usr/lib/python1.5/site-packages
|
||||
|
||||
%description
|
||||
|
||||
This Python package consists of an extension module that wraps around the
|
||||
wxWindows C++ class library and provides a cross platform GUI toolkit for
|
||||
use with Python. Currently supported platforms are Win32 and Unix/GTK/X.
|
||||
|
||||
Python is an interpreted, interactive, object-oriented programming language.
|
||||
Python combines remarkable power with very clear syntax. It has modules,
|
||||
classes, exceptions, very high level dynamic data types, and dynamic typing.
|
||||
There are interfaces to many system calls and libraries, and new built-in
|
||||
modules are easily written in C or C++. Python is also usable as an
|
||||
extension language for applications that need a programmable interface.
|
||||
|
||||
#%prep
|
||||
#%setup
|
||||
#cd wxPython-__VERSION__
|
||||
#make -f Makefile.pre.in boot
|
||||
#
|
||||
#%build
|
||||
#make
|
||||
#
|
||||
#
|
||||
#%install
|
||||
#make install
|
||||
|
||||
%files
|
||||
%doc /usr/doc/wxPython-__VERSION__/README.txt
|
||||
/usr/lib/python1.5/site-packages/wxPython
|
||||
|
@@ -1,17 +0,0 @@
|
||||
|
||||
@echo off
|
||||
|
||||
|
||||
zip -@ -r wxPython\wxPython-src-%1.zip < wxPython\distrib\wxPython.rsp
|
||||
|
||||
mkdir wxPython\docs
|
||||
copy %WXWIN%\docs\html\wx\*.gif wxPython\docs
|
||||
copy %WXWIN%\docs\html\wx\*.htm wxPython\docs
|
||||
copy wxPython\docs\wx.htm wxPython\docs\index.htm
|
||||
|
||||
zip -r wxPython\wxPython-docs-%1.zip wxPython\docs
|
||||
|
||||
del /y wxPython\docs\*.*
|
||||
rmdir wxPython\docs
|
||||
|
||||
move /R wxPython\*.zip wxPython\distrib
|