topic "U++ vs wxWidgets"; [ $$0,0#00000000000000000000000000000000:Default] [l288;i704;a17;O9;~~~.992; $$1,0#10431211400427159095818037425705:param] [a83;*R6 $$2,5#31310162474203024125188417583966:caption] [b83;* $$3,5#07864147445237544204411237157677:title] [b167;a42;C $$4,6#40027414424643823182269349404212:item] [b42;a42; $$5,5#45413000475342174754091244180557:text] [l288;a17; $$6,6#27521748481378242620020725143825:desc] [l321;t246;C@5;1 $$7,7#20902679421464641399138805415013:code] [b2503; $$8,0#65142375456100023862071332075487:separator] [*@(0.0.255) $$9,0#83433469410354161042741608181528:base] [t4167;C+117 $$10,0#37138531426314131251341829483380:class] [l288;a17;*1 $$11,11#70004532496200323422659154056402:requirement] [i416;b42;a42;O9;~~~.416; $$12,12#10566046415157235020018451313112:tparam] [b167;C $$13,13#92430459443460461911108080531343:item1] [a42;C $$14,14#77422149456609303542238260500223:item2] [*@2$(0.128.128) $$15,15#34511555403152284025741354420178:NewsDate] [l321;*C$7 $$16,16#03451589433145915344929335295360:result] [l321;b83;a83;*C$7 $$17,17#07531550463529505371228428965313:result`-line] [l160;t4167;*C+117 $$18,5#88603949442205825958800053222425:package`-title] [{_}%EN-US [s0;= [7 Ultimate`+`+ vs wxWidgets]&] [s0;=2 &] [s0; [2 To compare Ultimate`+`+ with wxWindows, we decided to reimplement wxWindows demonstration example `"Bombs`". On the left side is U`+`+ code, on the right side wxWidgets code (part of wxWidgets release).]&] [s0;=2 &] [ {{5000:5000f0;g0; [s0;= [2 @@image:1549&1849 򁀀흯ƃ҇Ȉ ׶֫եթޘ޾ǰ̛ք ށÚՇןןѿޖ뿩޽ Օ׮ﶏۿ׿߬ 꿬廏߹ٽˢ쯶 ƮݼѽӾϛʮ ՝ϛտ苣޴ϲ유ꇂ Էꫵ˚Ւ؊ԯҠ鍛Խ Ɵ廂߷ǺڂجЭؠۨ խׅȏ߁ȼ䕨ぜՕ ч޶ƚ岝妭Τ힘 ͼٳçß갽̤ޟdzȤր󽃳Ρ̢̺ ٪Ҫ㯛տӂùԴè țٳϞïß̼ݎ臃ٳշ ǃҏƫȧ؇ه܇è۪ Њ‹ܮڒʾ藒鷚ֆ ⶇطŲ흴هه칄 ɾϜͶЏ؁ևߎթ퐦Ў񹴐ϟК ׾Ўѣ۰ÝȧهŨ葼͡лÛ뿇 Ȳ؇֐𾴶̽ƾš߮؈߇߮ ǸںÿهЮʾñ劐ᚍ±̳ Ű͆ˆܫМֶ‡̝ЌÎڜ܈գكꍫĮ 踬߰ȡөۖЈ򞨆 ծקō򣟗Ìҙ򥴬ư鶪Ű͆٠ôݥ 袭Ʋƣ»ﲥ¾è։ͅղúȠյ úԑնڎ蜳٬𹛎ջㄆΆŸ ίȲߖǭɄʈʉܺݗ̟ؼ۾ ijފϿĚ̠𩧚󃦐ȏܽ ƒ߾זҔٿ̐Ԙǯ ܻϒ慎Ꟗ쏱͆۬É؟ј ꪟ͐ۋ߲󗇳ߒݩϿ ګ̈́Ϫ𵙩ܢΨާ茡Üîˇܞٳ 薼ε⣳䳢ߟˮߔ˭雷̵׌ إِǎܓʜᴦ®ȏِۃ ۊٱԟֶ׳음ëǿݕ ﷟߃Ж䄚߶ބȳ۲ș؏ ކ蘝˴̧֤Ư֟Ɍɴ뜬ߢߴ ͒ԅ쭗ҝ򞎌șլЎձ»ԧСЕÙլ Ўű»Оǧ񿙹ϑ帄 ׿ߘئ􂂟݂̖ߛτ畦ـ 🉝ݯȵԹ塟юܛόվ˞ǬǢǬ 嬍ς簯ژչ嬟ς؍퀨о󣏕־ʠ Ѷũʫݦͭ󄦟ʝÁɒꨖηҤ󰵡ع ɒ¥ߡژϹַ嬆㮉ĵʟˠ ЙՙЎ唈ձ򻔡ІЕÙլЎձș»Ц ׶骬̙賘ߞр刽ߋݢ̐ʖ׻ şŔՕ艫ܡܿǢރΪꢎ˭ʹޮݾڌ ˍپ¨򩲞ֱٿޖ׫҉͞ڟƪŴݖҾ ώ˽ӯ§֪џћƵھÕϞ ˨Ѯզ󘹗ώǏԶ󕳨ϐ đʆ⟡≕󣕳תݻ뤯ʫ絯֯ļ ՒѮ嬄ܾ폮ғꫪٻъ ʈխᒍ빯ǣƫǖՖȭ̶ ڃܓ׶ڭ̙賘刽勫 ݢʐʖ׻şŔĕߧⴌèľèլΌ ԳɄֆʐϐ٪յΠٷ魏 ֟㫪ˠ̩狳 ث͇ßշʇ՛瘪ϝۛϽ êյΠᷚ́ϿȚ ·Փٜ⥧ߙԐΨڎê ߘϺͯ狳ݖ՛ۜ ɘ磳Ԇʐϐٙµèè綈լԳ͍ ٙٳ專řʐʚ唵èʨֆДѳ֬ΒǢʫվ 嬹ŹЦͧݱϖݡΉعЦ߹낑 Ʌ峧嬉ݜϜЫ٢ʘΛʐ㬦жԹ낟ʺ оߒ٢Ĝɩ٨ѕԖۡ۬ 幸Ιﶠřʐʣ唵èʨֵД֬ٙٳϬ͍ ʚ唐èʨֆД֬ٙٳŌɈոիʖО ܚާǒʃ׻关ЅО썶љɨ Ѩюᝋ 㧬̧渒ָʑ೜ɩ۫ʑ೜ɩﰙ 䔕•֊Ų،ʈսšԹֽیխ󔇪֪鉪۝ʚ 唵èʨֆД֬ٙٳřԆѴʑʲ浚ʐ򤲕΢ Ԫʐ򤲄΢Ǫʐ򤲄΢Ǫʐդ΢횳캝Ծ ĺٟ݁Ȳ푧Ą󭫛̕؝Ũ™ ٙЅݖȵٚ̕ֆг× ݆Ń׊ոԾﰊǎ̕ℾ՗ոؾù֮ Ų꟡܆حۂ݌ٍèʑʐ㡓èʑ ʐΨʑʐֲٓӷȡ٠ٳřʐʚ èʨֆД꽜ߡ􃯾ڙԨȂ Ծݕ퉳ݏĹƳ٬ٛйڧ šٛХ̹О츍ωƿ爸 虫؉凎ͣɿгˑ筑ʮ񒗺Ӻ ۹Ӽϓ־ʃȥ觜ޢĄݺЩ 牉ՊݥԟϽՇͿȇŝِ Β唵èʨֆД֬ٙٳřʐʚƣДթ˘ شʐє֧޴РʐŃ֧޴ʐŃъ֧޴ʐ㼡򵢴 աיݠݡĤۉվۮÖ򴮇Ֆ ũջⅲá乎бɨܭըɬЦ䃹꺸ТɈѦȹ ݡΡ􆣸ڈ焄Պξȑ،ζݲ؁ԫΙ§· Ǎ̻ҸԮ֔㠴ɌӭԄۊӅʃDž ޥ؃׫ʌՕޱɩÎ訝؜Ӥԫەޘƫɩ䄆 µĔ֡殖™ۺ矑Պ؁ըӎݖřﶠ բӆЯӆЯ㊲ӆИֈӆЯԾ ۣѴϪŒЙȸ׆Ѝ̜èِԦΓƕìتʐᖄհ ٸꘈܹЃՙ뜭ָ񯺇筏͗祋ܛۘ ݫ쾸۬»ؗŠ—℆˭럩팓ʳ ըǨۢιٺӓ諾‰Ԗ옒켹鉭쒪˾ ߞɪԉ־Ӑܜ㣉Ֆ㪴־Ζ⩪Ч격ۡ ݼը†ߜ٩סݵdzźݖ̳èٸԦƕ ìʐᖄǕٸꘅܙµ̣񶮌Йצٹ ڒ؛ЌԙɃЌ쐊ᚍ±̳鶈͞ϣ ύꯢߢ܇̄䱩ƑύēăŽŃ 르õ颼܇Îڵ᎜׳㎷㶲䉚 ‚ǿ폟ЮꝖ򖒁󈝼 Ljܳۢݣ ǖ׹ǻʑГǒ鿖ŃƂچ٠ôЌ 쵡ˣԝ ]] :: [s0;= [2 @@image:1429&1720 ؁흭 Ԙؠണߩԥѳ鷿їɚѠ ϋ⇪ׇ㡮Ϳ߬ߜҷߟߛ ގ˭׿ͯ׏ݩ ڿߊşӯ ԯաþ잊 ڟűЧà✿廮Կݗ ՐؙạÝ۳ݞࢪĎ璮ܕ ľϿຫમՁ؅թ˸ψԗ 춯ޘƭՉװõͺᵮլֿ͚نծ ﳊʵ깼潝լ۳ꕫ޳ٶ뽖ӑϔ؝֟լ։ լѳˬٿ뱷ڻ͓嘲冮ӼĺẪ߫ ẩݷݵ붕ٽߐֵꆰ׮ڝߐ۷ ؒѳ∻։ʵ䭳ի˴ݬ䭣ُ Ӻ̝֮ցȲݹ酬ی߾ί ¾ë҃瘃ˎеՎѪʚۭ֣ӵ ϬգѲʠ˝𾫾ۤʃЍցצ쳘 ꭔݳ̀։קݖƩ֞ϠꜬͪլ ȪɪՀ˅ѶÌճ៵ʐ֮ ذ烕͵ݖ׾燏Ϫլ֜پўѝփҪ 쳦톧ϔنրܠّكէѬ唬ؾܠٓ ܾ뎧֟ٴˀ¢젋Ȅƨ Φļ֣΀ͩơ񈼛ŬǷŐ ڛڣ›Ԭऋ芡Ҍɞാ͑Áࠐ쐥̴Ԭ ¢ؑăΰɴꁸβ貌؎಺Ρ NJߋͬ֠꟟܂߶ě׆ͭ ܾ쯯ەÚݰɲۇ߇ǹ񜁾ĕյ旷 ɮםỖɅ݁صޞ ӧ۲ݫۗ▽̥ԙ誹׃ 쐫ѻزْ͎̲Ԓͼر슽廜ˬ …ߧ×܈ˬďنӄ™ќ꿔鯎ݺͲ 㻀ْڔ۹ԴϴȪᩲȲϛ ցܿ˲͋㙽Ȳ߳ܞǎݥٽ ͚֍ɮ۫켹͞޾ɲ߶nj쯎ꏫ֤ 㧑əɮ讏ȺŖԳɸ򡕩ϳ樟Ȃ όЄ؍҉ͶܠÅ۲ͬՇ ֥܃ËݵӮ͚ϑҸڴǠ˫򜝁󄲴Κ ͥѼ췭¯ם՝ߺԵլگם푝ȃߺԵލ ﶙ׽؜엮ܚ֖Ŝ𚝗ߺԵ뷲ʌϱǹ ߿֤ո囹ڧ󔓎ǰ˾ϊ樧嗮 ٌܾܚǟ·ɒ޻˔ڄկܹ ݑߺɵӼگٙ٢Ȭݽů✅엮ܚ┬ؙͺǜ ҥۓժ۹乒ڵǬ򜁬󄲴ΚͥϑҸڴǠ 򜁬󄭲ΚͥϑڲЄͥ͐ʓȂ楉҄ Ьﭡūג̓Ӌ܉ҕْޒȒ݄ߺ 욌峉Ͳޒ䉃䝲ɒҧ Ҵ몢ܓ䚴Ƥڒמړγ 񑬡˴ͯͲӢݫגǼݗӗ֚ܡ ڹ͐ŗۚ⋐ʓȂ楉҄邲Ь߀ ݆լؼľΚ򙾦Ҹٚ㬡났Ξ򙾦䛎 Ðݵʠ۫񌏚ϗݵɚ ާݠ羼㬉羼ߞ Ù˾֗̓׬뮥޴䲥ݻ͂ĿÐ ݵ߲󒲒ۉиϻגϥٯխΚ򛙾Ҹ 났Κ򙾦Ҹ㬡났ł肬“ дͭ́ﭚҾϯ機לȒ֢䟕 ̖ͺל̖ٓ⣚߉ݓƖל ӗל֢ۋλĮ ͐ЄȂ肬“дͭÓۤК“ߓ֕ ͐ȂȂДЋ쮮߬݊ڴ ޟЌꄐ尪Э래dz݋ܝ볞ŀٍɁߺ ͠ݧߺ͠슍֢ьʧ 뾶ΰɲؕųԔ֢ι䗛㐥ڳ볞 ֦̭̕ȒעڙϋΏ떄ߺ͠ߞܲ埶 ьʧ޷ߜƖᚌ־֔עϧ ۠Ѯو殍͵Ǒۗœ֓֕͐օ ȂȂДЄ٠“䁬ơ靌քljʹ³͐ۓ 靧ljʹֵ꒽އח앟ݧоDZ݋ք յʾגۓ߾ӻȑחȢ¥׽ם ψ둾ܚ݋քݧоڌյ 븡Һ覭났ښ븡Һ覭ғ났ښ˝븡 Фڼ鋂ݞȊ˖۬邬ؠ㛽ūθ Բȏ̫Ȼ͉ѿ댘ωϒۙ鹞 Αĥג󳧋į݋׼ٓ ΐ˷Ѿ׼ƥȣ󄲒 ͞Д╟ΈԲ׻ߺ̧ʪÓҵ֌͐͐ ÓϓЄӄٱ֌͐͐Ó䭘ϓЄكӄٱ뎆гʡԬ˸ ֌͐܌͐֌͐֌͐֌͐䑼Ӯ뮡 󸎯Ή϶Ȟב帹͞ˈΉ 橑뎮霥߭ɸɞבॲƪҾŸ罎ىĆ޾ ӌσܻǖ٭㺲Ćؙݧ֔ɒ ˆɻɞבܥ܈襴։ڽ罚㺾ߢɏΉ ڧг͞ʈΉ깔迂ɭ肬ɭ ߬ɭ肬孉肬ɭ肬ɭ肬ɭ迂ɭ ꂬꂐꡂꂬȄꂬݛۍݫٚ ֤Қ֤ćȫ쑵˃樢ٲ֡Ż ߑ؆ū왞ެȉϡ˰ ݊“畿ɂ鯻ۆȣضуץþٍ ҥɟ߻ȃִăՄכ߭܇ȫ 樮掰䋐䈐Ԅ䈐ԄԄΈԄН䈐Ԅٻ䈐Ԅ 䈐Ԝ䈶لؑՁول𑕝¾᳀̩ ɪۆꜤ˼ȚٔȚغӒ̆ȩӘʂ ﺰγ茰njДԫ޲Σ惫٣۱ ކиɚԫߚ﬛͚Ѐߊߢ ✸ƎꔬӼ탫חէ䋆̃ وٸԌ”Ɗԡ梋ݐӸǠۨ ]]}}&] [s0;=2 &] [s0;=2 &] [ {{5000:5000^@7 [s0; [*2 Ultimate`+`+ version]] :: [s0; [*2 wxWidgets version]] ::@2 [s0; [C0 #include ]&] [s0;C0 &] [s0; [C0 class Bombs : public TopWindow `{]&] [s0; [C0 public:]&] [s0; [C0 -|virtual void Paint(Draw`& w);]&] [s0; [C0 -|virtual void LeftDown(Point p, dword flags);]&] [s0; [C0 -|virtual void RightDown(Point p, dword flags);]&] [s0;C0 &] [s0; [C0 private:]&] [s0; [C0 -|Size level;]&] [s0; [C0 -|int cx, cy;]&] [s0; [C0 -|int normal`_cells, bombs;]&] [s0; [C0 -|Buffer field;]&] [s0; [C0 -|MenuBar menu;]&] [s0; [C0 -|StatusBar status;]&] [s0; [C0 -|]&] [s0; [C0 -|byte`& Field(int x, int y) `{ return field`[x `+ y `* cx`]; `}]&] [s0; [C0 -|]&] [s0; [C0 -|enum `{]&] [s0; [C0 -|-|HIDDEN `= 16,]&] [s0; [C0 -|-|BOMB `= 32,]&] [s0; [C0 -|-|MARK `= 64,]&] [s0; [C0 -|-|EXPLODED `= 128,]&] [s0;C0 &] [s0; [C0 -|-|UNIT `= 30,]&] [s0; [C0 -|`};]&] [s0;C0 &] [s0; [C0 -|void About();]&] [s0; [C0 -|]&] [s0; [C0 -|void File(Bar`& menu);]&] [s0; [C0 -|void Game(Bar`& menu);]&] [s0; [C0 -|void Menu(Bar`& menu);]&] [s0; [C0 -|]&] [s0; [C0 -|void Status();]&] [s0; [C0 -|void Level(Size sz);]&] [s0;C0 &] [s0; [C0 public:]&] [s0; [C0 -|void Uncover(int x, int y);]&] [s0; [C0 -|void Generate();]&] [s0; [C0 -|void UncoverAll();]&] [s0;C0 &] [s0; [C0 -|typedef Bombs CLASSNAME;]&] [s0; [C0 -|Bombs();]&] [s0; [C0 `};]&] [s0;C0 &] [s0; [C0 void Bombs`::Generate()]&] [s0; [C0 `{]&] [s0; [C0 -|cx `= level.cx;]&] [s0; [C0 -|cy `= level.cy;]&] [s0; [C0 -|field.Alloc(cx `* cy);]&] [s0; [C0 -|for(int i `= cx `* cy `- 1; i >`= 0; i`-`-)]&] [s0; [C0 -|-|field`[i`] `= (rand() `& 15) < 3 ? HIDDEN`|BOMB : HIDDEN;]&] [s0; [C0 -|normal`_cells `= 0;]&] [s0; [C0 -|for(int x `= 0; x < cx; x`+`+)]&] [s0; [C0 -|-|for(int y `= 0; y < cy; y`+`+)]&] [s0; [C0 -|-|-|if((Field(x, y) `& BOMB) `=`= 0) `{]&] [s0; [C0 -|-|-|-|normal`_cells`+`+;]&] [s0; [C0 -|-|-|-|for(int xx `= `-1; xx <`= 1; xx`+`+)]&] [s0; [C0 -|-|-|-|-|for(int yy `= `-1; yy <`= 1; yy`+`+)]&] [s0; [C0 -|-|-|-|-|-|if((xx `|`| yy) `&`& x `+ xx >`= 0 `&`& x `+ xx < cx `&`& y `+ yy >`= 0 `&`& y `+ yy < cy `&`&]&] [s0; [C0 -|-|-|-|-|-| (Field(x `+ xx, y `+ yy) `& BOMB))]&] [s0; [C0 -|-|-|-|-|-|-|Field(x, y)`+`+;]&] [s0; [C0 -|-|-|`}]&] [s0; [C0 -|bombs `= cx `* cy `- normal`_cells;]&] [s0; [C0 -|Rect r `= GetRect();]&] [s0; [C0 -|r.SetSize(AddFrameSize(UNIT `* cx, UNIT `* cy));]&] [s0; [C0 -|SetRect(r);]&] [s0; [C0 -|Status();]&] [s0; [C0 -|Refresh();]&] [s0; [C0 `}]&] [s0;C0 &] [s0; [C0 void Bombs`::UncoverAll()]&] [s0; [C0 `{]&] [s0; [C0 -|for(int i `= cx `* cy `- 1; i >`= 0; i`-`-)]&] [s0; [C0 -|-|field`[i`] `&`= `~HIDDEN;]&] [s0; [C0 -|Refresh();]&] [s0; [C0 `}]&] [s0;C0 &] [s0; [C0 void Bombs`::Paint(Draw`& w)]&] [s0; [C0 `{]&] [s0; [C0 -|for(int x `= 0; x < cx; x`+`+)]&] [s0; [C0 -|-|for(int y `= 0; y < cy; y`+`+) `{]&] [s0; [C0 -|-|-|byte f `= Field(x, y);]&] [s0; [C0 -|-|-|w.DrawRect(x `* UNIT, y `* UNIT `+ UNIT `- 1, UNIT, 1, SBlack);]&] [s0; [C0 -|-|-|w.DrawRect(x `* UNIT `+ UNIT `- 1, y `* UNIT, 1, UNIT, SBlack);]&] [s0; [C0 -|-|-|w.DrawRect(x `* UNIT, y `* UNIT, UNIT `- 1, UNIT `- 1,]&] [s0; [C0 -|-|-| (f `& (HIDDEN`|MARK)) ? SLtGray : f `& BOMB ? SLtRed : SWhite);]&] [s0; [C0 -|-|-|String txt;]&] [s0; [C0 -|-|-|Color ink `= SBlack;]&] [s0; [C0 -|-|-|Color cross `= Null;]&] [s0; [C0 -|-|-|if(f `& MARK) `{]&] [s0; [C0 -|-|-|-|txt `= `"M`";]&] [s0; [C0 -|-|-|-|ink `= SLtRed;]&] [s0; [C0 -|-|-|-|if((f `& (HIDDEN`|BOMB)) `=`= BOMB) `{]&] [s0; [C0 -|-|-|-|-|ink `= SLtBlue;]&] [s0; [C0 -|-|-|-|-|cross `= SLtRed;]&] [s0; [C0 -|-|-|-|`}]&] [s0; [C0 -|-|-|`}]&] [s0; [C0 -|-|-|else]&] [s0; [C0 -|-|-|if(!(f `& HIDDEN))]&] [s0; [C0 -|-|-|-|if(f `& BOMB)]&] [s0; [C0 -|-|-|-|-|txt `= `"B`";]&] [s0; [C0 -|-|-|-|else `{]&] [s0; [C0 -|-|-|-|-|f `= f `& 15;]&] [s0; [C0 -|-|-|-|-|txt `= String(f `+ `'0`', 1);]&] [s0; [C0 -|-|-|-|-|ink `= f `=`= 0 ? SLtGreen : f `=`= 1 ? SLtBlue : SBlack;]&] [s0; [C0 -|-|-|-|`}]&] [s0; [C0 -|-|-|Size tsz `= w.GetTextSize(txt, Roman(2 `* UNIT / 3));]&] [s0; [C0 -|-|-|w.DrawText(x `* UNIT `+ (UNIT `- tsz.cx) / 2, y `* UNIT `+ (UNIT `- tsz.cy) / 2,]&] [s0; [C0 -|-|-| txt, Roman(2 `* UNIT / 3), ink);]&] [s0; [C0 -|-|-|if(f `& EXPLODED)]&] [s0; [C0 -|-|-|-|cross `= SLtBlue;]&] [s0; [C0 -|-|-|w.DrawLine(x `* UNIT, y `* UNIT, x `* UNIT `+ UNIT `- 1, y `* UNIT `+ UNIT `- 1, 1, cross);]&] [s0; [C0 -|-|-|w.DrawLine(x `* UNIT, y `* UNIT `+ UNIT `- 1, x `* UNIT `+ UNIT `- 1, y `* UNIT, 1, cross);]&] [s0; [C0 -|-|`}]&] [s0; [C0 `}]&] [s0;C0 &] [s0; [C0 void Bombs`::Uncover(int x, int y)]&] [s0; [C0 `{]&] [s0; [C0 -|if(x >`= 0 `&`& x < cx `&`& y >`= 0 `&`& y < cy) `{]&] [s0; [C0 -|-|byte`& f `= Field(x, y);]&] [s0; [C0 -|-|if((f `& (HIDDEN`|MARK)) `=`= HIDDEN) `{]&] [s0; [C0 -|-|-|if(f `& BOMB) `{]&] [s0; [C0 -|-|-|-|f `|`= EXPLODED;]&] [s0; [C0 -|-|-|-|normal`_cells `= 0;]&] [s0; [C0 -|-|-|-|UncoverAll();]&] [s0; [C0 -|-|-|-|return;]&] [s0; [C0 -|-|-|`}]&] [s0; [C0 -|-|-|if((f `&`= `~HIDDEN) `=`= 0)]&] [s0; [C0 -|-|-|-|for(int xx `= `-1; xx <`= 1; xx`+`+)]&] [s0; [C0 -|-|-|-|-|for(int yy `= `-1; yy <`= 1; yy`+`+)]&] [s0; [C0 -|-|-|-|-|-|if(xx `|`| yy)]&] [s0; [C0 -|-|-|-|-|-|-|Uncover(x `+ xx, y `+ yy);]&] [s0; [C0 -|-|-|normal`_cells`-`-;]&] [s0; [C0 -|-|-|if(normal`_cells `=`= 0) `{]&] [s0; [C0 -|-|-|-|UncoverAll();]&] [s0; [C0 -|-|-|-|PromptOK(`"`[`*`@4A6 Nice!`]`&You have found all the bombs!`");]&] [s0; [C0 -|-|-|`}]&] [s0; [C0 -|-|`}]&] [s0; [C0 -|`}]&] [s0; [C0 `}]&] [s0;C0 &] [s0; [C0 void Bombs`::LeftDown(Point p, dword flags)]&] [s0; [C0 `{]&] [s0; [C0 -|if(!normal`_cells)]&] [s0; [C0 -|-|return;]&] [s0; [C0 -|p /`= UNIT;]&] [s0; [C0 -|Uncover(p.x, p.y);]&] [s0; [C0 -|Refresh();]&] [s0; [C0 -|Status();]&] [s0; [C0 `}]&] [s0;C0 &] [s0; [C0 void Bombs`::RightDown(Point p, dword flags)]&] [s0; [C0 `{]&] [s0; [C0 -|if(!normal`_cells)]&] [s0; [C0 -|-|return;]&] [s0; [C0 -|p /`= UNIT;]&] [s0; [C0 -|if(Field(p.x, p.y) `& HIDDEN) `{]&] [s0; [C0 -|-|Field(p.x, p.y) `^`= MARK;]&] [s0; [C0 -|-|Refresh();]&] [s0; [C0 -|`}]&] [s0; [C0 `}]&] [s0;C0 &] [s0; [C0 void Bombs`::Status()]&] [s0; [C0 `{]&] [s0; [C0 -|status `= Format(`"%d bombs, %d cells remaining`", bombs, normal`_cells);]&] [s0; [C0 `}]&] [s0;C0 &] [s0; [C0 void Bombs`::Level(Size sz)]&] [s0; [C0 `{]&] [s0; [C0 -|level `= sz;]&] [s0; [C0 `}]&] [s0;C0 &] [s0; [C0 void Bombs`::About()]&] [s0; [C0 `{]&] [s0; [C0 -|PromptOK(`"`[`*A9/ uBombs`]`&`[A5 Ultimate```+```+ example`]`");]&] [s0; [C0 `}]&] [s0;C0 &] [s0; [C0 void Bombs`::File(Bar`& menu)]&] [s0; [C0 `{]&] [s0; [C0 -|menu.Add(`"Exit`", Breaker(IDOK));]&] [s0; [C0 -|menu.Separator();]&] [s0; [C0 -|menu.Add(`"About..`", THISBACK(About));]&] [s0; [C0 `}]&] [s0;C0 &] [s0; [C0 void Bombs`::Game(Bar`& menu)]&] [s0; [C0 `{]&] [s0; [C0 -|menu.Add(`"Restart`", THISBACK(Generate));]&] [s0; [C0 -|menu.Separator();]&] [s0; [C0 -|menu.Add(`"Easy`", THISBACK1(Level, Size(10, 10)))]&] [s0; [C0 -| .Check(level.cx `=`= 10);]&] [s0; [C0 -|menu.Add(`"Medium`", THISBACK1(Level, Size(15, 15)))]&] [s0; [C0 -| .Check(level.cx `=`= 15);]&] [s0; [C0 -|menu.Add(`"Difficult`", THISBACK1(Level, Size(25, 20)))]&] [s0; [C0 -| .Check(level.cx `=`= 25);]&] [s0; [C0 `}]&] [s0;C0 &] [s0; [C0 void Bombs`::Menu(Bar`& menu)]&] [s0; [C0 `{]&] [s0; [C0 -|menu.Add(`"File`", THISBACK(File));]&] [s0; [C0 -|menu.Add(`"Game`", THISBACK(Game));]&] [s0; [C0 `}]&] [s0;C0 &] [s0; [C0 #define IMAGECLASS BombsImg]&] [s0; [C0 #define IMAGEFILE ]&] [s0; [C0 #include ]&] [s0;C0 &] [s0; [C0 Bombs`::Bombs()]&] [s0; [C0 `{]&] [s0; [C0 -|level `= Size(10, 10);]&] [s0; [C0 -|AddFrame(menu);]&] [s0; [C0 -|menu.Set(THISBACK(Menu));]&] [s0; [C0 -|AddFrame(status);]&] [s0; [C0 -|AddFrame(InsetFrame());]&] [s0; [C0 -|Title(`"uBombs`");]&] [s0; [C0 -|Icon(BombsImg`::Small());]&] [s0; [C0 -|Generate();]&] [s0; [C0 `}]&] [s0;C0 &] [s0; [C0 GUI`_APP`_MAIN]&] [s0; [C0 `{]&] [s0; [C0 -|Bombs b;]&] [s0; [C0 -|b.Run();]&] [s0; [C0 `}]&] [s0;=2 ] :: [s0; [C0 #include ]&] [s0;C0 &] [s0; [C0 const int ID`_RESTART `= 100;]&] [s0; [C0 const int ID`_EASY `= 101;]&] [s0; [C0 const int ID`_MEDIUM `= 102;]&] [s0; [C0 const int ID`_DIFFICULT `= 103;]&] [s0;C0 &] [s0; [C0 class MyFrame: public wxFrame]&] [s0; [C0 `{]&] [s0; [C0 public:]&] [s0; [C0 MyFrame( const wxString `&title, const wxPoint`& pos, const wxSize`& size );]&] [s0; [C0 void OnAbout( wxCommandEvent `&event );]&] [s0; [C0 void OnQuit( wxCommandEvent `&event );]&] [s0; [C0 void OnLevel( wxCommandEvent `&event );]&] [s0; [C0 void OnRestart( wxCommandEvent `&event );]&] [s0; [C0 void OnPaint( wxPaintEvent`& event );]&] [s0; [C0 void OnLeftDown( wxMouseEvent `&event );]&] [s0; [C0 void OnRightDown( wxMouseEvent `&event );]&] [s0;C0 &] [s0; [C0 wxSize level;]&] [s0; [C0 int cx, cy;]&] [s0; [C0 int normal`_cells, bombs;]&] [s0; [C0 wxString field;]&] [s0; [C0 ]&] [s0; [C0 enum `{]&] [s0; [C0 HIDDEN `= 16,]&] [s0; [C0 BOMB `= 32,]&] [s0; [C0 MARK `= 64,]&] [s0; [C0 EXPLODED `= 128,]&] [s0; [C0 UNIT `= 30,]&] [s0; [C0 `};]&] [s0; [C0 ]&] [s0; [C0 wxChar`& Field(int x, int y) `{ return field`[x `+ y `* cx`]; `}]&] [s0; [C0 void Level( wxSize size ) `{ level `= size; `}]&] [s0; [C0 void Status(); ]&] [s0;C0 &] [s0; [C0 public:]&] [s0; [C0 void Uncover(int x, int y);]&] [s0; [C0 void Generate();]&] [s0; [C0 void UncoverAll();]&] [s0; [C0 `};]&] [s0;C0 &] [s0; [C0 class MyApp: public wxApp]&] [s0; [C0 `{]&] [s0; [C0 public:]&] [s0; [C0 virtual bool OnInit();]&] [s0; [C0 `};]&] [s0;C0 &] [s0; [C0 MyFrame`::MyFrame( const wxString `&title, const wxPoint `&position, const wxSize`& size ) :]&] [s0; [C0 wxFrame( NULL, `-1, title, position, size )]&] [s0; [C0 `{]&] [s0; [C0 wxMenu `*file`_menu `= new wxMenu;]&] [s0; [C0 file`_menu`->Append( wxID`_ABOUT, wxT(`"About...`"), wxT(`"Program info`") );]&] [s0; [C0 file`_menu`->AppendSeparator();]&] [s0; [C0 file`_menu`->Append( wxID`_EXIT, wxT(`"Quit`"), wxT(`"Quit wxBombs`") );]&] [s0; [C0 ]&] [s0; [C0 wxMenu `*game`_menu `= new wxMenu;]&] [s0; [C0 game`_menu`->Append( ID`_RESTART, wxT(`"Restart`"), wxT(`"Restart game`") );]&] [s0; [C0 game`_menu`->AppendSeparator();]&] [s0; [C0 game`_menu`->AppendRadioItem( ID`_EASY, wxT(`"Easy`"), wxT(`"Easy level`") );]&] [s0; [C0 game`_menu`->AppendRadioItem( ID`_MEDIUM, wxT(`"Medium`"), wxT(`"Medium level`") );]&] [s0; [C0 game`_menu`->AppendRadioItem( ID`_DIFFICULT, wxT(`"Difficult`"), wxT(`"Difficult level`") );]&] [s0;C0 &] [s0; [C0 wxMenuBar `*menu`_bar `= new wxMenuBar();]&] [s0; [C0 menu`_bar`->Append( file`_menu, wxT(`"File`") );]&] [s0; [C0 menu`_bar`->Append( game`_menu, wxT(`"Game`") );]&] [s0; [C0 ]&] [s0; [C0 SetMenuBar( menu`_bar );]&] [s0; [C0 ]&] [s0; [C0 CreateStatusBar(1);]&] [s0; [C0 ]&] [s0; [C0 Connect( wxID`_ABOUT, wxEVT`_COMMAND`_MENU`_SELECTED, wxCommandEventHandler(MyFrame`::OnAbout) );]&] [s0; [C0 Connect( wxID`_EXIT, wxEVT`_COMMAND`_MENU`_SELECTED, wxCommandEventHandler (MyFrame`::OnQuit) );]&] [s0; [C0 Connect( ID`_RESTART, wxEVT`_COMMAND`_MENU`_SELECTED, wxCommandEventHandler(MyFrame`::OnRestart) );]&] [s0; [C0 Connect( ID`_EASY, wxEVT`_COMMAND`_MENU`_SELECTED, wxCommandEventHandler(M yFrame`::OnLevel) );]&] [s0; [C0 Connect( ID`_MEDIUM, wxEVT`_COMMAND`_MENU`_SELECTED, wxCommandEventHandler (MyFrame`::OnLevel) );]&] [s0; [C0 Connect( ID`_DIFFICULT, wxEVT`_COMMAND`_MENU`_SELECTED, wxCommandEventHandler(MyFrame`::OnLevel) );]&] [s0; [C0 ]&] [s0; [C0 Connect( `-1, wxEVT`_LEFT`_DOWN, wxMouseEventHandler(MyFrame`::OnLeftDown) );]&] [s0; [C0 Connect( `-1, wxEVT`_RIGHT`_DOWN, wxMouseEventHandler(MyFrame`::OnRightDown ) );]&] [s0; [C0 Connect( `-1, wxEVT`_PAINT, wxPaintEventHandler(MyFrame`::OnPaint) );]&] [s0; [C0 ]&] [s0; [C0 level `= wxSize( 10, 10 );]&] [s0; [C0 `}]&] [s0;C0 &] [s0;C0 &] [s0; [C0 void MyFrame`::OnAbout( wxCommandEvent `&event )]&] [s0; [C0 `{]&] [s0; [C0 wxMessageDialog dialog( this, wxT(`"Welcome to wxBombs`"), wxT(`"About wxBombs`"), wxOK`|wxICON`_INFORMATION );]&] [s0; [C0 dialog.ShowModal();]&] [s0; [C0 `}]&] [s0;C0 &] [s0; [C0 void MyFrame`::OnQuit( wxCommandEvent `&event )]&] [s0; [C0 `{]&] [s0; [C0 Close( TRUE );]&] [s0; [C0 `}]&] [s0;C0 &] [s0; [C0 void MyFrame`::OnLevel( wxCommandEvent `&event )]&] [s0; [C0 `{]&] [s0; [C0 switch (event.GetId())]&] [s0; [C0 `{]&] [s0; [C0 case ID`_EASY: Level( wxSize( 10,10 ) ); break;]&] [s0; [C0 case ID`_MEDIUM: Level( wxSize( 15,15 ) ); break;]&] [s0; [C0 case ID`_DIFFICULT: Level( wxSize( 25,25 ) ); break;]&] [s0; [C0 `}]&] [s0; [C0 `}]&] [s0;C0 &] [s0; [C0 void MyFrame`::OnRestart( wxCommandEvent `&event )]&] [s0; [C0 `{]&] [s0; [C0 Generate();]&] [s0; [C0 `}]&] [s0;C0 &] [s0; [C0 void MyFrame`::OnPaint( wxPaintEvent`& event )]&] [s0; [C0 `{]&] [s0; [C0 wxPaintDC w( this );]&] [s0; [C0 ]&] [s0; [C0 for(int x `= 0; x < cx; x`+`+)]&] [s0; [C0 for(int y `= 0; y < cy; y`+`+) `{]&] [s0; [C0 wxChar f `= Field(x, y);]&] [s0; [C0 w.SetPen( `*wxBLACK`_PEN );]&] [s0; [C0 w.DrawRectangle(x `* UNIT, y `* UNIT `+ UNIT `- 1, UNIT, 1 );]&] [s0; [C0 w.DrawRectangle(x `* UNIT `+ UNIT `- 1, y `* UNIT, 1, UNIT );]&] [s0; [C0 ]&] [s0; [C0 w.SetPen( (f `& (HIDDEN`|MARK)) ? `*wxGREY`_PEN : f `& BOMB ? `*wxRED`_PEN : `*wxWHITE`_PEN );]&] [s0; [C0 w.DrawRectangle(x `* UNIT, y `* UNIT, UNIT `- 1, UNIT `- 1 );]&] [s0;C0 &] [s0; [C0 wxString txt;]&] [s0; [C0 wxColour ink `= `*wxBLACK;]&] [s0; [C0 wxPen cross;]&] [s0; [C0 if(f `& MARK) `{]&] [s0; [C0 txt `= wxT(`"M`");]&] [s0; [C0 ink `= `*wxRED;]&] [s0; [C0 if((f `& (HIDDEN`|BOMB)) `=`= BOMB) `{]&] [s0; [C0 ink `= `*wxBLUE;]&] [s0; [C0 cross `= `*wxBLACK`_PEN;]&] [s0; [C0 `}]&] [s0; [C0 `}]&] [s0; [C0 else]&] [s0; [C0 if(!(f `& HIDDEN))]&] [s0; [C0 if(f `& BOMB)]&] [s0; [C0 txt `= wxT(`"B`");]&] [s0; [C0 else `{]&] [s0; [C0 f `= f `& 15;]&] [s0; [C0 txt `= wxString( wxChar( f `+ wxT(`'0`') ), (unsigned int )1);]&] [s0; [C0 ink `= f `=`= 0 ? `*wxGREEN : f `=`= 1 ? `*wxBLUE : `*wxBLACK;]&] [s0; [C0 `}]&] [s0;C0 &] [s0; [C0 wxSize tsz `= w.GetTextExtent(txt);]&] [s0; [C0 w.DrawText(txt, x `* UNIT `+ (UNIT `- tsz.x) / 2, y `* UNIT `+ (UNIT `- tsz.y) / 2 );]&] [s0; [C0 if(f `& EXPLODED)]&] [s0; [C0 cross `= wxPen( `*wxBLUE );]&] [s0; [C0 ]&] [s0; [C0 if (cross !`= wxNullPen)]&] [s0; [C0 `{]&] [s0; [C0 w.SetPen ( cross );]&] [s0; [C0 w.DrawLine(x `* UNIT, y `* UNIT, x `* UNIT `+ UNIT `- 1, y `* UNIT `+ UNIT `- 1 );]&] [s0; [C0 w.DrawLine(x `* UNIT, y `* UNIT `+ UNIT `- 1, x `* UNIT `+ UNIT `- 1, y `* UNIT );]&] [s0; [C0 `}]&] [s0; [C0 `}]&] [s0; [C0 `}]&] [s0;C0 &] [s0; [C0 void MyFrame`::OnLeftDown( wxMouseEvent `&event )]&] [s0; [C0 `{]&] [s0; [C0 if(!normal`_cells)]&] [s0; [C0 return;]&] [s0; [C0 wxPoint p( event.GetX(), event.GetY() );]&] [s0; [C0 p.x /`= UNIT;]&] [s0; [C0 p.y /`= UNIT;]&] [s0; [C0 Uncover(p.x, p.y);]&] [s0; [C0 Refresh();]&] [s0; [C0 Status();]&] [s0; [C0 `}]&] [s0;C0 &] [s0; [C0 void MyFrame`::OnRightDown( wxMouseEvent `&event )]&] [s0; [C0 `{]&] [s0; [C0 if(!normal`_cells)]&] [s0; [C0 return;]&] [s0; [C0 wxPoint p( event.GetX(), event.GetY() );]&] [s0; [C0 p.x /`= UNIT;]&] [s0; [C0 p.y /`= UNIT;]&] [s0; [C0 if(Field(p.x, p.y) `& HIDDEN) `{]&] [s0; [C0 Field(p.x, p.y) `^`= MARK;]&] [s0; [C0 Refresh();]&] [s0; [C0 `}]&] [s0; [C0 `}]&] [s0;C0 &] [s0; [C0 void MyFrame`::Status()]&] [s0; [C0 `{]&] [s0; [C0 wxString text;]&] [s0; [C0 text.Printf( wxT(`"%d bombs, %d cells remaining`"), bombs, normal`_cells );]&] [s0; [C0 SetStatusText( text );]&] [s0; [C0 `}]&] [s0;C0 &] [s0; [C0 void MyFrame`::Generate()]&] [s0; [C0 `{]&] [s0; [C0 cx `= level.x;]&] [s0; [C0 cy `= level.y;]&] [s0; [C0 field.Alloc(cx `* cy);]&] [s0; [C0 for(int i `= cx `* cy `- 1; i >`= 0; i`-`-)]&] [s0; [C0 field`[i`] `= (rand() `& 15) < 3 ? HIDDEN`|BOMB : HIDDEN;]&] [s0; [C0 normal`_cells `= 0;]&] [s0; [C0 for(int x `= 0; x < cx; x`+`+)]&] [s0; [C0 for(int y `= 0; y < cy; y`+`+)]&] [s0; [C0 if((Field(x, y) `& BOMB) `=`= 0) `{]&] [s0; [C0 normal`_cells`+`+;]&] [s0; [C0 for(int xx `= `-1; xx <`= 1; xx`+`+)]&] [s0; [C0 for(int yy `= `-1; yy <`= 1; yy`+`+)]&] [s0; [C0 if((xx `|`| yy) `&`& x `+ xx >`= 0 `&`& x `+ xx < cx `&`& y `+ yy >`= 0 `&`& y `+ yy < cy `&`&]&] [s0; [C0 (Field(x `+ xx, y `+ yy) `& BOMB))]&] [s0; [C0 Field(x, y)`+`+;]&] [s0; [C0 `}]&] [s0; [C0 bombs `= cx `* cy `- normal`_cells;]&] [s0; [C0 SetClientSize( wxSize(UNIT `* cx, UNIT `* cy));]&] [s0; [C0 Status();]&] [s0; [C0 Refresh();]&] [s0; [C0 `}]&] [s0;C0 &] [s0; [C0 void MyFrame`::Uncover(int x, int y)]&] [s0; [C0 `{]&] [s0; [C0 if(x >`= 0 `&`& x < cx `&`& y >`= 0 `&`& y < cy) `{]&] [s0; [C0 wxChar`& f `= Field(x, y);]&] [s0; [C0 if((f `& (HIDDEN`|MARK)) `=`= HIDDEN) `{]&] [s0; [C0 if(f `& BOMB) `{]&] [s0; [C0 f `|`= EXPLODED;]&] [s0; [C0 normal`_cells `= 0;]&] [s0; [C0 UncoverAll();]&] [s0; [C0 return;]&] [s0; [C0 `}]&] [s0;C0 &] [s0; [C0 if((f `&`= `~HIDDEN) `=`= 0)]&] [s0; [C0 for(int xx `= `-1; xx <`= 1; xx`+`+)]&] [s0; [C0 for(int yy `= `-1; yy <`= 1; yy`+`+)]&] [s0; [C0 if(xx `|`| yy)]&] [s0; [C0 Uncover(x `+ xx, y `+ yy);]&] [s0; [C0 normal`_cells`-`-;]&] [s0; [C0 if(normal`_cells `=`= 0) `{]&] [s0; [C0 UncoverAll();]&] [s0; [C0 wxMessageDialog dialog( this, wxT(`"You have found all the bombs!`"), wxT(`"wxBombs`"), wxOK`|wxICON`_INFORMATION );]&] [s0; [C0 dialog.ShowModal();]&] [s0; [C0 `}]&] [s0; [C0 `}]&] [s0; [C0 `}]&] [s0; [C0 `}]&] [s0;C0 &] [s0; [C0 void MyFrame`::UncoverAll()]&] [s0; [C0 `{]&] [s0; [C0 for(int i `= cx `* cy `- 1; i >`= 0; i`-`-)]&] [s0; [C0 field`[i`] `= field`[i`] `& `~HIDDEN;]&] [s0; [C0 Refresh();]&] [s0; [C0 `}]&] [s0;C0 &] [s0; [C0 IMPLEMENT`_APP(MyApp)]&] [s0;C0 &] [s0; [C0 bool MyApp`::OnInit()]&] [s0; [C0 `{]&] [s0; [C0 MyFrame `*frame `= new MyFrame( wxT(`"wxBombs`"), wxPoint(20,20), wxSize(500,340) );]&] [s0; [C0 frame`->Show( TRUE );]&] [s0; [C0 return TRUE;]&] [s0; [C0 `}]]}}]