| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687 |
- /*
- ** Command & Conquer Generals(tm)
- ** Copyright 2025 Electronic Arts Inc.
- **
- ** This program is free software: you can redistribute it and/or modify
- ** it under the terms of the GNU General Public License as published by
- ** the Free Software Foundation, either version 3 of the License, or
- ** (at your option) any later version.
- **
- ** This program is distributed in the hope that it will be useful,
- ** but WITHOUT ANY WARRANTY; without even the implied warranty of
- ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- ** GNU General Public License for more details.
- **
- ** You should have received a copy of the GNU General Public License
- ** along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
- ////////////////////////////////////////////////////////////////////////////////
- // //
- // (c) 2001-2003 Electronic Arts Inc. //
- // //
- ////////////////////////////////////////////////////////////////////////////////
- // FILE: GUIEdit.cpp //////////////////////////////////////////////////////////
- //-----------------------------------------------------------------------------
- //
- // Westwood Studios Pacific.
- //
- // Confidential Information
- // Copyright (C) 2001 - All Rights Reserved
- //
- //-----------------------------------------------------------------------------
- //
- // Project: RTS3
- //
- // File name: GUIEdit.cpp
- //
- // Created: Colin Day, July 2001
- //
- // Desc: GUI Edit and window layout entry point
- //
- //-----------------------------------------------------------------------------
- ///////////////////////////////////////////////////////////////////////////////
- // SYSTEM INCLUDES ////////////////////////////////////////////////////////////
- #include <stdlib.h>
- #include <windows.h>
- #include <commctrl.h>
- // USER INCLUDES //////////////////////////////////////////////////////////////
- #include "Common/Debug.h"
- #include "Common/NameKeyGenerator.h"
- #include "Common/GameEngine.h"
- #include "Common/GlobalData.h"
- #include "GameClient/GlobalLanguage.h"
- #include "Common/PlayerList.h"
- #include "GameLogic/RankInfo.h"
- #include "Common/FileSystem.h"
- #include "Common/LocalFileSystem.h"
- #include "Common/ArchiveFileSystem.h"
- #include "GameClient/GadgetTextEntry.h"
- #include "GameClient/GadgetPushButton.h"
- #include "GameClient/GadgetProgressBar.h"
- #include "GameClient/GadgetRadioButton.h"
- #include "GameClient/GadgetStaticText.h"
- #include "GameClient/GadgetListBox.h"
- #include "GameClient/GadgetComboBox.h"
- #include "GameClient/GadgetSlider.h"
- #include "GameClient/GadgetCheckBox.h"
- #include "GameClient/GameText.h"
- #include "GameClient/GadgetTabControl.h"
- #include "GameClient/IMEManager.h"
- #include "GameClient/InGameUI.h"
- #include "GameClient/WindowXlat.h"
- #include "GameClient/HeaderTemplate.h"
- #include "W3DDevice/Common/W3DFunctionLexicon.h"
- #include "W3DDevice/GameClient/W3DGameWindowManager.h"
- #include "W3DDevice/GameClient/W3DDisplay.h"
- #include "W3DDevice/GameClient/W3DGameWindowManager.h"
- #include "W3DDevice/GameClient/W3DGameFont.h"
- #include "W3DDevice/GameClient/W3DDisplayStringManager.h"
- #include "GameClient/Keyboard.h"
- #include "Win32Device/GameClient/Win32Mouse.h"
- #include "Win32Device/GameClient/Win32DIKeyboard.h"
- #include "Win32Device/Common/Win32LocalFileSystem.h"
- #include "Win32Device/Common/Win32BIGFileSystem.h"
- #include "Resource.h"
- #include "WinMain.h"
- #include "GUIEdit.h"
- #include "HierarchyView.h"
- #include "EditWindow.h"
- #include "GUIEditWindowManager.h"
- #include "GUIEditDisplay.H"
- #include "DialogProc.h"
- #include "LayoutScheme.h"
- ///////////////////////////////////////////////////////////////////////////////
- // DEFINES ////////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////////////////
- #define GUIEDIT_CONFIG_VERSION 4
- // PRIVATE TYPES //////////////////////////////////////////////////////////////
- // PRIVATE DATA ///////////////////////////////////////////////////////////////
- // PUBLIC DATA ////////////////////////////////////////////////////////////////
- GUIEdit *TheEditor = NULL;
- // PRIVATE PROTOTYPES /////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////////////////
- // PRIVATE FUNCTIONS //////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////////////////
- // GUIEdit::saveAsDialog ======================================================
- /** Bring up the standard windows browser save as dialog and return
- * filename selected */
- //=============================================================================
- char *GUIEdit::saveAsDialog( void )
- {
- static char filename[ _MAX_PATH ];
- OPENFILENAME ofn;
- Bool returnCode;
- char filter[] = "Window Files (*.wnd)\0*.wnd\0" \
- "All Files (*.*)\0*.*\0\0" ;
- ofn.lStructSize = sizeof( OPENFILENAME );
- ofn.hwndOwner = m_appHWnd;
- ofn.hInstance = NULL;
- ofn.lpstrFilter = filter;
- ofn.lpstrCustomFilter = NULL;
- ofn.nMaxCustFilter = 0;
- ofn.nFilterIndex = 0;
- ofn.lpstrFile = filename;
- ofn.nMaxFile = _MAX_PATH;
- ofn.lpstrFileTitle = NULL;
- ofn.nMaxFileTitle = 0;
- ofn.lpstrInitialDir = NULL;
- ofn.lpstrTitle = NULL;
- ofn.Flags = OFN_NOREADONLYRETURN | OFN_OVERWRITEPROMPT | OFN_PATHMUSTEXIST | OFN_NOCHANGEDIR;
- ofn.nFileOffset = 0;
- ofn.nFileExtension = 0;
- ofn.lpstrDefExt = "wnd";
- ofn.lCustData = 0L ;
- ofn.lpfnHook = NULL ;
- ofn.lpTemplateName = NULL ;
- returnCode = GetSaveFileName( &ofn );
- if( returnCode )
- return filename;
- else
- return NULL;
- } // end saveAsDialog
- // GUIEdit::openDialog ========================================================
- /** Bring up the standard windows browser open dialog and return
- * filename selected */
- //=============================================================================
- char *GUIEdit::openDialog( void )
- {
- static char filename[ _MAX_PATH ];
- OPENFILENAME ofn;
- Bool returnCode;
- char filter[] = "Window Files (*.wnd)\0*.wnd\0" \
- "All Files (*.*)\0*.*\0\0" ;
- ofn.lStructSize = sizeof( OPENFILENAME );
- ofn.hwndOwner = m_appHWnd;
- ofn.hInstance = NULL;
- ofn.lpstrFilter = filter;
- ofn.lpstrCustomFilter = NULL;
- ofn.nMaxCustFilter = 0;
- ofn.nFilterIndex = 0;
- ofn.lpstrFile = filename;
- ofn.nMaxFile = _MAX_PATH;
- ofn.lpstrFileTitle = NULL;
- ofn.nMaxFileTitle = 0;
- ofn.lpstrInitialDir = NULL;
- ofn.lpstrTitle = NULL;
- ofn.Flags = OFN_NOREADONLYRETURN | OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST | OFN_NOCHANGEDIR;
- ofn.nFileOffset = 0;
- ofn.nFileExtension = 0;
- ofn.lpstrDefExt = "wnd";
- ofn.lCustData = 0L ;
- ofn.lpfnHook = NULL ;
- ofn.lpTemplateName = NULL ;
- returnCode = GetOpenFileName( &ofn );
- if( returnCode )
- return filename;
- else
- return NULL;
- } // end openDialog
- // GUIEdit::setUnsaved ========================================================
- /** Set the current contents of the editor as either saved or unsaved,
- * when we're entering an unsaved state we will put a marker in the title
- * bar of the app, when leaving an unsaved state we will remove
- * that marker */
- //=============================================================================
- void GUIEdit::setUnsaved( Bool unsaved )
- {
- // char *saveStatus = " *";
- char *unsavedFilename = "New File";
- char *filename;
- // which filename to use in title bar
- if( strlen( m_saveFilename ) == 0 )
- filename = unsavedFilename;
- else
- filename = m_saveFilename;
- // if( m_unsaved == FALSE && unsaved == TRUE )
- if( unsaved == TRUE )
- {
- char title[ 256 ];
- // entering unsaved state, place '*' in title bar
- sprintf( title, "GUIEdit: %s *", filename );
- SetWindowText( m_appHWnd, title );
- } // end if
- //else if( m_unsaved == TRUE && unsaved == FALSE )
- else
- {
- char title[ 256 ];
- // leaving unsaved state, place '*' in title bar
- sprintf( title, "GUIEdit: %s", filename );
- SetWindowText( m_appHWnd, title );
- } // end else
- // save the new state we're in
- m_unsaved = unsaved;
- } // end setUnsaved
- // GUIEdit::setSaveFile =======================================================
- /** Set our member variables for the full path and filename passed in
- * to this method. We will also extract the filename only from the
- * full path and save that separately */
- //=============================================================================
- void GUIEdit::setSaveFile( char *fullPathAndFilename )
- {
- char *ptr;
- // copy over the full path and filename
- strcpy( m_savePathAndFilename, fullPathAndFilename );
- //
- // copy everything after the last '\' from the full path, this will
- // be just the filename with extension
- //
- ptr = strrchr( fullPathAndFilename, '\\' ) + 1;
- strcpy( m_saveFilename, ptr );
- } // end setSaveFile
- // GUIEdit::validateParentForCreate ===========================================
- /** This method is used when creating new windows and gadgets, if a
- * parent is present, that parent cannot be a GUI gadget because those
- * gadgets are atomic units, they can not contain user defined children */
- //=============================================================================
- Bool GUIEdit::validateParentForCreate( GameWindow *parent )
- {
- //
- // if there is a parent, that parent cannot be a gadget control,
- // gadgets are units themselves and should have no user defined
- // children
- //
- if( parent && TheEditor->windowIsGadget( parent ) )
- {
-
- MessageBox( TheEditor->getWindowHandle(),
- "You cannot make a new window as a child to a GUI Gadget Control",
- "Illegal Parent", MB_OK );
- return FALSE;
- } // end if
- return TRUE; // ok
- } // end validateParentForCreate
- // GUIEdit::findSelectionEntry ================================================
- /** Find selection entry for this window */
- //=============================================================================
- WindowSelectionEntry *GUIEdit::findSelectionEntry( GameWindow *window )
- {
- WindowSelectionEntry *entry;
- // sanity
- if( window == NULL )
- return NULL;
- // search the list
- entry = m_selectList;
- while( entry )
- {
- if( entry->window == window )
- return entry;
- // next entry
- entry = entry->next;
- } // end while
- return NULL; // not found
- } // end findSelectionEntry
- // GUIEdit::normalizeRegion ===================================================
- /** Normalize the region so that lo and hi are actually lo and hi */
- //=============================================================================
- void GUIEdit::normalizeRegion( IRegion2D *region )
- {
- ICoord2D temp;
- if( region->hi.x < region->lo.x )
- {
- if( region->hi.y < region->lo.y )
- {
- temp = region->hi;
- region->hi = region->lo;
- region->lo = temp;
- } // end if
- else
- {
-
- temp = region->hi;
- region->hi.x = region->lo.x;
- region->lo.x = temp.x;
- } // end else
- } // end if
- else if( region->hi.y < region->lo.y )
- {
- temp = region->hi;
- region->hi.y = region->lo.y;
- region->lo.y = temp.y;
- } // end if
- } // end normalizeRegion
- // GUIEdit::selectWindowsInRegion =============================================
- /** Select all the windows that are fully in the region */
- //=============================================================================
- void GUIEdit::selectWindowsInRegion( IRegion2D *region )
- {
- GameWindow *window;
- ICoord2D origin, size;
- // sanity
- if( region == NULL )
- return;
- // unselect everything selected
- clearSelections();
- // normalize the region if needed
- normalizeRegion( region );
- // get the window list
- window = TheWindowManager->winGetWindowList();
- while( window )
- {
- // get the screen position and size of window
- window->winGetScreenPosition( &origin.x, &origin.y );
- window->winGetSize( &size.x, &size.y );
- // compare window extents to selection region
- if( origin.x >= region->lo.x &&
- origin.y >= region->lo.y &&
- origin.x + size.x <= region->hi.x &&
- origin.y + size.y <= region->hi.y )
- {
- // add to selection list
- selectWindow( window );
- } // end if
- // go to next window
- window = window->winGetNext();
- } // end while
- } // end selectWindowsInRegion
- ///////////////////////////////////////////////////////////////////////////////
- // PUBLIC FUNCTIONS ///////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////////////////
- // GUIEdit::GUIEdit ===========================================================
- /** */
- //=============================================================================
- GUIEdit::GUIEdit( void )
- {
- m_appInst = 0;
- m_appHWnd = NULL;
- m_statusBarHWnd = NULL;
- m_toolbarHWnd = NULL;
- m_unsaved = FALSE;
- m_mode = MODE_UNDEFINED;
- strcpy( m_savePathAndFilename, "" );
- strcpy( m_saveFilename, "" );
- m_selectList = NULL;
- m_propertyTarget = NULL;
- m_gridVisible = TRUE;
- m_snapToGrid = TRUE;
- m_gridResolution = 8;
- m_gridColor.red = 112;
- m_gridColor.green = 112;
- m_gridColor.blue = 112;
- m_gridColor.alpha = 64;
- m_showHiddenOutlines = TRUE;
- m_showSeeThruOutlines = TRUE;
- m_layoutInitString = GUIEDIT_NONE_STRING;
- m_layoutUpdateString = GUIEDIT_NONE_STRING;
- m_layoutShutdownString = GUIEDIT_NONE_STRING;
- } // end GUIEdit
- // GUIEdit::~GUIEdit ==========================================================
- /** */
- //=============================================================================
- GUIEdit::~GUIEdit( void )
- {
- if (TheHeaderTemplateManager)
- {
- delete TheHeaderTemplateManager;
- TheHeaderTemplateManager = NULL;
- }
- if (TheGameText)
- {
- delete TheGameText;
- TheGameText = NULL;
- }
-
- // delete the IME Manager
- // if ( TheIMEManager )
- // {
- // delete TheIMEManager;
- // TheIMEManager = NULL;
- // }
- // all the shutdown routine
- shutdown();
- } // end ~GUIEdit
- // GUIEdit::init ==============================================================
- /** Initialize all the GUI edit data */
- //=============================================================================
- void GUIEdit::init( void )
- {
- //
- // save the couple of globals for our app main window as locals for
- // convenient access
- //
- m_appInst = ApplicationHInstance;
- m_appHWnd = ApplicationHWnd;
- // add status bar to the bottom
- createStatusBar();
- // create file system
- TheFileSystem = new FileSystem;
- TheLocalFileSystem = new Win32LocalFileSystem;
- TheArchiveFileSystem = new Win32BIGFileSystem;
- TheFileSystem->init();
- TheGlobalLanguageData = new GlobalLanguage;
- TheGlobalLanguageData->init();
- //---------------------------------------------------------------------------
- // GUI tool specific initializations ----------------------------------------
- //---------------------------------------------------------------------------
- //
- // create the window for the rendered GUI interaction, the GUIEdit
- // program MUST run in the same resolution that the window files are
- // created in, we have chosen 800x600 for all our GUI creation (CDay)
- //
- TheEditWindow = new EditWindow;
- // TheEditWindow->init( 640, 480 );
- TheEditWindow->init( 800, 600 );
- // TheEditWindow->init( 1024, 768 );
- // create hierarchy view
- TheHierarchyView = new HierarchyView;
- TheHierarchyView->init();
- //---------------------------------------------------------------------------
- // Game engine specific initializations -------------------------------------
- //---------------------------------------------------------------------------
- // create the name key generator
- TheWritableGlobalData = new GlobalData;
- TheWritableGlobalData->init();
- // create the name key generator
- TheNameKeyGenerator = new NameKeyGenerator;
- TheNameKeyGenerator->init();
- // create the message stream
- TheMessageStream = new MessageStream;
- TheMessageStream->init();
- TheMessageStream->attachTranslator( new WindowTranslator, 10 );
- // create the command list
- TheCommandList = new CommandList;
- // create the function lexicon
- TheFunctionLexicon = new W3DFunctionLexicon;
- TheFunctionLexicon->init();
- TheFunctionLexicon->validate();
- // create the font library
- TheFontLibrary = new W3DFontLibrary;
- TheFontLibrary->init();
- // load the set of GUIEdit default fonts for controls
- loadGUIEditFontLibrary( TheFontLibrary );
- // create GUI image collection
- TheMappedImageCollection = new ImageCollection;
- TheMappedImageCollection->init();
- TheMappedImageCollection->load( 512 );
- // create display string manager
- TheDisplayStringManager = new W3DDisplayStringManager;
- TheDisplayStringManager->init();
- // create the window manager
- TheWindowManager = new GUIEditWindowManager;
- TheWindowManager->init();
- TheRankInfoStore = new RankInfoStore;
- TheRankInfoStore->init();
- ThePlayerList = new PlayerList;
- ThePlayerList->init();
- TheKeyboard = new DirectInputKeyboard;
- //
- // in order to easily expose the new methods for our own internal editor
- // use we will keep a pointer to what we KNOW to be a gui edit window man.
- //
- TheGUIEditWindowManager = static_cast<GUIEditWindowManager *>(TheWindowManager);
- // create the display
- TheDisplay = new GUIEditDisplay;
- TheDisplay->init();
- ICoord2D size;
- TheEditWindow->getSize( &size );
- TheDisplay->setWidth( size.x );
- TheDisplay->setHeight( size.y );
- // set our initial mode
- setMode( MODE_EDIT );
- // create the default scheme, this must be done after image collections are loaded
- TheDefaultScheme = new LayoutScheme;
- TheDefaultScheme->init();
- // read our configuration file
- readConfigFile( GUIEDIT_CONFIG_FILENAME );
- // read the available font definitions
- readFontFile( GUIEDIT_FONT_FILENAME );
- // create the mouse
- TheWin32Mouse = new Win32Mouse;
- TheMouse = TheWin32Mouse;
- TheMouse->init();
- // lastly just for testing
- TheWindowManager->initTestGUI();
- // load the layout scheme now read in from the cofig file
- TheDefaultScheme->loadScheme( TheDefaultScheme->getSchemeFilename() );
- // create the localized game text interface
- TheGameText = CreateGameTextInterface();
- if ( TheGameText )
- {
- TheGameText->init();
- }
- TheHeaderTemplateManager = new HeaderTemplateManager;
- if(TheHeaderTemplateManager)
- TheHeaderTemplateManager->init();
- // create the IME manager
- // TheIMEManager = CreateIMEManagerInterface();
- // if ( TheIMEManager )
- // {
- // TheIMEManager->init();
- // }
- } // end init
- // GUIEdit::shutdown ==========================================================
- /** Shutdown our GUI edit application */
- //=============================================================================
- void GUIEdit::shutdown( void )
- {
- // write our configuration file
- writeConfigFile( GUIEDIT_CONFIG_FILENAME );
- // write our loaded fonts into the font file if we can
- writeFontFile( GUIEDIT_FONT_FILENAME );
- // delete all the selection entries
- clearSelections();
- // delete the display
- delete TheDisplay;
- TheDisplay = NULL;
- // delete all windows properly in the editor
- deleteAllWindows();
- // delete the mouse
- delete TheMouse;
- TheMouse = NULL;
- TheWin32Mouse = NULL;
- delete ThePlayerList;
- ThePlayerList = NULL;
- delete TheRankInfoStore;
- TheRankInfoStore = NULL;
- // delete the window manager
- delete TheWindowManager;
- TheWindowManager = NULL;
- TheGUIEditWindowManager = NULL;
- // delete display string manager
- delete TheDisplayStringManager;
- TheDisplayStringManager = NULL;
- // delete image collection
- delete TheMappedImageCollection;
- TheMappedImageCollection = NULL;
- // delete the font library
- delete TheFontLibrary;
- TheFontLibrary = NULL;
- delete TheCommandList;
- TheCommandList = NULL;
- delete TheMessageStream;
- TheMessageStream = NULL;
- // delete the function lexicon
- delete TheFunctionLexicon;
- TheFunctionLexicon = NULL;
- // delete name key generator
- delete TheNameKeyGenerator;
- TheNameKeyGenerator = NULL;
-
- delete TheGlobalLanguageData;
- TheGlobalLanguageData = NULL;
- // delete file system
- delete TheFileSystem;
- TheFileSystem = NULL;
- delete TheLocalFileSystem;
- TheLocalFileSystem = NULL;
- delete TheArchiveFileSystem;
- TheArchiveFileSystem = NULL;
- // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- // delete the hierarchy view
- delete TheHierarchyView;
- TheHierarchyView = NULL;
- // destroy the edit window
- delete TheEditWindow;
- TheEditWindow = NULL;
- delete TheKeyboard;
- TheKeyboard = NULL;
- } // end shutdown
- // GUIEdit::update ============================================================
- /** Update method for our GUI edit application */
- //=============================================================================
- void GUIEdit::update( void )
- {
- // update mouse info
- TheMouse->update();
- // process the mouse if we're in test mode
- if( TheEditor->getMode() == MODE_TEST_RUN )
- {
-
- // send input through the window system and clear all messages after
- TheMouse->createStreamMessages();
- TheMessageStream->propagateMessages();
- TheCommandList->reset();
- } // end if
- // update the window manager itself
- TheWindowManager->update();
- // draw the edit window
- TheEditWindow->draw();
- } // end update
- // GUIEdit::writeConfigFile ===================================================
- /** Write the guiedit config file */
- //=============================================================================
- Bool GUIEdit::writeConfigFile( char *filename )
- {
- FILE *fp;
- // open the file
- fp = fopen( filename, "w" );
- if( fp == NULL )
- {
- DEBUG_LOG(( "writeConfigFile: Unable to open file '%s'\n", filename ));
- assert( 0 );
- return FALSE;
- } // end if
- // version
- fprintf( fp, "GUIEdit Config file version '%d'\n", GUIEDIT_CONFIG_VERSION );
- // edit window background color
- RGBColorReal backColor = TheEditWindow->getBackgroundColor();
- fprintf( fp, "BACKGROUNDCOLOR = %f %f %f %f\n",
- backColor.red, backColor.green, backColor.blue, backColor.alpha );
- // grid settings
- fprintf( fp, "GRIDRESOLUTION = %d\n", TheEditor->getGridResolution() );
- RGBColorInt *gridColor = TheEditor->getGridColor();
- fprintf( fp, "GRIDCOLOR = %d %d %d %d\n",
- gridColor->red, gridColor->green, gridColor->blue, gridColor->alpha );
- fprintf( fp, "SNAPTOGRID = %d\n", TheEditor->isGridSnapOn() );
- fprintf( fp, "GRIDVISIBLE = %d\n", TheEditor->isGridVisible() );
- // write hierarchy position and size
- ICoord2D pos, size;
- TheHierarchyView->getDialogPos( &pos );
- TheHierarchyView->getDialogSize( &size );
- fprintf( fp, "HIERARCHYPOSITION = %d %d\n", pos.x, pos.y );
- fprintf( fp, "HIERARCHYSIZE = %d %d\n", size.x, size.y );
- // hidden and see thru options
- fprintf( fp, "SHOWSEETHRUOUTLINES = %d\n", getShowSeeThruOutlines() );
- fprintf( fp, "SHOWHIDDENOUTLINES = %d\n", getShowHiddenOutlines() );
- // scheme file
- fprintf( fp, "SCHEMEFILE = %s\n", TheDefaultScheme->getSchemeFilename() );
- // close the file
- fclose( fp );
- return TRUE;
- } // end writeConfigFile
- // GUIEdit::readConfigFile ====================================================
- /** Read the guiedit config file */
- //=============================================================================
- Bool GUIEdit::readConfigFile( char *filename )
- {
- FILE *fp;
- // open the file
- fp = fopen( filename, "r" );
- if( fp == NULL )
- return TRUE;
- // version
- Int version;
- fscanf( fp, "GUIEdit Config file version '%d'\n", &version );
- if( version != GUIEDIT_CONFIG_VERSION )
- return FALSE; // version has changed, use defaults again
- // edit window background color
- RGBColorReal backColor;
- fscanf( fp, "BACKGROUNDCOLOR = %f %f %f %f\n",
- &backColor.red, &backColor.green, &backColor.blue, &backColor.alpha );
- TheEditWindow->setBackgroundColor( backColor );
- // grid settings
- Int intData;
- fscanf( fp, "GRIDRESOLUTION = %d\n", &intData );
- TheEditor->setGridResolution( intData );
- RGBColorInt gridColor;
- fscanf( fp, "GRIDCOLOR = %d %d %d %d\n",
- &gridColor.red, &gridColor.green, &gridColor.blue, &gridColor.alpha );
- TheEditor->setGridColor( &gridColor );
- fscanf( fp, "SNAPTOGRID = %d\n", &intData );
- TheEditor->setGridSnap( intData );
- fscanf( fp, "GRIDVISIBLE = %d\n", &intData );
- TheEditor->setGridVisible( intData );
- // hierarchy view
- ICoord2D pos, size;
- fscanf( fp, "HIERARCHYPOSITION = %d %d\n", &pos.x, &pos.y );
- fscanf( fp, "HIERARCHYSIZE = %d %d\n", &size.x, &size.y );
- TheHierarchyView->setDialogPos( &pos );
- TheHierarchyView->setDialogSize( &size );
- // hidden and see thru options
- Int show;
- fscanf( fp, "SHOWSEETHRUOUTLINES = %d\n", &show );
- setShowSeeThruOutlines( show );
- fscanf( fp, "SHOWHIDDENOUTLINES = %d\n", &show );
- setShowHiddenOutlines( show );
- // scheme file
- char file[ _MAX_PATH ];
- if (fscanf( fp, "SCHEMEFILE = %s\n", file ) == 1)
- {
- TheDefaultScheme->setSchemeFilename( file );
- }
- // close the file
- fclose( fp );
- return TRUE;
- } // end readConfigFile
- // GUIEdit::readFontFile ======================================================
- /** Read the font file defintitions and load them */
- //=============================================================================
- void GUIEdit::readFontFile( char *filename )
- {
- FILE *fp;
- // sanity
- if( filename == NULL )
- return;
- // open the file
- fp = fopen( filename, "r" );
- if( fp == NULL )
- return;
- // read how many entries follow
- Int fontCount;
- fscanf( fp, "AVAILABLE_FONT_COUNT = %d\n", &fontCount );
- for( Int i = 0; i < fontCount; i++ )
- {
- // read all the font defitions
- char fontBuffer[ 512 ];
- Int size, bold;
- char c = fgetc( fp );
- // skip past the first quote
- while( c != '\"' )
- c = fgetc( fp );
- c = fgetc( fp ); // the quote itself
- // copy the name till the next quote is read
- Int index = 0;
- while( c != '\"' )
- {
- fontBuffer[ index++ ] = c;
- c = fgetc( fp );
- } // end while
- fontBuffer[ index ] = '\0';
- c = fgetc( fp ); // the end quite itself
- // read the size and bold data elements
- fscanf( fp, " Size: %d Bold: %d\n", &size, &bold );
- // set the font
- GameFont *font = TheFontLibrary->getFont( AsciiString(fontBuffer), size, bold );
- if( font == NULL )
- {
- char buffer[ 1024 ];
- sprintf( buffer, "Warning: The font '%s' Size: '%d' Bold: '%d', specified in the config file could not be loaded. Does that font exist?",
- fontBuffer, size, bold );
- MessageBox( m_appHWnd, buffer, "Cannot Load Font", MB_OK );
-
- } // end if
- } // end for i
- // close the file
- fclose( fp );
- } // end readFontFile
- // GUIEdit::writeFontFile =====================================================
- /** If we can, write a file containing a definition of all the fonts
- * we have loaded */
- //=============================================================================
- void GUIEdit::writeFontFile( char *filename )
- {
- FILE *fp;
- // sanity
- if( filename == NULL )
- return;
- // open the file
- fp = fopen( filename, "w" );
- if( fp == NULL )
- return; // dont bother making an error, it's likely to be read only a lot
- // available fonts
- Int count = TheFontLibrary->getCount();
- fprintf( fp, "AVAILABLE_FONT_COUNT = %d\n", count );
- GameFont *font;
- for( font = TheFontLibrary->firstFont();
- font;
- font = TheFontLibrary->nextFont( font ) )
- {
- fprintf( fp, "AVAILABLEFONT = \"%s\" Size: %d Bold: %d\n",
- font->nameString.str(), font->pointSize, font->bold );
- } // end for
- // close the file
- fclose( fp );
- } // end writeFontFile
- // GUIEdit::setMode ===========================================================
- /** Set a new mode for the editor */
- //=============================================================================
- void GUIEdit::setMode( EditMode mode )
- {
- static TranslatorID transID = 0;
- // if same mode do nothing
- if( m_mode == mode )
- return;
- // if leaving test mode, remove the translator for test input
- if( m_mode == MODE_TEST_RUN )
- {
- TheMessageStream->removeTranslator( transID );
- transID = 0;
- } // end if
- // assign new mode
- m_mode = mode;
- // uncheck menu item for test mode by default
- unCheckMenuItem( MENU_TEST_MODE );
-
- // update status message
- switch( m_mode )
- {
- // ------------------------------------------------------------------------
- case MODE_TEST_RUN:
- statusMessage( STATUS_MODE, "Mode: Test Run" );
- // check menu item for test mode
- checkMenuItem( MENU_TEST_MODE );
- // attach window translator to stream for testing
- transID = TheMessageStream->attachTranslator( new WindowTranslator, 10 );
- break;
- // ------------------------------------------------------------------------
- case MODE_EDIT:
- setCursor( CURSOR_NORMAL );
- statusMessage( STATUS_MODE, "Ready" );
- break;
- // ------------------------------------------------------------------------
- case MODE_DRAG_MOVE:
- setCursor( CURSOR_MOVE );
- statusMessage( STATUS_MODE, "Drag window with mouse" );
- break;
- // ------------------------------------------------------------------------
- case MODE_KEYBOARD_MOVE:
- //setCursor( CURSOR_MOVE );
- statusMessage( STATUS_MODE, "Hit enter to accept or Esc to cancel" );
- break;
- // ------------------------------------------------------------------------
- case MODE_RESIZE_TOP_LEFT:
- setCursor( CURSOR_SIZE_NWSE );
- statusMessage( STATUS_MODE, "Drag top left corner to resize" );
- break;
- // ------------------------------------------------------------------------
- case MODE_RESIZE_TOP_RIGHT:
- setCursor( CURSOR_SIZE_NESW );
- statusMessage( STATUS_MODE, "Drag top right corner to resize" );
- break;
- // ------------------------------------------------------------------------
- case MODE_RESIZE_BOTTOM_RIGHT:
- setCursor( CURSOR_SIZE_NWSE );
- statusMessage( STATUS_MODE, "Drag bottom right corner to resize" );
- break;
- // ------------------------------------------------------------------------
- case MODE_RESIZE_BOTTOM_LEFT:
- setCursor( CURSOR_SIZE_NESW );
- statusMessage( STATUS_MODE, "Drag bottom left corner to resize" );
- break;
- // ------------------------------------------------------------------------
- case MODE_RESIZE_TOP:
- setCursor( CURSOR_SIZE_NS );
- statusMessage( STATUS_MODE, "Drag top to resize" );
- break;
- // ------------------------------------------------------------------------
- case MODE_RESIZE_BOTTOM:
- setCursor( CURSOR_SIZE_NS );
- statusMessage( STATUS_MODE, "Drag bottom to resize" );
- break;
- // ------------------------------------------------------------------------
- case MODE_RESIZE_LEFT:
- setCursor( CURSOR_SIZE_WE );
- statusMessage( STATUS_MODE, "Drag left to resize" );
- break;
- // ------------------------------------------------------------------------
- case MODE_RESIZE_RIGHT:
- setCursor( CURSOR_SIZE_WE );
- statusMessage( STATUS_MODE, "Drag right to resize" );
- break;
- } // end switch
- } // end setMode
- // GUIEdit::setCursor =========================================================
- /** Set the cursor to the specified type */
- //=============================================================================
- void GUIEdit::setCursor( CursorType type )
- {
- char *identifier;
- switch( type )
- {
- // ------------------------------------------------------------------------
- case CURSOR_NORMAL:
- identifier = IDC_ARROW;
- break;
- // ------------------------------------------------------------------------
- case CURSOR_MOVE:
- identifier = IDC_SIZEALL;
- break;
- // ------------------------------------------------------------------------
- case CURSOR_SIZE_NESW:
- identifier = IDC_SIZENESW;
- break;
- // ------------------------------------------------------------------------
- case CURSOR_SIZE_NS:
- identifier = IDC_SIZENS;
- break;
- // ------------------------------------------------------------------------
- case CURSOR_SIZE_NWSE:
- identifier = IDC_SIZENWSE;
- break;
- // ------------------------------------------------------------------------
- case CURSOR_SIZE_WE:
- identifier = IDC_SIZEWE;
- break;
- // ------------------------------------------------------------------------
- case CURSOR_WAIT:
- identifier = IDC_WAIT;
- break;
- } // end switchType
- // set the new cursor
- SetCursor( LoadCursor( NULL, identifier ) );
- } // end setCursor
- // pointInChild ===============================================================
- /** Given a mouse position, get the topmost window at that location. We needed
- to pull this out into it's own special case function since the standard
- winPointInAnyChild is used by the game and we needed a special case to
- select a disabled control in GUIEdit */
- //=============================================================================
- static GameWindow *pointInChild( Int x, Int y , GameWindow *win)
- {
- GameWindow *parent;
- GameWindow *child;
- ICoord2D origin;
- IRegion2D tempRegion;
- Int tempX, tempY;
- for( child = win->winGetChild(); child; child = child->winGetNext() )
- {
- child->winGetRegion(&tempRegion);
- origin = tempRegion.lo;
- parent = child->winGetParent();
- while( parent )
- {
- parent->winGetRegion(&tempRegion);
- origin.x += tempRegion.lo.x;
- origin.y += tempRegion.lo.y;
- parent = parent->winGetParent();
- } // end while
- child->winGetSize(&tempX,&tempY);
- if( x >= origin.x && x <= origin.x + tempX &&
- y >= origin.y && y <= origin.y + tempY &&
- BitTest( child->winGetStatus(), WIN_STATUS_HIDDEN ) == FALSE)
- return child->winPointInChild( x, y );
- } // end for child
- // not in any children, must be in parent
- return win;
- } // end pointInChild
- // pointInAnyChild ============================================================
- /** Given a mouse position, get the topmost window at that location. We needed
- to pull this out into it's own special case function since the standard
- winPointInAnyChild is used by the game and we needed a special case to
- select a disabled control in GUIEdit */
- //=============================================================================
- static GameWindow *pointInAnyChild( Int x, Int y, Bool ignoreHidden, GameWindow *win )
- {
- GameWindow *parent;
- GameWindow *child;
- ICoord2D origin;
- IRegion2D tempRegion;
- Int tempX, tempY;
- for( child = win->winGetChild(); child; child = child->winGetNext() )
- {
- child->winGetRegion(&tempRegion);
- origin = tempRegion.lo;
- parent = child->winGetParent();
- while( parent )
- {
- parent->winGetRegion(&tempRegion);
- origin.x += tempRegion.lo.x;
- origin.y += tempRegion.lo.y;
- parent = parent->winGetParent();
- } // end while
- child->winGetSize(&tempX,&tempY);
- if( x >= origin.x && x <= origin.x + tempX &&
- y >= origin.y && y <= origin.y + tempY )
- {
- if( !(ignoreHidden == TRUE && BitTest( child->winGetStatus(), WIN_STATUS_HIDDEN )) )
- return pointInChild( x, y , child);
- } // end if
- } // end for child
- // not in any children, must be in parent
- return win;
- } // end pointInAnyChild
- // GUIEdit::getWindowAtPos ====================================================
- /** Given a mouse position, get the topmost window at that location */
- //=============================================================================
- GameWindow *GUIEdit::getWindowAtPos( Int x, Int y )
- {
- GameWindow *window;
- GameWindow *pick = NULL;
- IRegion2D region;
- for( window = TheWindowManager->winGetWindowList();
- window;
- window = window->winGetNext() )
- {
-
- // get window region
- window->winGetRegion( ®ion );
- if( x >= region.lo.x && x <= region.hi.x &&
- y >= region.lo.y && y <= region.hi.y )
- {
- pick = pointInAnyChild( x, y, FALSE, window );
- break; // exit for
- } // end if
- } // end for
- //
- // gadget controls are just composed of generic windows and buttons,
- // we will not allow you to select these componenets themselves in a gadget
- // because the gadget is the atomic "unit" as far as GUI editing goes.
- // If we've picked a gadget component we will instead just return the gadget
- // itself
- //
- if( pick )
- {
- GameWindow *parent = pick->winGetParent();
- //
- // all gadget components are children of their parent, therefore they
- // all have a parent
- //
- if( parent )
- {
-
- if( BitTest( parent->winGetStyle(), GWS_VERT_SLIDER |
- GWS_HORZ_SLIDER |
- GWS_SCROLL_LISTBOX |
- GWS_COMBO_BOX |
- GWS_TAB_CONTROL
- )
- )
- {
-
- // the parent is what we care about
- pick = parent;
-
- //
- // the parent is the thing we want to return here, unless we clicked
- // on the thumb of a scroll list box, that element is implemented as
- // a slider, therefore in that situation only we want to return the
- // parent of the slider
- //
- if( BitTest( parent->winGetStyle(), GWS_HORZ_SLIDER |
- GWS_VERT_SLIDER ) )
- {
- GameWindow *grandParent = parent->winGetParent();
- if( grandParent && BitTest( grandParent->winGetStyle(),
- GWS_SCROLL_LISTBOX ) )
- pick = grandParent;
- } // end if
- //must check to see of the parent of a scroll box is a combo box
- if(BitTest(pick->winGetStyle(), GWS_SCROLL_LISTBOX))
- {
- GameWindow *grandParent = pick->winGetParent();
- if( grandParent && BitTest( grandParent->winGetStyle(), GWS_COMBO_BOX))
- pick = grandParent;
- }
- } // end if
- } // end if
- } // end if
- return pick;
- } // end getWindowAtPos
- // GUIEdit::clipCreationParamsToParent ========================================
- /** when creating child windows we don't want them to exist outside the
- * parent so we use this to clip them to the the parent size and
- * locations */
- //=============================================================================
- void GUIEdit::clipCreationParamsToParent( GameWindow *parent,
- Int *x, Int *y,
- Int *width, Int *height )
- {
- IRegion2D parentScreenRegion;
- ICoord2D parentSize;
- ICoord2D parentPos;
- Int newX, newY,
- newWidth, newHeight;
- // sanity
- if( parent == NULL ||
- x == NULL || y == NULL ||
- width == NULL || height == NULL )
- return;
- // get parent screen region and size
- parent->winGetScreenPosition( &parentPos.x, &parentPos.y );
- parent->winGetSize( &parentSize.x, &parentSize.y );
- //
- // compute the screen region, note this is NOT the same as the region
- // that comes back from winGetRegion, those regions are relative to their
- // parents
- //
- parentScreenRegion.lo.x = parentPos.x;
- parentScreenRegion.lo.y = parentPos.y;
- parentScreenRegion.hi.x = parentPos.x + parentSize.x;
- parentScreenRegion.hi.y = parentPos.y + parentSize.y;
- //
- // the new window position is really the difference between where
- // we clicked and the parent location
- //
- newX = *x - parentScreenRegion.lo.x;
- newY = *y - parentScreenRegion.lo.y;
- // new child windows must stay contained within their parent
- newWidth = *width;
- if( *x + *width > parentScreenRegion.hi.x )
- newWidth = parentSize.x - newX;
- newHeight = *height;
- if( *y + *height > parentScreenRegion.hi.y )
- newHeight = parentSize.y - newY;
- *x = newX;
- *y = newY;
- *width = newWidth;
- *height= newHeight;
- } // end clipcreationParamsToParent
- ///////////////////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////////////////
- // GUIEdit::deleteAllWindows ==================================================
- /** Delete all windows in the editor */
- //=============================================================================
- void GUIEdit::deleteAllWindows( void )
- {
- GameWindow *window, *next;
- window = TheWindowManager->winGetWindowList();
- while( window )
- {
- next = window->winGetNext();
- deleteWindow( window );
- window = next;
- } // end while
- } // end deleteAllWindows
- // GUIEdit::removeWindowCleanup ===============================================
- /** This is called on each window before it is deleted or removed from
- * the active windows in the editor to allow the system to
- * cleanup before the delete */
- //=============================================================================
- void GUIEdit::removeWindowCleanup( GameWindow *window )
- {
- // end of recursion
- if( window == NULL )
- return;
- //
- // unselect the window if selected, this should be done first as further
- // operations like deleting the tree entry change selections
- //
- unSelectWindow( window );
- // remove this window from the hierarchy
- TheHierarchyView->removeWindow( window );
- // take this out of the property target if present
- if( m_propertyTarget == window )
- m_propertyTarget = NULL;
- // notify the edit window this is going away
- TheEditWindow->notifyWindowDeleted( window );
- //
- // any children of this window will be destroyed as well, do cleanup
- // for them as well
- //
- GameWindow *child;
- for( child = window->winGetChild(); child; child = child->winGetNext() )
- removeWindowCleanup( child );
- } // end removeWindowCleanup
- // GUIEdit::deleteWindow ======================================================
- /** Delete the window from the editor */
- //=============================================================================
- void GUIEdit::deleteWindow( GameWindow *window )
- {
- // have the editor cleanup all references to this window
- removeWindowCleanup( window );
- // destroy the game winodow
- TheWindowManager->winDestroy( window );
- // we've changed contents
- setUnsaved( TRUE );
- } // end deleteWindow
- // GUIEdit::newWindow =========================================================
- /** Create a new window of the specified type. This is the single creation
- * point for all windows created in the editor */
- //=============================================================================
- GameWindow *GUIEdit::newWindow( UnsignedInt windowStyle,
- GameWindow *parent,
- Int x, Int y,
- Int width, Int height )
- {
- GameWindow *window = NULL;
- // create the appropriate window based on style bit passed in
- switch( windowStyle )
- {
-
- // ------------------------------------------------------------------------
- case GWS_USER_WINDOW:
- window = newUserWindow( parent, x, y, width, height );
- break;
- // ------------------------------------------------------------------------
- case GWS_PUSH_BUTTON:
- window = newPushButton( parent, x, y, width, height );
- break;
- // ------------------------------------------------------------------------
- case GWS_CHECK_BOX:
- window = newCheckBox( parent, x, y, width, height );
- break;
- // ------------------------------------------------------------------------
- case GWS_RADIO_BUTTON:
- window = newRadioButton( parent, x, y, width, height );
- break;
- // ------------------------------------------------------------------------
- case GWS_TAB_CONTROL:
- window = newTabControl( parent, x, y, width, height );
- break;
- // ------------------------------------------------------------------------
- case GWS_HORZ_SLIDER:
- window = newHorizontalSlider( parent, x, y, width, height );
- break;
- // ------------------------------------------------------------------------
- case GWS_VERT_SLIDER:
- window = newVerticalSlider( parent, x, y, width, height );
- break;
- // ------------------------------------------------------------------------
- case GWS_SCROLL_LISTBOX:
- window = newListbox( parent, x, y, width, height );
- break;
-
- // ------------------------------------------------------------------------
- case GWS_COMBO_BOX:
- window = newComboBox( parent, x, y, width, height );
- break;
- // ------------------------------------------------------------------------
- case GWS_PROGRESS_BAR:
- window = newProgressBar( parent, x, y, width, height );
- break;
- // ------------------------------------------------------------------------
- case GWS_ENTRY_FIELD:
- window = newTextEntry( parent, x, y, width, height );
- break;
- // ------------------------------------------------------------------------
- case GWS_STATIC_TEXT:
- window = newStaticText( parent, x, y, width, height );
- break;
- // ------------------------------------------------------------------------
- default:
- MessageBox( m_appHWnd, "Unknown window type to newWindow()", "ERROR",
- MB_OK | MB_ICONERROR );
- break;
- } // end switch
- return window;
- } // end newWindow
- // GUIEdit::newUserWindow =====================================================
- /** Create a new window at the given location */
- //=============================================================================
- GameWindow *GUIEdit::newUserWindow( GameWindow *parent, Int x, Int y,
- Int width, Int height )
- {
- UnsignedInt status = WIN_STATUS_ENABLED;
- GameWindow *window;
- // validate the parent to disallow illegal relationships
- if( validateParentForCreate( parent ) == FALSE )
- return NULL;
- //
- // if there is a parent present we need to translate the screen x and y
- // location to coords that are local to the parent window
- //
- if( parent )
- clipCreationParamsToParent( parent, &x, &y, &width, &height );
- // create the new window
- window = TheWindowManager->winCreate( parent, status,
- x, y,
- width, height,
- NULL, NULL );
- // a window created in the editor here is a user window
- WinInstanceData *instData = window->winGetInstanceData();
- BitSet( instData->m_style, GWS_USER_WINDOW );
- // set default colors based on the default scheme
- ImageAndColorInfo *info;
- info = TheDefaultScheme->getImageAndColor( GENERIC_ENABLED );
- window->winSetEnabledImage( 0, info->image );
- window->winSetEnabledColor( 0, info->color );
- window->winSetEnabledBorderColor( 0, info->borderColor );
- info = TheDefaultScheme->getImageAndColor( GENERIC_DISABLED );
- window->winSetDisabledImage( 0, info->image );
- window->winSetDisabledColor( 0, info->color );
- window->winSetDisabledBorderColor( 0, info->borderColor );
- info = TheDefaultScheme->getImageAndColor( GENERIC_HILITE );
- window->winSetHiliteImage( 0, info->image );
- window->winSetHiliteColor( 0, info->color );
- window->winSetHiliteBorderColor( 0, info->borderColor );
- // contents have changed
- setUnsaved( TRUE );
- // notify the editor of the new window
- notifyNewWindow( window );
- return window;
- } // end newUserWindow
- // GUIEdit::newPushButton =====================================================
- /** Create a new push button */
- //=============================================================================
- GameWindow *GUIEdit::newPushButton( GameWindow *parent,
- Int x, Int y, Int width, Int height )
- {
- GameWindow *window;
- WinInstanceData instData;
- UnsignedInt status = WIN_STATUS_ENABLED | WIN_STATUS_IMAGE;
- // validate the parent to disallow illegal relationships
- if( validateParentForCreate( parent ) == FALSE )
- return NULL;
- // keep the button inside a parent if present
- if( parent )
- clipCreationParamsToParent( parent, &x, &y, &width, &height );
- // initialize inst data
- instData.init();
- instData.m_style = GWS_PUSH_BUTTON | GWS_MOUSE_TRACK;
- instData.m_textLabelString = "Button";
- window = TheWindowManager->gogoGadgetPushButton( parent,
- status,
- x, y,
- width, height,
- &instData,
- NULL,
- TRUE );
- // set default colors based on the default scheme
- if( window )
- {
- ImageAndColorInfo *info;
- info = TheDefaultScheme->getImageAndColor( BUTTON_ENABLED );
- GadgetButtonSetEnabledImage( window, info->image );
- GadgetButtonSetEnabledColor( window, info->color );
- GadgetButtonSetEnabledBorderColor( window, info->borderColor );
- info = TheDefaultScheme->getImageAndColor( BUTTON_ENABLED_PUSHED );
- GadgetButtonSetEnabledSelectedImage( window, info->image );
- GadgetButtonSetEnabledSelectedColor( window, info->color );
- GadgetButtonSetEnabledSelectedBorderColor( window, info->borderColor );
- info = TheDefaultScheme->getImageAndColor( BUTTON_DISABLED );
- GadgetButtonSetDisabledImage( window, info->image );
- GadgetButtonSetDisabledColor( window, info->color );
- GadgetButtonSetDisabledBorderColor( window, info->borderColor );
- info = TheDefaultScheme->getImageAndColor( BUTTON_DISABLED_PUSHED );
- GadgetButtonSetDisabledSelectedImage( window, info->image );
- GadgetButtonSetDisabledSelectedColor( window, info->color );
- GadgetButtonSetDisabledSelectedBorderColor( window, info->borderColor );
- info = TheDefaultScheme->getImageAndColor( BUTTON_HILITE );
- GadgetButtonSetHiliteImage( window, info->image );
- GadgetButtonSetHiliteColor( window, info->color );
- GadgetButtonSetHiliteBorderColor( window, info->borderColor );
- info = TheDefaultScheme->getImageAndColor( BUTTON_HILITE_PUSHED );
- GadgetButtonSetHiliteSelectedImage( window, info->image );
- GadgetButtonSetHiliteSelectedColor( window, info->color );
- GadgetButtonSetHiliteSelectedBorderColor( window, info->borderColor );
- Color color, border;
- color = TheDefaultScheme->getEnabledTextColor();
- border = TheDefaultScheme->getEnabledTextBorderColor();
- window->winSetEnabledTextColors( color, border );
- color = TheDefaultScheme->getDisabledTextColor();
- border = TheDefaultScheme->getDisabledTextBorderColor();
- window->winSetDisabledTextColors( color, border );
- color = TheDefaultScheme->getHiliteTextColor();
- border = TheDefaultScheme->getHiliteTextBorderColor();
- window->winSetHiliteTextColors( color, border );
- // set default font
- window->winSetFont( TheDefaultScheme->getFont() );
- } // end if
- // contents have changed
- setUnsaved( TRUE );
- // notify the editor of the new window
- notifyNewWindow( window );
- return window;
- } // end newPushButton
- // GUIEdit::newCheckBox =======================================================
- /** Create a new check box */
- //=============================================================================
- GameWindow *GUIEdit::newCheckBox( GameWindow *parent,
- Int x, Int y, Int width, Int height )
- {
- GameWindow *window;
- WinInstanceData instData;
- UnsignedInt status = WIN_STATUS_ENABLED | WIN_STATUS_IMAGE;
- // validate the parent to disallow illegal relationships
- if( validateParentForCreate( parent ) == FALSE )
- return NULL;
- // keep inside a parent if present
- if( parent )
- clipCreationParamsToParent( parent, &x, &y, &width, &height );
- // initialize inst data
- instData.init();
- instData.m_style = GWS_CHECK_BOX | GWS_MOUSE_TRACK;
- instData.m_textLabelString = "Check";
- // create gadget
- window = TheWindowManager->gogoGadgetCheckbox( parent,
- status,
- x, y,
- width, height,
- &instData,
- NULL,
- TRUE );
- // set default colors based on the default scheme
- if( window )
- {
- ImageAndColorInfo *info;
- info = TheDefaultScheme->getImageAndColor( CHECK_BOX_ENABLED );
- GadgetCheckBoxSetEnabledImage( window, info->image );
- GadgetCheckBoxSetEnabledColor( window, info->color );
- GadgetCheckBoxSetEnabledBorderColor( window, info->borderColor );
- info = TheDefaultScheme->getImageAndColor( CHECK_BOX_ENABLED_UNCHECKED_BOX );
- GadgetCheckBoxSetEnabledUncheckedBoxImage( window, info->image );
- GadgetCheckBoxSetEnabledUncheckedBoxColor( window, info->color );
- GadgetCheckBoxSetEnabledUncheckedBoxBorderColor( window, info->borderColor );
- info = TheDefaultScheme->getImageAndColor( CHECK_BOX_ENABLED_CHECKED_BOX );
- GadgetCheckBoxSetEnabledCheckedBoxImage( window, info->image );
- GadgetCheckBoxSetEnabledCheckedBoxColor( window, info->color );
- GadgetCheckBoxSetEnabledCheckedBoxBorderColor( window, info->borderColor );
- info = TheDefaultScheme->getImageAndColor( CHECK_BOX_DISABLED );
- GadgetCheckBoxSetDisabledImage( window, info->image );
- GadgetCheckBoxSetDisabledColor( window, info->color );
- GadgetCheckBoxSetDisabledBorderColor( window, info->borderColor );
- info = TheDefaultScheme->getImageAndColor( CHECK_BOX_DISABLED_UNCHECKED_BOX );
- GadgetCheckBoxSetDisabledUncheckedBoxImage( window, info->image );
- GadgetCheckBoxSetDisabledUncheckedBoxColor( window, info->color );
- GadgetCheckBoxSetDisabledUncheckedBoxBorderColor( window, info->borderColor );
- info = TheDefaultScheme->getImageAndColor( CHECK_BOX_DISABLED_CHECKED_BOX );
- GadgetCheckBoxSetDisabledCheckedBoxImage( window, info->image );
- GadgetCheckBoxSetDisabledCheckedBoxColor( window, info->color );
- GadgetCheckBoxSetDisabledCheckedBoxBorderColor( window, info->borderColor );
- info = TheDefaultScheme->getImageAndColor( CHECK_BOX_HILITE );
- GadgetCheckBoxSetHiliteImage( window, info->image );
- GadgetCheckBoxSetHiliteColor( window, info->color );
- GadgetCheckBoxSetHiliteBorderColor( window, info->borderColor );
- info = TheDefaultScheme->getImageAndColor( CHECK_BOX_HILITE_UNCHECKED_BOX );
- GadgetCheckBoxSetHiliteUncheckedBoxImage( window, info->image );
- GadgetCheckBoxSetHiliteUncheckedBoxColor( window, info->color );
- GadgetCheckBoxSetHiliteUncheckedBoxBorderColor( window, info->borderColor );
- info = TheDefaultScheme->getImageAndColor( CHECK_BOX_HILITE_CHECKED_BOX );
- GadgetCheckBoxSetHiliteCheckedBoxImage( window, info->image );
- GadgetCheckBoxSetHiliteCheckedBoxColor( window, info->color );
- GadgetCheckBoxSetHiliteCheckedBoxBorderColor( window, info->borderColor );
- Color color, border;
- color = TheDefaultScheme->getEnabledTextColor();
- border = TheDefaultScheme->getEnabledTextBorderColor();
- window->winSetEnabledTextColors( color, border );
- color = TheDefaultScheme->getDisabledTextColor();
- border = TheDefaultScheme->getDisabledTextBorderColor();
- window->winSetDisabledTextColors( color, border );
- color = TheDefaultScheme->getHiliteTextColor();
- border = TheDefaultScheme->getHiliteTextBorderColor();
- window->winSetHiliteTextColors( color, border );
- // set default font
- window->winSetFont( TheDefaultScheme->getFont() );
- } // end if
- // contents have changed
- setUnsaved( TRUE );
- // notify the editor of the new window
- notifyNewWindow( window );
- return window;
- } // end newCheckBox
- // GUIEdit::newRadioButton ====================================================
- /** Create a new radio button */
- //=============================================================================
- GameWindow *GUIEdit::newRadioButton( GameWindow *parent,
- Int x, Int y, Int width, Int height )
- {
- RadioButtonData radioData;
- GameWindow *window;
- WinInstanceData instData;
- UnsignedInt status = WIN_STATUS_ENABLED | WIN_STATUS_IMAGE;
- // validate the parent to disallow illegal relationships
- if( validateParentForCreate( parent ) == FALSE )
- return NULL;
- // keep inside a parent if present
- if( parent )
- clipCreationParamsToParent( parent, &x, &y, &width, &height );
- // initialize inst data
- instData.init();
- instData.m_style = GWS_RADIO_BUTTON | GWS_MOUSE_TRACK;
- memset( &radioData, 0, sizeof( radioData ) );
- instData.m_textLabelString = "Radio";
- // create gadget
- window = TheWindowManager->gogoGadgetRadioButton( parent,
- status,
- x, y,
- width, height,
- &instData,
- &radioData,
- NULL,
- TRUE );
- // set default colors based on the default scheme
- if( window )
- {
- ImageAndColorInfo *info;
- info = TheDefaultScheme->getImageAndColor( RADIO_ENABLED );
- GadgetRadioSetEnabledImage( window, info->image );
- GadgetRadioSetEnabledColor( window, info->color );
- GadgetRadioSetEnabledBorderColor( window, info->borderColor );
- info = TheDefaultScheme->getImageAndColor( RADIO_ENABLED_UNCHECKED_BOX );
- GadgetRadioSetEnabledUncheckedBoxImage( window, info->image );
- GadgetRadioSetEnabledUncheckedBoxColor( window, info->color );
- GadgetRadioSetEnabledUncheckedBoxBorderColor( window, info->borderColor );
- info = TheDefaultScheme->getImageAndColor( RADIO_ENABLED_CHECKED_BOX );
- GadgetRadioSetEnabledCheckedBoxImage( window, info->image );
- GadgetRadioSetEnabledCheckedBoxColor( window, info->color );
- GadgetRadioSetEnabledCheckedBoxBorderColor( window, info->borderColor );
- info = TheDefaultScheme->getImageAndColor( RADIO_DISABLED );
- GadgetRadioSetDisabledImage( window, info->image );
- GadgetRadioSetDisabledColor( window, info->color );
- GadgetRadioSetDisabledBorderColor( window, info->borderColor );
- info = TheDefaultScheme->getImageAndColor( RADIO_DISABLED_UNCHECKED_BOX );
- GadgetRadioSetDisabledUncheckedBoxImage( window, info->image );
- GadgetRadioSetDisabledUncheckedBoxColor( window, info->color );
- GadgetRadioSetDisabledUncheckedBoxBorderColor( window, info->borderColor );
- info = TheDefaultScheme->getImageAndColor( RADIO_DISABLED_CHECKED_BOX );
- GadgetRadioSetDisabledCheckedBoxImage( window, info->image );
- GadgetRadioSetDisabledCheckedBoxColor( window, info->color );
- GadgetRadioSetDisabledCheckedBoxBorderColor( window, info->borderColor );
- info = TheDefaultScheme->getImageAndColor( RADIO_HILITE );
- GadgetRadioSetHiliteImage( window, info->image );
- GadgetRadioSetHiliteColor( window, info->color );
- GadgetRadioSetHiliteBorderColor( window, info->borderColor );
- info = TheDefaultScheme->getImageAndColor( RADIO_HILITE_UNCHECKED_BOX );
- GadgetRadioSetHiliteUncheckedBoxImage( window, info->image );
- GadgetRadioSetHiliteUncheckedBoxColor( window, info->color );
- GadgetRadioSetHiliteUncheckedBoxBorderColor( window, info->borderColor );
- info = TheDefaultScheme->getImageAndColor( RADIO_HILITE_CHECKED_BOX );
- GadgetRadioSetHiliteCheckedBoxImage( window, info->image );
- GadgetRadioSetHiliteCheckedBoxColor( window, info->color );
- GadgetRadioSetHiliteCheckedBoxBorderColor( window, info->borderColor );
- Color color, border;
- color = TheDefaultScheme->getEnabledTextColor();
- border = TheDefaultScheme->getEnabledTextBorderColor();
- window->winSetEnabledTextColors( color, border );
- color = TheDefaultScheme->getDisabledTextColor();
- border = TheDefaultScheme->getDisabledTextBorderColor();
- window->winSetDisabledTextColors( color, border );
- color = TheDefaultScheme->getHiliteTextColor();
- border = TheDefaultScheme->getHiliteTextBorderColor();
- window->winSetHiliteTextColors( color, border );
- // set default font
- window->winSetFont( TheDefaultScheme->getFont() );
- } // end if
- // contents have changed
- setUnsaved( TRUE );
- // notify the editor of the new window
- notifyNewWindow( window );
- return window;
- } // end newRadioButton
- // GUIEdit::newTabControl ====================================================
- /** Create a tab control gadget */
- //=============================================================================
- GameWindow *GUIEdit::newTabControl( GameWindow *parent,
- Int x, Int y, Int width, Int height )
- {
- TabControlData tabControlData;
- GameWindow *window;
- WinInstanceData instData;
- UnsignedInt status = WIN_STATUS_ENABLED;
- // validate the parent to disallow illegal relationships
- if( validateParentForCreate( parent ) == FALSE )
- return NULL;
- // keep inside a parent if present
- if( parent )
- clipCreationParamsToParent( parent, &x, &y, &width, &height );
- // initialize inst data
- instData.init();
- instData.m_style = GWS_TAB_CONTROL | GWS_MOUSE_TRACK;
- memset( &tabControlData, 0, sizeof( tabControlData ) );
- tabControlData.tabOrientation = TP_TOPLEFT;
- tabControlData.tabEdge = TP_TOP_SIDE;
- tabControlData.tabWidth = 50;
- tabControlData.tabHeight = 25;
- tabControlData.tabCount = 2;
- tabControlData.paneBorder = 5;
- // create gadget
- window = TheWindowManager->gogoGadgetTabControl( parent,
- status,
- x, y,
- width, height,
- &instData,
- &tabControlData,
- NULL,
- TRUE );
- // set default colors based on the default scheme
- if( window )
- {
- ImageAndColorInfo *info;
- info = TheDefaultScheme->getImageAndColor( TC_TAB_0_ENABLED );
- GadgetTabControlSetEnabledImageTabZero( window, info->image );
- GadgetTabControlSetEnabledColorTabZero( window, info->color );
- GadgetTabControlSetEnabledBorderColorTabZero( window, info->borderColor );
- info = TheDefaultScheme->getImageAndColor( TC_TAB_1_ENABLED );
- GadgetTabControlSetEnabledImageTabOne( window, info->image );
- GadgetTabControlSetEnabledColorTabOne( window, info->color );
- GadgetTabControlSetEnabledBorderColorTabOne( window, info->borderColor );
- info = TheDefaultScheme->getImageAndColor( TC_TAB_2_ENABLED );
- GadgetTabControlSetEnabledImageTabTwo( window, info->image );
- GadgetTabControlSetEnabledColorTabTwo( window, info->color );
- GadgetTabControlSetEnabledBorderColorTabTwo( window, info->borderColor );
- info = TheDefaultScheme->getImageAndColor( TC_TAB_3_ENABLED );
- GadgetTabControlSetEnabledImageTabThree( window, info->image );
- GadgetTabControlSetEnabledColorTabThree( window, info->color );
- GadgetTabControlSetEnabledBorderColorTabThree( window, info->borderColor );
- info = TheDefaultScheme->getImageAndColor( TC_TAB_4_ENABLED );
- GadgetTabControlSetEnabledImageTabFour( window, info->image );
- GadgetTabControlSetEnabledColorTabFour( window, info->color );
- GadgetTabControlSetEnabledBorderColorTabFour( window, info->borderColor );
- info = TheDefaultScheme->getImageAndColor( TC_TAB_5_ENABLED );
- GadgetTabControlSetEnabledImageTabFive( window, info->image );
- GadgetTabControlSetEnabledColorTabFive( window, info->color );
- GadgetTabControlSetEnabledBorderColorTabFive( window, info->borderColor );
- info = TheDefaultScheme->getImageAndColor( TC_TAB_6_ENABLED );
- GadgetTabControlSetEnabledImageTabSix( window, info->image );
- GadgetTabControlSetEnabledColorTabSix( window, info->color );
- GadgetTabControlSetEnabledBorderColorTabSix( window, info->borderColor );
- info = TheDefaultScheme->getImageAndColor( TC_TAB_7_ENABLED );
- GadgetTabControlSetEnabledImageTabSeven( window, info->image );
- GadgetTabControlSetEnabledColorTabSeven( window, info->color );
- GadgetTabControlSetEnabledBorderColorTabSeven( window, info->borderColor );
- info = TheDefaultScheme->getImageAndColor( TAB_CONTROL_ENABLED );
- GadgetTabControlSetEnabledImageBackground( window, info->image );
- GadgetTabControlSetEnabledColorBackground( window, info->color );
- GadgetTabControlSetEnabledBorderColorBackground( window, info->borderColor );
-
- info = TheDefaultScheme->getImageAndColor( TC_TAB_0_DISABLED );
- GadgetTabControlSetDisabledImageTabZero( window, info->image );
- GadgetTabControlSetDisabledColorTabZero( window, info->color );
- GadgetTabControlSetDisabledBorderColorTabZero( window, info->borderColor );
- info = TheDefaultScheme->getImageAndColor( TC_TAB_1_DISABLED );
- GadgetTabControlSetDisabledImageTabOne( window, info->image );
- GadgetTabControlSetDisabledColorTabOne( window, info->color );
- GadgetTabControlSetDisabledBorderColorTabOne( window, info->borderColor );
- info = TheDefaultScheme->getImageAndColor( TC_TAB_2_DISABLED );
- GadgetTabControlSetDisabledImageTabTwo( window, info->image );
- GadgetTabControlSetDisabledColorTabTwo( window, info->color );
- GadgetTabControlSetDisabledBorderColorTabTwo( window, info->borderColor );
- info = TheDefaultScheme->getImageAndColor( TC_TAB_3_DISABLED );
- GadgetTabControlSetDisabledImageTabThree( window, info->image );
- GadgetTabControlSetDisabledColorTabThree( window, info->color );
- GadgetTabControlSetDisabledBorderColorTabThree( window, info->borderColor );
- info = TheDefaultScheme->getImageAndColor( TC_TAB_4_DISABLED );
- GadgetTabControlSetDisabledImageTabFour( window, info->image );
- GadgetTabControlSetDisabledColorTabFour( window, info->color );
- GadgetTabControlSetDisabledBorderColorTabFour( window, info->borderColor );
- info = TheDefaultScheme->getImageAndColor( TC_TAB_5_DISABLED );
- GadgetTabControlSetDisabledImageTabFive( window, info->image );
- GadgetTabControlSetDisabledColorTabFive( window, info->color );
- GadgetTabControlSetDisabledBorderColorTabFive( window, info->borderColor );
- info = TheDefaultScheme->getImageAndColor( TC_TAB_6_DISABLED );
- GadgetTabControlSetDisabledImageTabSix( window, info->image );
- GadgetTabControlSetDisabledColorTabSix( window, info->color );
- GadgetTabControlSetDisabledBorderColorTabSix( window, info->borderColor );
- info = TheDefaultScheme->getImageAndColor( TC_TAB_7_DISABLED );
- GadgetTabControlSetDisabledImageTabSeven( window, info->image );
- GadgetTabControlSetDisabledColorTabSeven( window, info->color );
- GadgetTabControlSetDisabledBorderColorTabSeven( window, info->borderColor );
- info = TheDefaultScheme->getImageAndColor( TAB_CONTROL_DISABLED );
- GadgetTabControlSetDisabledImageBackground( window, info->image );
- GadgetTabControlSetDisabledColorBackground( window, info->color );
- GadgetTabControlSetDisabledBorderColorBackground( window, info->borderColor );
-
- info = TheDefaultScheme->getImageAndColor( TC_TAB_0_HILITE );
- GadgetTabControlSetHiliteImageTabZero( window, info->image );
- GadgetTabControlSetHiliteColorTabZero( window, info->color );
- GadgetTabControlSetHiliteBorderColorTabZero( window, info->borderColor );
- info = TheDefaultScheme->getImageAndColor( TC_TAB_1_HILITE );
- GadgetTabControlSetHiliteImageTabOne( window, info->image );
- GadgetTabControlSetHiliteColorTabOne( window, info->color );
- GadgetTabControlSetHiliteBorderColorTabOne( window, info->borderColor );
- info = TheDefaultScheme->getImageAndColor( TC_TAB_2_HILITE );
- GadgetTabControlSetHiliteImageTabTwo( window, info->image );
- GadgetTabControlSetHiliteColorTabTwo( window, info->color );
- GadgetTabControlSetHiliteBorderColorTabTwo( window, info->borderColor );
- info = TheDefaultScheme->getImageAndColor( TC_TAB_3_HILITE );
- GadgetTabControlSetHiliteImageTabThree( window, info->image );
- GadgetTabControlSetHiliteColorTabThree( window, info->color );
- GadgetTabControlSetHiliteBorderColorTabThree( window, info->borderColor );
- info = TheDefaultScheme->getImageAndColor( TC_TAB_4_HILITE );
- GadgetTabControlSetHiliteImageTabFour( window, info->image );
- GadgetTabControlSetHiliteColorTabFour( window, info->color );
- GadgetTabControlSetHiliteBorderColorTabFour( window, info->borderColor );
- info = TheDefaultScheme->getImageAndColor( TC_TAB_5_HILITE );
- GadgetTabControlSetHiliteImageTabFive( window, info->image );
- GadgetTabControlSetHiliteColorTabFive( window, info->color );
- GadgetTabControlSetHiliteBorderColorTabFive( window, info->borderColor );
- info = TheDefaultScheme->getImageAndColor( TC_TAB_6_HILITE );
- GadgetTabControlSetHiliteImageTabSix( window, info->image );
- GadgetTabControlSetHiliteColorTabSix( window, info->color );
- GadgetTabControlSetHiliteBorderColorTabSix( window, info->borderColor );
- info = TheDefaultScheme->getImageAndColor( TC_TAB_7_HILITE );
- GadgetTabControlSetHiliteImageTabSeven( window, info->image );
- GadgetTabControlSetHiliteColorTabSeven( window, info->color );
- GadgetTabControlSetHiliteBorderColorTabSeven( window, info->borderColor );
- info = TheDefaultScheme->getImageAndColor( TAB_CONTROL_HILITE );
- GadgetTabControlSetHiliteImageBackground( window, info->image );
- GadgetTabControlSetHiliteColorBackground( window, info->color );
- GadgetTabControlSetHiliteBorderColorBackground( window, info->borderColor );
- } // end if
- // contents have changed
- setUnsaved( TRUE );
- // notify the editor of the new window
- notifyNewWindow( window );
- return window;
- } // end newTabControl
- // GUIEdit::newHorizontalSlider ===============================================
- /** Create a new horizontal slider*/
- //=============================================================================
- GameWindow *GUIEdit::newHorizontalSlider( GameWindow *parent,
- Int x, Int y,
- Int width, Int height )
- {
- GameWindow *window;
- WinInstanceData instData;
- UnsignedInt status = WIN_STATUS_ENABLED | WIN_STATUS_IMAGE;
- // validate the parent to disallow illegal relationships
- if( validateParentForCreate( parent ) == FALSE )
- return NULL;
- // keep inside a parent if present
- if( parent )
- clipCreationParamsToParent( parent, &x, &y, &width, &height );
- // initialize inst data
- instData.init();
- instData.m_style = GWS_HORZ_SLIDER | GWS_MOUSE_TRACK;
- // initialize slider data
- SliderData sliderData;
- memset( &sliderData, 0, sizeof( sliderData ) );
- sliderData.maxVal = 100;
- sliderData.minVal = 0;
- sliderData.numTicks = 100;
- sliderData.position = 0;
- // make control
- window = TheWindowManager->gogoGadgetSlider( parent,
- status,
- x, y,
- width, height,
- &instData,
- &sliderData,
- NULL,
- TRUE );
- // set default colors based on the default scheme
- if( window )
- {
- ImageAndColorInfo *info;
- info = TheDefaultScheme->getImageAndColor( HSLIDER_ENABLED_LEFT );
- GadgetSliderSetEnabledImageLeft( window, info->image );
- GadgetSliderSetEnabledColor( window, info->color );
- GadgetSliderSetEnabledBorderColor( window, info->borderColor );
- info = TheDefaultScheme->getImageAndColor( HSLIDER_ENABLED_RIGHT );
- GadgetSliderSetEnabledImageRight( window, info->image );
- info = TheDefaultScheme->getImageAndColor( HSLIDER_ENABLED_CENTER );
- GadgetSliderSetEnabledImageCenter( window, info->image );
- info = TheDefaultScheme->getImageAndColor( HSLIDER_ENABLED_SMALL_CENTER );
- GadgetSliderSetEnabledImageSmallCenter( window, info->image );
- info = TheDefaultScheme->getImageAndColor( HSLIDER_DISABLED_LEFT );
- GadgetSliderSetDisabledImageLeft( window, info->image );
- GadgetSliderSetDisabledColor( window, info->color );
- GadgetSliderSetDisabledBorderColor( window, info->borderColor );
- info = TheDefaultScheme->getImageAndColor( HSLIDER_DISABLED_RIGHT );
- GadgetSliderSetDisabledImageRight( window, info->image );
- info = TheDefaultScheme->getImageAndColor( HSLIDER_DISABLED_CENTER );
- GadgetSliderSetDisabledImageCenter( window, info->image );
- info = TheDefaultScheme->getImageAndColor( HSLIDER_DISABLED_SMALL_CENTER );
- GadgetSliderSetDisabledImageSmallCenter( window, info->image );
- info = TheDefaultScheme->getImageAndColor( HSLIDER_HILITE_LEFT );
- GadgetSliderSetHiliteImageLeft( window, info->image );
- GadgetSliderSetHiliteColor( window, info->color );
- GadgetSliderSetHiliteBorderColor( window, info->borderColor );
- info = TheDefaultScheme->getImageAndColor( HSLIDER_HILITE_RIGHT );
- GadgetSliderSetHiliteImageRight( window, info->image );
- info = TheDefaultScheme->getImageAndColor( HSLIDER_HILITE_CENTER );
- GadgetSliderSetHiliteImageCenter( window, info->image );
- info = TheDefaultScheme->getImageAndColor( HSLIDER_HILITE_SMALL_CENTER );
- GadgetSliderSetHiliteImageSmallCenter( window, info->image );
- info = TheDefaultScheme->getImageAndColor( HSLIDER_THUMB_ENABLED );
- GadgetSliderSetEnabledThumbImage( window, info->image );
- GadgetSliderSetEnabledThumbColor( window, info->color );
- GadgetSliderSetEnabledThumbBorderColor( window, info->borderColor );
- info = TheDefaultScheme->getImageAndColor( HSLIDER_THUMB_ENABLED_PUSHED );
- GadgetSliderSetEnabledSelectedThumbImage( window, info->image );
- GadgetSliderSetEnabledSelectedThumbColor( window, info->color );
- GadgetSliderSetEnabledSelectedThumbBorderColor( window, info->borderColor );
- info = TheDefaultScheme->getImageAndColor( HSLIDER_THUMB_DISABLED );
- GadgetSliderSetDisabledThumbImage( window, info->image );
- GadgetSliderSetDisabledThumbColor( window, info->color );
- GadgetSliderSetDisabledThumbBorderColor( window, info->borderColor );
- info = TheDefaultScheme->getImageAndColor( HSLIDER_THUMB_DISABLED_PUSHED );
- GadgetSliderSetDisabledSelectedThumbImage( window, info->image );
- GadgetSliderSetDisabledSelectedThumbColor( window, info->color );
- GadgetSliderSetDisabledSelectedThumbBorderColor( window, info->borderColor );
- info = TheDefaultScheme->getImageAndColor( HSLIDER_THUMB_HILITE );
- GadgetSliderSetHiliteThumbImage( window, info->image );
- GadgetSliderSetHiliteThumbColor( window, info->color );
- GadgetSliderSetHiliteThumbBorderColor( window, info->borderColor );
- info = TheDefaultScheme->getImageAndColor( HSLIDER_THUMB_HILITE_PUSHED );
- GadgetSliderSetHiliteSelectedThumbImage( window, info->image );
- GadgetSliderSetHiliteSelectedThumbColor( window, info->color );
- GadgetSliderSetHiliteSelectedThumbBorderColor( window, info->borderColor );
- // set default font
- window->winSetFont( TheDefaultScheme->getFont() );
- } // end if
- // contents have changed
- setUnsaved( TRUE );
- // notify the editor of the new window
- notifyNewWindow( window );
- return window;
- } // end newHorizontalSlider
- // GUIEdit::newVerticlaSlider =================================================
- /** Create a new vertical slider */
- //=============================================================================
- GameWindow *GUIEdit::newVerticalSlider( GameWindow *parent,
- Int x, Int y,
- Int width, Int height )
- {
- GameWindow *window;
- WinInstanceData instData;
- UnsignedInt status = WIN_STATUS_ENABLED | WIN_STATUS_IMAGE;
- // validate the parent to disallow illegal relationships
- if( validateParentForCreate( parent ) == FALSE )
- return NULL;
- // keep inside a parent if present
- if( parent )
- clipCreationParamsToParent( parent, &x, &y, &width, &height );
- // initialize inst data
- instData.init();
- instData.m_style = GWS_VERT_SLIDER | GWS_MOUSE_TRACK;
- // initialize slider data
- SliderData sliderData;
- memset( &sliderData, 0, sizeof( sliderData ) );
- sliderData.maxVal = 100;
- sliderData.minVal = 0;
- sliderData.numTicks = 100;
- sliderData.position = 0;
- // make control
- window = TheWindowManager->gogoGadgetSlider( parent,
- status,
- x, y,
- width, height,
- &instData,
- &sliderData,
- NULL,
- TRUE );
- // set default colors based on the default scheme
- if( window )
- {
- ImageAndColorInfo *info;
- info = TheDefaultScheme->getImageAndColor( VSLIDER_ENABLED_TOP );
- GadgetSliderSetEnabledImageLeft( window, info->image );
- GadgetSliderSetEnabledColor( window, info->color );
- GadgetSliderSetEnabledBorderColor( window, info->borderColor );
- info = TheDefaultScheme->getImageAndColor( VSLIDER_ENABLED_BOTTOM );
- GadgetSliderSetEnabledImageRight( window, info->image );
- info = TheDefaultScheme->getImageAndColor( VSLIDER_ENABLED_CENTER );
- GadgetSliderSetEnabledImageCenter( window, info->image );
- info = TheDefaultScheme->getImageAndColor( VSLIDER_ENABLED_SMALL_CENTER );
- GadgetSliderSetEnabledImageSmallCenter( window, info->image );
- info = TheDefaultScheme->getImageAndColor( VSLIDER_DISABLED_TOP );
- GadgetSliderSetDisabledImageLeft( window, info->image );
- GadgetSliderSetDisabledColor( window, info->color );
- GadgetSliderSetDisabledBorderColor( window, info->borderColor );
- info = TheDefaultScheme->getImageAndColor( VSLIDER_DISABLED_BOTTOM );
- GadgetSliderSetDisabledImageRight( window, info->image );
- info = TheDefaultScheme->getImageAndColor( VSLIDER_DISABLED_CENTER );
- GadgetSliderSetDisabledImageCenter( window, info->image );
- info = TheDefaultScheme->getImageAndColor( VSLIDER_DISABLED_SMALL_CENTER );
- GadgetSliderSetDisabledImageSmallCenter( window, info->image );
- info = TheDefaultScheme->getImageAndColor( VSLIDER_HILITE_TOP );
- GadgetSliderSetHiliteImageLeft( window, info->image );
- GadgetSliderSetHiliteColor( window, info->color );
- GadgetSliderSetHiliteBorderColor( window, info->borderColor );
- info = TheDefaultScheme->getImageAndColor( VSLIDER_HILITE_BOTTOM );
- GadgetSliderSetHiliteImageRight( window, info->image );
- info = TheDefaultScheme->getImageAndColor( VSLIDER_HILITE_CENTER );
- GadgetSliderSetHiliteImageCenter( window, info->image );
- info = TheDefaultScheme->getImageAndColor( VSLIDER_HILITE_SMALL_CENTER );
- GadgetSliderSetHiliteImageSmallCenter( window, info->image );
- info = TheDefaultScheme->getImageAndColor( VSLIDER_THUMB_ENABLED );
- GadgetSliderSetEnabledThumbImage( window, info->image );
- GadgetSliderSetEnabledThumbColor( window, info->color );
- GadgetSliderSetEnabledThumbBorderColor( window, info->borderColor );
- info = TheDefaultScheme->getImageAndColor( VSLIDER_THUMB_ENABLED_PUSHED );
- GadgetSliderSetEnabledSelectedThumbImage( window, info->image );
- GadgetSliderSetEnabledSelectedThumbColor( window, info->color );
- GadgetSliderSetEnabledSelectedThumbBorderColor( window, info->borderColor );
- info = TheDefaultScheme->getImageAndColor( VSLIDER_THUMB_DISABLED );
- GadgetSliderSetDisabledThumbImage( window, info->image );
- GadgetSliderSetDisabledThumbColor( window, info->color );
- GadgetSliderSetDisabledThumbBorderColor( window, info->borderColor );
- info = TheDefaultScheme->getImageAndColor( VSLIDER_THUMB_DISABLED_PUSHED );
- GadgetSliderSetDisabledSelectedThumbImage( window, info->image );
- GadgetSliderSetDisabledSelectedThumbColor( window, info->color );
- GadgetSliderSetDisabledSelectedThumbBorderColor( window, info->borderColor );
- info = TheDefaultScheme->getImageAndColor( VSLIDER_THUMB_HILITE );
- GadgetSliderSetHiliteThumbImage( window, info->image );
- GadgetSliderSetHiliteThumbColor( window, info->color );
- GadgetSliderSetHiliteThumbBorderColor( window, info->borderColor );
- info = TheDefaultScheme->getImageAndColor( VSLIDER_THUMB_HILITE_PUSHED );
- GadgetSliderSetHiliteSelectedThumbImage( window, info->image );
- GadgetSliderSetHiliteSelectedThumbColor( window, info->color );
- GadgetSliderSetHiliteSelectedThumbBorderColor( window, info->borderColor );
- // set default font
- window->winSetFont( TheDefaultScheme->getFont() );
- } // end if
- // contents have changed
- setUnsaved( TRUE );
- // notify the editor of the new window
- notifyNewWindow( window );
- return window;
- } // end newVerticalSlider
- // GUIEdit::newProgressBar ====================================================
- /** Create a new progress bar */
- //=============================================================================
- GameWindow *GUIEdit::newProgressBar( GameWindow *parent,
- Int x, Int y,
- Int width, Int height )
- {
- GameWindow *window;
- WinInstanceData instData;
- UnsignedInt status = WIN_STATUS_ENABLED | WIN_STATUS_IMAGE;
- // validate the parent to disallow illegal relationships
- if( validateParentForCreate( parent ) == FALSE )
- return NULL;
- // keep inside a parent if present
- if( parent )
- clipCreationParamsToParent( parent, &x, &y, &width, &height );
- // initialize inst data
- instData.init();
- instData.m_style = GWS_PROGRESS_BAR | GWS_MOUSE_TRACK;
- // make control
- window = TheWindowManager->gogoGadgetProgressBar( parent,
- status,
- x, y,
- width, height,
- &instData,
- NULL,
- TRUE );
- // set default colors based on the default scheme
- if( window )
- {
- ImageAndColorInfo *info;
- //-------------------------------------------------------------------------
- info = TheDefaultScheme->getImageAndColor( PROGRESS_BAR_ENABLED_LEFT );
- GadgetProgressBarSetEnabledImageLeft( window, info->image );
- GadgetProgressBarSetEnabledColor( window, info->color );
- GadgetProgressBarSetEnabledBorderColor( window, info->borderColor );
- info = TheDefaultScheme->getImageAndColor( PROGRESS_BAR_ENABLED_RIGHT );
- GadgetProgressBarSetEnabledImageRight( window, info->image );
- info = TheDefaultScheme->getImageAndColor( PROGRESS_BAR_ENABLED_CENTER );
- GadgetProgressBarSetEnabledImageCenter( window, info->image );
- info = TheDefaultScheme->getImageAndColor( PROGRESS_BAR_ENABLED_SMALL_CENTER );
- GadgetProgressBarSetEnabledImageSmallCenter( window, info->image );
- info = TheDefaultScheme->getImageAndColor( PROGRESS_BAR_ENABLED_BAR_LEFT );
- GadgetProgressBarSetEnabledBarImageLeft( window, info->image );
- GadgetProgressBarSetEnabledBarColor( window, info->color );
- GadgetProgressBarSetEnabledBarBorderColor( window, info->borderColor );
- info = TheDefaultScheme->getImageAndColor( PROGRESS_BAR_ENABLED_BAR_RIGHT );
- GadgetProgressBarSetEnabledBarImageRight( window, info->image );
- info = TheDefaultScheme->getImageAndColor( PROGRESS_BAR_ENABLED_BAR_CENTER );
- GadgetProgressBarSetEnabledBarImageCenter( window, info->image );
- info = TheDefaultScheme->getImageAndColor( PROGRESS_BAR_ENABLED_BAR_SMALL_CENTER );
- GadgetProgressBarSetEnabledBarImageSmallCenter( window, info->image );
- //-------------------------------------------------------------------------
- info = TheDefaultScheme->getImageAndColor( PROGRESS_BAR_DISABLED_LEFT );
- GadgetProgressBarSetDisabledImageLeft( window, info->image );
- GadgetProgressBarSetDisabledColor( window, info->color );
- GadgetProgressBarSetDisabledBorderColor( window, info->borderColor );
- info = TheDefaultScheme->getImageAndColor( PROGRESS_BAR_DISABLED_RIGHT );
- GadgetProgressBarSetDisabledImageRight( window, info->image );
- info = TheDefaultScheme->getImageAndColor( PROGRESS_BAR_DISABLED_CENTER );
- GadgetProgressBarSetDisabledImageCenter( window, info->image );
- info = TheDefaultScheme->getImageAndColor( PROGRESS_BAR_DISABLED_SMALL_CENTER );
- GadgetProgressBarSetDisabledImageSmallCenter( window, info->image );
- info = TheDefaultScheme->getImageAndColor( PROGRESS_BAR_DISABLED_BAR_LEFT );
- GadgetProgressBarSetDisabledBarImageLeft( window, info->image );
- GadgetProgressBarSetDisabledBarColor( window, info->color );
- GadgetProgressBarSetDisabledBarBorderColor( window, info->borderColor );
- info = TheDefaultScheme->getImageAndColor( PROGRESS_BAR_DISABLED_BAR_RIGHT );
- GadgetProgressBarSetDisabledBarImageRight( window, info->image );
- info = TheDefaultScheme->getImageAndColor( PROGRESS_BAR_DISABLED_BAR_CENTER );
- GadgetProgressBarSetDisabledBarImageCenter( window, info->image );
- info = TheDefaultScheme->getImageAndColor( PROGRESS_BAR_DISABLED_BAR_SMALL_CENTER );
- GadgetProgressBarSetDisabledBarImageSmallCenter( window, info->image );
- //-------------------------------------------------------------------------
- info = TheDefaultScheme->getImageAndColor( PROGRESS_BAR_HILITE_LEFT );
- GadgetProgressBarSetHiliteImageLeft( window, info->image );
- GadgetProgressBarSetHiliteColor( window, info->color );
- GadgetProgressBarSetHiliteBorderColor( window, info->borderColor );
- info = TheDefaultScheme->getImageAndColor( PROGRESS_BAR_HILITE_RIGHT );
- GadgetProgressBarSetHiliteImageRight( window, info->image );
- info = TheDefaultScheme->getImageAndColor( PROGRESS_BAR_HILITE_CENTER );
- GadgetProgressBarSetHiliteImageCenter( window, info->image );
- info = TheDefaultScheme->getImageAndColor( PROGRESS_BAR_HILITE_SMALL_CENTER );
- GadgetProgressBarSetHiliteImageSmallCenter( window, info->image );
- info = TheDefaultScheme->getImageAndColor( PROGRESS_BAR_HILITE_BAR_LEFT );
- GadgetProgressBarSetHiliteBarImageLeft( window, info->image );
- GadgetProgressBarSetHiliteBarColor( window, info->color );
- GadgetProgressBarSetHiliteBarBorderColor( window, info->borderColor );
- info = TheDefaultScheme->getImageAndColor( PROGRESS_BAR_HILITE_BAR_RIGHT );
- GadgetProgressBarSetHiliteBarImageRight( window, info->image );
- info = TheDefaultScheme->getImageAndColor( PROGRESS_BAR_HILITE_BAR_CENTER );
- GadgetProgressBarSetHiliteBarImageCenter( window, info->image );
- info = TheDefaultScheme->getImageAndColor( PROGRESS_BAR_HILITE_BAR_SMALL_CENTER );
- GadgetProgressBarSetHiliteBarImageSmallCenter( window, info->image );
- Color color, border;
- color = TheDefaultScheme->getEnabledTextColor();
- border = TheDefaultScheme->getEnabledTextBorderColor();
- window->winSetEnabledTextColors( color, border );
- color = TheDefaultScheme->getDisabledTextColor();
- border = TheDefaultScheme->getDisabledTextBorderColor();
- window->winSetDisabledTextColors( color, border );
- color = TheDefaultScheme->getHiliteTextColor();
- border = TheDefaultScheme->getHiliteTextBorderColor();
- window->winSetHiliteTextColors( color, border );
- // set default font
- window->winSetFont( TheDefaultScheme->getFont() );
- } // end if
- // contents have changed
- setUnsaved( TRUE );
- // notify the editor of the new window
- notifyNewWindow( window );
- return window;
- } // end newProgressBar
- // GUIEdit::newListbox ========================================================
- /** Create a new list box */
- //=============================================================================
- GameWindow *GUIEdit::newComboBox( GameWindow *parent,
- Int x, Int y,
- Int width, Int height )
- {
- GameWindow *window;
- WinInstanceData instData;
- UnsignedInt status = WIN_STATUS_ENABLED | WIN_STATUS_IMAGE;
- // validate the parent to disallow illegal relationships
- if( validateParentForCreate( parent ) == FALSE )
- return NULL;
- // keep inside a parent if present
- if( parent )
- clipCreationParamsToParent( parent, &x, &y, &width, &height );
- // initialize inst data
- instData.init();
- instData.m_style = GWS_COMBO_BOX | GWS_MOUSE_TRACK;
- //initialize combo box data
- ComboBoxData *comboData = new ComboBoxData;
- memset ( comboData, 0, sizeof(comboData));
-
- comboData->entryData = new EntryData;
- memset ( comboData->entryData, 0, sizeof(EntryData));
- comboData->listboxData = new ListboxData;
- memset ( comboData->listboxData, 0, sizeof(ListboxData));
-
- //initialize combo box data
- comboData->isEditable = TRUE;
- comboData->maxChars = 16;
- comboData->maxDisplay = 5;
- comboData->entryCount = 0;
- comboData->dontHide = FALSE;
- comboData->asciiOnly = FALSE;
- comboData->lettersAndNumbersOnly = FALSE;
-
- //initialize entry data
- comboData->entryData->maxTextLen = 16;
- comboData->entryData->alphaNumericalOnly = FALSE;
- comboData->entryData->aSCIIOnly = FALSE;
- comboData->entryData->numericalOnly = FALSE;
-
- //initialize listbox data
- comboData->listboxData->listLength = 10;
- comboData->listboxData->autoScroll = 0;
- comboData->listboxData->scrollIfAtEnd = FALSE;
- comboData->listboxData->autoPurge = 0;
- comboData->listboxData->scrollBar = 1;
- comboData->listboxData->multiSelect = 0;
- comboData->listboxData->forceSelect = 1;
- comboData->listboxData->columns = 1;
- comboData->listboxData->columnWidth = NULL;
- comboData->listboxData->columnWidthPercentage = NULL;
- //create the control
- window = TheWindowManager->gogoGadgetComboBox( parent,
- status,
- x, y,
- width, height,
- &instData,
- comboData,
- NULL,
- TRUE );
- // set default colors based on the default scheme
-
- if( window )
- {
- ImageAndColorInfo *info;
- info = TheDefaultScheme->getImageAndColor( COMBOBOX_ENABLED );
- GadgetComboBoxSetEnabledImage( window, info->image );
- GadgetComboBoxSetEnabledColor( window, info->color );
- GadgetComboBoxSetEnabledBorderColor( window, info->borderColor );
- info = TheDefaultScheme->getImageAndColor( COMBOBOX_ENABLED_SELECTED_ITEM_LEFT );
- GadgetComboBoxSetEnabledSelectedItemImageLeft( window, info->image );
- GadgetComboBoxSetEnabledSelectedItemColor( window, info->color );
- GadgetComboBoxSetEnabledSelectedItemBorderColor( window, info->borderColor );
- info = TheDefaultScheme->getImageAndColor( COMBOBOX_ENABLED_SELECTED_ITEM_RIGHT );
- GadgetComboBoxSetEnabledSelectedItemImageRight( window, info->image );
- info = TheDefaultScheme->getImageAndColor( COMBOBOX_ENABLED_SELECTED_ITEM_CENTER );
- GadgetComboBoxSetEnabledSelectedItemImageCenter( window, info->image );
- info = TheDefaultScheme->getImageAndColor( COMBOBOX_ENABLED_SELECTED_ITEM_SMALL_CENTER );
- GadgetComboBoxSetEnabledSelectedItemImageSmallCenter( window, info->image );
- info = TheDefaultScheme->getImageAndColor( COMBOBOX_DISABLED );
- GadgetComboBoxSetDisabledImage( window, info->image );
- GadgetComboBoxSetDisabledColor( window, info->color );
- GadgetComboBoxSetDisabledBorderColor( window, info->borderColor );
- info = TheDefaultScheme->getImageAndColor( COMBOBOX_DISABLED_SELECTED_ITEM_LEFT );
- GadgetComboBoxSetDisabledSelectedItemImageLeft( window, info->image );
- GadgetComboBoxSetDisabledSelectedItemColor( window, info->color );
- GadgetComboBoxSetDisabledSelectedItemBorderColor( window, info->borderColor );
- info = TheDefaultScheme->getImageAndColor( COMBOBOX_DISABLED_SELECTED_ITEM_RIGHT );
- GadgetComboBoxSetDisabledSelectedItemImageRight( window, info->image );
- info = TheDefaultScheme->getImageAndColor( COMBOBOX_DISABLED_SELECTED_ITEM_CENTER );
- GadgetComboBoxSetDisabledSelectedItemImageCenter( window, info->image );
- info = TheDefaultScheme->getImageAndColor( COMBOBOX_DISABLED_SELECTED_ITEM_SMALL_CENTER );
- GadgetComboBoxSetDisabledSelectedItemImageSmallCenter( window, info->image );
- info = TheDefaultScheme->getImageAndColor( COMBOBOX_HILITE );
- GadgetComboBoxSetHiliteImage( window, info->image );
- GadgetComboBoxSetHiliteColor( window, info->color );
- GadgetComboBoxSetHiliteBorderColor( window, info->borderColor );
- info = TheDefaultScheme->getImageAndColor( COMBOBOX_HILITE_SELECTED_ITEM_LEFT );
- GadgetComboBoxSetHiliteSelectedItemImageLeft( window, info->image );
- GadgetComboBoxSetHiliteSelectedItemColor( window, info->color );
- GadgetComboBoxSetHiliteSelectedItemBorderColor( window, info->borderColor );
- info = TheDefaultScheme->getImageAndColor( COMBOBOX_HILITE_SELECTED_ITEM_RIGHT );
- GadgetComboBoxSetHiliteSelectedItemImageRight( window, info->image );
- info = TheDefaultScheme->getImageAndColor( COMBOBOX_HILITE_SELECTED_ITEM_CENTER );
- GadgetComboBoxSetHiliteSelectedItemImageCenter( window, info->image );
- info = TheDefaultScheme->getImageAndColor( COMBOBOX_HILITE_SELECTED_ITEM_SMALL_CENTER );
- GadgetComboBoxSetHiliteSelectedItemImageSmallCenter( window, info->image );
- GameWindow *editBox = GadgetComboBoxGetEditBox( window );
- if(editBox)
- {
- info = TheDefaultScheme->getImageAndColor( COMBOBOX_EDIT_BOX_ENABLED_LEFT );
- GadgetTextEntrySetEnabledImageLeft( editBox, info->image );
- GadgetTextEntrySetEnabledColor( editBox, info->color );
- GadgetTextEntrySetEnabledBorderColor( editBox, info->borderColor );
- info = TheDefaultScheme->getImageAndColor( COMBOBOX_EDIT_BOX_ENABLED_RIGHT );
- GadgetTextEntrySetEnabledImageRight( editBox, info->image );
- info = TheDefaultScheme->getImageAndColor( COMBOBOX_EDIT_BOX_ENABLED_CENTER );
- GadgetTextEntrySetEnabledImageCenter( editBox, info->image );
- info = TheDefaultScheme->getImageAndColor( COMBOBOX_EDIT_BOX_ENABLED_SMALL_CENTER );
- GadgetTextEntrySetEnabledImageSmallCenter( editBox, info->image );
- info = TheDefaultScheme->getImageAndColor( COMBOBOX_EDIT_BOX_DISABLED_LEFT );
- GadgetTextEntrySetDisabledImageLeft( editBox, info->image );
- GadgetTextEntrySetDisabledColor( editBox, info->color );
- GadgetTextEntrySetDisabledBorderColor( editBox, info->borderColor );
- info = TheDefaultScheme->getImageAndColor( COMBOBOX_EDIT_BOX_DISABLED_RIGHT );
- GadgetTextEntrySetDisabledImageRight( editBox, info->image );
- info = TheDefaultScheme->getImageAndColor( COMBOBOX_EDIT_BOX_DISABLED_CENTER );
- GadgetTextEntrySetDisabledImageCenter( editBox, info->image );
- info = TheDefaultScheme->getImageAndColor( COMBOBOX_EDIT_BOX_DISABLED_SMALL_CENTER );
- GadgetTextEntrySetDisabledImageSmallCenter( editBox, info->image );
- info = TheDefaultScheme->getImageAndColor( COMBOBOX_EDIT_BOX_HILITE_LEFT );
- GadgetTextEntrySetHiliteImageLeft( editBox, info->image );
- GadgetTextEntrySetHiliteColor( window, info->color );
- GadgetTextEntrySetHiliteBorderColor( editBox, info->borderColor );
- info = TheDefaultScheme->getImageAndColor( COMBOBOX_EDIT_BOX_HILITE_RIGHT );
- GadgetTextEntrySetHiliteImageRight( editBox, info->image );
- info = TheDefaultScheme->getImageAndColor( COMBOBOX_EDIT_BOX_HILITE_CENTER );
- GadgetTextEntrySetHiliteImageCenter( editBox, info->image );
- info = TheDefaultScheme->getImageAndColor( COMBOBOX_EDIT_BOX_HILITE_SMALL_CENTER );
- GadgetTextEntrySetHiliteImageSmallCenter( editBox, info->image );
- }
- GameWindow *listBox = GadgetComboBoxGetListBox( window );
- if(listBox)
- {
- info = TheDefaultScheme->getImageAndColor( COMBOBOX_LISTBOX_ENABLED );
- GadgetListBoxSetEnabledImage( listBox, info->image );
- GadgetListBoxSetEnabledColor( listBox, info->color );
- GadgetListBoxSetEnabledBorderColor( listBox, info->borderColor );
- info = TheDefaultScheme->getImageAndColor( COMBOBOX_LISTBOX_ENABLED_SELECTED_ITEM_LEFT );
- GadgetListBoxSetEnabledSelectedItemImageLeft( listBox, info->image );
- GadgetListBoxSetEnabledSelectedItemColor( listBox, info->color );
- GadgetListBoxSetEnabledSelectedItemBorderColor( listBox, info->borderColor );
- info = TheDefaultScheme->getImageAndColor( COMBOBOX_LISTBOX_ENABLED_SELECTED_ITEM_RIGHT );
- GadgetListBoxSetEnabledSelectedItemImageRight( listBox, info->image );
- info = TheDefaultScheme->getImageAndColor( COMBOBOX_LISTBOX_ENABLED_SELECTED_ITEM_CENTER );
- GadgetListBoxSetEnabledSelectedItemImageCenter( listBox, info->image );
- info = TheDefaultScheme->getImageAndColor( COMBOBOX_LISTBOX_ENABLED_SELECTED_ITEM_SMALL_CENTER );
- GadgetListBoxSetEnabledSelectedItemImageSmallCenter( listBox, info->image );
- info = TheDefaultScheme->getImageAndColor( COMBOBOX_LISTBOX_DISABLED );
- GadgetListBoxSetDisabledImage( listBox, info->image );
- GadgetListBoxSetDisabledColor( listBox, info->color );
- GadgetListBoxSetDisabledBorderColor( listBox, info->borderColor );
- info = TheDefaultScheme->getImageAndColor( COMBOBOX_LISTBOX_DISABLED_SELECTED_ITEM_LEFT );
- GadgetListBoxSetDisabledSelectedItemImageLeft( listBox, info->image );
- GadgetListBoxSetDisabledSelectedItemColor( listBox, info->color );
- GadgetListBoxSetDisabledSelectedItemBorderColor( listBox, info->borderColor );
- info = TheDefaultScheme->getImageAndColor( COMBOBOX_LISTBOX_DISABLED_SELECTED_ITEM_RIGHT );
- GadgetListBoxSetDisabledSelectedItemImageRight( listBox, info->image );
- info = TheDefaultScheme->getImageAndColor( COMBOBOX_LISTBOX_DISABLED_SELECTED_ITEM_CENTER );
- GadgetListBoxSetDisabledSelectedItemImageCenter( listBox, info->image );
- info = TheDefaultScheme->getImageAndColor( COMBOBOX_LISTBOX_DISABLED_SELECTED_ITEM_SMALL_CENTER );
- GadgetListBoxSetDisabledSelectedItemImageSmallCenter( listBox, info->image );
- info = TheDefaultScheme->getImageAndColor( COMBOBOX_LISTBOX_HILITE );
- GadgetListBoxSetHiliteImage( listBox, info->image );
- GadgetListBoxSetHiliteColor( listBox, info->color );
- GadgetListBoxSetHiliteBorderColor( listBox, info->borderColor );
- info = TheDefaultScheme->getImageAndColor( COMBOBOX_LISTBOX_HILITE_SELECTED_ITEM_LEFT );
- GadgetListBoxSetHiliteSelectedItemImageLeft( listBox, info->image );
- GadgetListBoxSetHiliteSelectedItemColor( listBox, info->color );
- GadgetListBoxSetHiliteSelectedItemBorderColor( listBox, info->borderColor );
- info = TheDefaultScheme->getImageAndColor( COMBOBOX_LISTBOX_HILITE_SELECTED_ITEM_RIGHT );
- GadgetListBoxSetHiliteSelectedItemImageRight( listBox, info->image );
- info = TheDefaultScheme->getImageAndColor( COMBOBOX_LISTBOX_HILITE_SELECTED_ITEM_CENTER );
- GadgetListBoxSetHiliteSelectedItemImageCenter( listBox, info->image );
- info = TheDefaultScheme->getImageAndColor( COMBOBOX_LISTBOX_HILITE_SELECTED_ITEM_SMALL_CENTER );
- GadgetListBoxSetHiliteSelectedItemImageSmallCenter( listBox, info->image );
- GameWindow *upButton = GadgetListBoxGetUpButton( listBox );
- if( upButton )
- {
- info = TheDefaultScheme->getImageAndColor( COMBOBOX_LISTBOX_UP_BUTTON_ENABLED );
- GadgetButtonSetEnabledImage( upButton, info->image );
- GadgetButtonSetEnabledColor( upButton, info->color );
- GadgetButtonSetEnabledBorderColor( upButton, info->borderColor );
- info = TheDefaultScheme->getImageAndColor( COMBOBOX_LISTBOX_UP_BUTTON_ENABLED_PUSHED );
- GadgetButtonSetEnabledSelectedImage( upButton, info->image );
- GadgetButtonSetEnabledSelectedColor( upButton, info->color );
- GadgetButtonSetEnabledSelectedBorderColor( upButton, info->borderColor );
- info = TheDefaultScheme->getImageAndColor( COMBOBOX_LISTBOX_UP_BUTTON_DISABLED );
- GadgetButtonSetDisabledImage( upButton, info->image );
- GadgetButtonSetDisabledColor( upButton, info->color );
- GadgetButtonSetDisabledBorderColor( upButton, info->borderColor );
- info = TheDefaultScheme->getImageAndColor( COMBOBOX_LISTBOX_UP_BUTTON_DISABLED_PUSHED );
- GadgetButtonSetDisabledSelectedImage( upButton, info->image );
- GadgetButtonSetDisabledSelectedColor( upButton, info->color );
- GadgetButtonSetDisabledSelectedBorderColor( upButton, info->borderColor );
- info = TheDefaultScheme->getImageAndColor( COMBOBOX_LISTBOX_UP_BUTTON_HILITE );
- GadgetButtonSetHiliteImage( upButton, info->image );
- GadgetButtonSetHiliteColor( upButton, info->color );
- GadgetButtonSetHiliteBorderColor( upButton, info->borderColor );
- info = TheDefaultScheme->getImageAndColor( COMBOBOX_LISTBOX_UP_BUTTON_HILITE_PUSHED );
- GadgetButtonSetHiliteSelectedImage( upButton, info->image );
- GadgetButtonSetHiliteSelectedColor( upButton, info->color );
- GadgetButtonSetHiliteSelectedBorderColor( upButton, info->borderColor );
- } // end if
- GameWindow *downButton = GadgetListBoxGetDownButton( listBox );
- if( downButton )
- {
- info = TheDefaultScheme->getImageAndColor( COMBOBOX_LISTBOX_DOWN_BUTTON_ENABLED );
- GadgetButtonSetEnabledImage( downButton, info->image );
- GadgetButtonSetEnabledColor( downButton, info->color );
- GadgetButtonSetEnabledBorderColor( downButton, info->borderColor );
- info = TheDefaultScheme->getImageAndColor( COMBOBOX_LISTBOX_DOWN_BUTTON_ENABLED_PUSHED );
- GadgetButtonSetEnabledSelectedImage( downButton, info->image );
- GadgetButtonSetEnabledSelectedColor( downButton, info->color );
- GadgetButtonSetEnabledSelectedBorderColor( downButton, info->borderColor );
- info = TheDefaultScheme->getImageAndColor( COMBOBOX_LISTBOX_DOWN_BUTTON_DISABLED );
- GadgetButtonSetDisabledImage( downButton, info->image );
- GadgetButtonSetDisabledColor( downButton, info->color );
- GadgetButtonSetDisabledBorderColor( downButton, info->borderColor );
- info = TheDefaultScheme->getImageAndColor( COMBOBOX_LISTBOX_DOWN_BUTTON_DISABLED_PUSHED );
- GadgetButtonSetDisabledSelectedImage( downButton, info->image );
- GadgetButtonSetDisabledSelectedColor( downButton, info->color );
- GadgetButtonSetDisabledSelectedBorderColor( downButton, info->borderColor );
- info = TheDefaultScheme->getImageAndColor( COMBOBOX_LISTBOX_DOWN_BUTTON_HILITE );
- GadgetButtonSetHiliteImage( downButton, info->image );
- GadgetButtonSetHiliteColor( downButton, info->color );
- GadgetButtonSetHiliteBorderColor( downButton, info->borderColor );
- info = TheDefaultScheme->getImageAndColor( COMBOBOX_LISTBOX_DOWN_BUTTON_HILITE_PUSHED );
- GadgetButtonSetHiliteSelectedImage( downButton, info->image );
- GadgetButtonSetHiliteSelectedColor( downButton, info->color );
- GadgetButtonSetHiliteSelectedBorderColor( downButton, info->borderColor );
- } // end if
- GameWindow *slider = GadgetListBoxGetSlider( listBox );
- if( slider )
- {
- // ----------------------------------------------------------------------
- info = TheDefaultScheme->getImageAndColor( COMBOBOX_LISTBOX_SLIDER_ENABLED_TOP );
- GadgetSliderSetEnabledImageTop( slider, info->image );
- GadgetSliderSetEnabledColor( slider, info->color );
- GadgetSliderSetEnabledBorderColor( slider, info->borderColor );
- info = TheDefaultScheme->getImageAndColor( COMBOBOX_LISTBOX_SLIDER_ENABLED_BOTTOM );
- GadgetSliderSetEnabledImageBottom( slider, info->image );
- info = TheDefaultScheme->getImageAndColor( COMBOBOX_LISTBOX_SLIDER_ENABLED_CENTER );
- GadgetSliderSetEnabledImageCenter( slider, info->image );
- info = TheDefaultScheme->getImageAndColor( COMBOBOX_LISTBOX_SLIDER_ENABLED_SMALL_CENTER );
- GadgetSliderSetEnabledImageSmallCenter( slider, info->image );
- // ----------------------------------------------------------------------
- info = TheDefaultScheme->getImageAndColor( COMBOBOX_LISTBOX_SLIDER_DISABLED_TOP );
- GadgetSliderSetDisabledImageTop( slider, info->image );
- GadgetSliderSetDisabledColor( slider, info->color );
- GadgetSliderSetDisabledBorderColor( slider, info->borderColor );
- info = TheDefaultScheme->getImageAndColor( COMBOBOX_LISTBOX_SLIDER_DISABLED_BOTTOM );
- GadgetSliderSetDisabledImageBottom( slider, info->image );
- info = TheDefaultScheme->getImageAndColor( COMBOBOX_LISTBOX_SLIDER_DISABLED_CENTER );
- GadgetSliderSetDisabledImageCenter( slider, info->image );
- info = TheDefaultScheme->getImageAndColor( COMBOBOX_LISTBOX_SLIDER_DISABLED_SMALL_CENTER );
- GadgetSliderSetDisabledImageSmallCenter( slider, info->image );
- // ----------------------------------------------------------------------
- info = TheDefaultScheme->getImageAndColor( COMBOBOX_LISTBOX_SLIDER_HILITE_TOP );
- GadgetSliderSetHiliteImageTop( slider, info->image );
- GadgetSliderSetHiliteColor( slider, info->color );
- GadgetSliderSetHiliteBorderColor( slider, info->borderColor );
- info = TheDefaultScheme->getImageAndColor( COMBOBOX_LISTBOX_SLIDER_HILITE_BOTTOM );
- GadgetSliderSetHiliteImageBottom( slider, info->image );
- info = TheDefaultScheme->getImageAndColor( COMBOBOX_LISTBOX_SLIDER_HILITE_CENTER );
- GadgetSliderSetHiliteImageCenter( slider, info->image );
- info = TheDefaultScheme->getImageAndColor( COMBOBOX_LISTBOX_SLIDER_HILITE_SMALL_CENTER );
- GadgetSliderSetHiliteImageSmallCenter( slider, info->image );
- //-----------------------------------------------------------------------
- info = TheDefaultScheme->getImageAndColor( COMBOBOX_LISTBOX_SLIDER_THUMB_ENABLED );
- GadgetSliderSetEnabledThumbImage( slider, info->image );
- GadgetSliderSetEnabledThumbColor( slider, info->color );
- GadgetSliderSetEnabledThumbBorderColor( slider, info->borderColor );
- info = TheDefaultScheme->getImageAndColor( COMBOBOX_LISTBOX_SLIDER_THUMB_ENABLED_PUSHED );
- GadgetSliderSetEnabledSelectedThumbImage( slider, info->image );
- GadgetSliderSetEnabledSelectedThumbColor( slider, info->color );
- GadgetSliderSetEnabledSelectedThumbBorderColor( slider, info->borderColor );
- info = TheDefaultScheme->getImageAndColor( COMBOBOX_LISTBOX_SLIDER_THUMB_DISABLED );
- GadgetSliderSetDisabledThumbImage( slider, info->image );
- GadgetSliderSetDisabledThumbColor( slider, info->color );
- GadgetSliderSetDisabledThumbBorderColor( slider, info->borderColor );
- info = TheDefaultScheme->getImageAndColor( COMBOBOX_LISTBOX_SLIDER_THUMB_DISABLED_PUSHED );
- GadgetSliderSetDisabledSelectedThumbImage( slider, info->image );
- GadgetSliderSetDisabledSelectedThumbColor( slider, info->color );
- GadgetSliderSetDisabledSelectedThumbBorderColor( slider, info->borderColor );
- info = TheDefaultScheme->getImageAndColor( COMBOBOX_LISTBOX_SLIDER_THUMB_HILITE );
- GadgetSliderSetHiliteThumbImage( slider, info->image );
- GadgetSliderSetHiliteThumbColor( slider, info->color );
- GadgetSliderSetHiliteThumbBorderColor( slider, info->borderColor );
- info = TheDefaultScheme->getImageAndColor( COMBOBOX_LISTBOX_SLIDER_THUMB_HILITE_PUSHED );
- GadgetSliderSetHiliteSelectedThumbImage( slider, info->image );
- GadgetSliderSetHiliteSelectedThumbColor( slider, info->color );
- GadgetSliderSetHiliteSelectedThumbBorderColor( slider, info->borderColor );
- }
- } //end listbox if
- GameWindow *dropDownButton = GadgetComboBoxGetDropDownButton( window );
- if( dropDownButton )
- {
- info = TheDefaultScheme->getImageAndColor( COMBOBOX_DROP_DOWN_BUTTON_ENABLED );
- GadgetButtonSetEnabledImage( dropDownButton, info->image );
- GadgetButtonSetEnabledColor( dropDownButton, info->color );
- GadgetButtonSetEnabledBorderColor( dropDownButton, info->borderColor );
- info = TheDefaultScheme->getImageAndColor( COMBOBOX_DROP_DOWN_BUTTON_ENABLED_PUSHED );
- GadgetButtonSetEnabledSelectedImage( dropDownButton, info->image );
- GadgetButtonSetEnabledSelectedColor( dropDownButton, info->color );
- GadgetButtonSetEnabledSelectedBorderColor( dropDownButton, info->borderColor );
- info = TheDefaultScheme->getImageAndColor( COMBOBOX_DROP_DOWN_BUTTON_DISABLED );
- GadgetButtonSetDisabledImage( dropDownButton, info->image );
- GadgetButtonSetDisabledColor( dropDownButton, info->color );
- GadgetButtonSetDisabledBorderColor( dropDownButton, info->borderColor );
- info = TheDefaultScheme->getImageAndColor( COMBOBOX_DROP_DOWN_BUTTON_DISABLED_PUSHED );
- GadgetButtonSetDisabledSelectedImage( dropDownButton, info->image );
- GadgetButtonSetDisabledSelectedColor( dropDownButton, info->color );
- GadgetButtonSetDisabledSelectedBorderColor( dropDownButton, info->borderColor );
- info = TheDefaultScheme->getImageAndColor( COMBOBOX_DROP_DOWN_BUTTON_HILITE );
- GadgetButtonSetHiliteImage( dropDownButton, info->image );
- GadgetButtonSetHiliteColor( dropDownButton, info->color );
- GadgetButtonSetHiliteBorderColor( dropDownButton, info->borderColor );
- info = TheDefaultScheme->getImageAndColor( COMBOBOX_DROP_DOWN_BUTTON_HILITE_PUSHED );
- GadgetButtonSetHiliteSelectedImage( dropDownButton, info->image );
- GadgetButtonSetHiliteSelectedColor( dropDownButton, info->color );
- GadgetButtonSetHiliteSelectedBorderColor( dropDownButton, info->borderColor );
- } // end if
- Color color, border;
- color = TheDefaultScheme->getEnabledTextColor();
- border = TheDefaultScheme->getEnabledTextBorderColor();
- window->winSetEnabledTextColors( color, border );
- color = TheDefaultScheme->getDisabledTextColor();
- border = TheDefaultScheme->getDisabledTextBorderColor();
- window->winSetDisabledTextColors( color, border );
- color = TheDefaultScheme->getHiliteTextColor();
- border = TheDefaultScheme->getHiliteTextBorderColor();
- window->winSetHiliteTextColors( color, border );
-
- /// @TODO: We still need to set the IME Composite Text colors in TheDefaultScheme
- window->winSetIMECompositeTextColors( color, border );
- // set default font
- window->winSetFont( TheDefaultScheme->getFont() );
-
- }// end if
-
- // contents have changed
- setUnsaved( TRUE );
- // notify the editor of the new window
- notifyNewWindow( window );
- return window;
- } // end newComboBox
- // GUIEdit::newListbox ========================================================
- /** Create a new list box */
- //=============================================================================
- GameWindow *GUIEdit::newListbox( GameWindow *parent,
- Int x, Int y,
- Int width, Int height )
- {
- GameWindow *window;
- WinInstanceData instData;
- UnsignedInt status = WIN_STATUS_ENABLED | WIN_STATUS_IMAGE;
- // validate the parent to disallow illegal relationships
- if( validateParentForCreate( parent ) == FALSE )
- return NULL;
- // keep inside a parent if present
- if( parent )
- clipCreationParamsToParent( parent, &x, &y, &width, &height );
- // initialize inst data
- instData.init();
- instData.m_style = GWS_SCROLL_LISTBOX | GWS_MOUSE_TRACK;
- // initialize listbox data
- ListboxData listData;
- memset( &listData, 0, sizeof( listData ) );
- listData.listLength = 10;
- listData.autoScroll = 0;
- listData.scrollIfAtEnd = FALSE;
- listData.autoPurge = 0;
- listData.scrollBar = 1;
- listData.multiSelect = 0;
- listData.forceSelect = 0;
- listData.columns = 1;
- listData.columnWidth = NULL;
- listData.columnWidthPercentage = NULL;
- // make control
- window = TheWindowManager->gogoGadgetListBox( parent,
- status,
- x, y,
- width, height,
- &instData,
- &listData,
- NULL,
- TRUE );
- // set default colors based on the default scheme
- if( window )
- {
- ImageAndColorInfo *info;
- info = TheDefaultScheme->getImageAndColor( LISTBOX_ENABLED );
- GadgetListBoxSetEnabledImage( window, info->image );
- GadgetListBoxSetEnabledColor( window, info->color );
- GadgetListBoxSetEnabledBorderColor( window, info->borderColor );
- info = TheDefaultScheme->getImageAndColor( LISTBOX_ENABLED_SELECTED_ITEM_LEFT );
- GadgetListBoxSetEnabledSelectedItemImageLeft( window, info->image );
- GadgetListBoxSetEnabledSelectedItemColor( window, info->color );
- GadgetListBoxSetEnabledSelectedItemBorderColor( window, info->borderColor );
- info = TheDefaultScheme->getImageAndColor( LISTBOX_ENABLED_SELECTED_ITEM_RIGHT );
- GadgetListBoxSetEnabledSelectedItemImageRight( window, info->image );
- info = TheDefaultScheme->getImageAndColor( LISTBOX_ENABLED_SELECTED_ITEM_CENTER );
- GadgetListBoxSetEnabledSelectedItemImageCenter( window, info->image );
- info = TheDefaultScheme->getImageAndColor( LISTBOX_ENABLED_SELECTED_ITEM_SMALL_CENTER );
- GadgetListBoxSetEnabledSelectedItemImageSmallCenter( window, info->image );
- info = TheDefaultScheme->getImageAndColor( LISTBOX_DISABLED );
- GadgetListBoxSetDisabledImage( window, info->image );
- GadgetListBoxSetDisabledColor( window, info->color );
- GadgetListBoxSetDisabledBorderColor( window, info->borderColor );
- info = TheDefaultScheme->getImageAndColor( LISTBOX_DISABLED_SELECTED_ITEM_LEFT );
- GadgetListBoxSetDisabledSelectedItemImageLeft( window, info->image );
- GadgetListBoxSetDisabledSelectedItemColor( window, info->color );
- GadgetListBoxSetDisabledSelectedItemBorderColor( window, info->borderColor );
- info = TheDefaultScheme->getImageAndColor( LISTBOX_DISABLED_SELECTED_ITEM_RIGHT );
- GadgetListBoxSetDisabledSelectedItemImageRight( window, info->image );
- info = TheDefaultScheme->getImageAndColor( LISTBOX_DISABLED_SELECTED_ITEM_CENTER );
- GadgetListBoxSetDisabledSelectedItemImageCenter( window, info->image );
- info = TheDefaultScheme->getImageAndColor( LISTBOX_DISABLED_SELECTED_ITEM_SMALL_CENTER );
- GadgetListBoxSetDisabledSelectedItemImageSmallCenter( window, info->image );
- info = TheDefaultScheme->getImageAndColor( LISTBOX_HILITE );
- GadgetListBoxSetHiliteImage( window, info->image );
- GadgetListBoxSetHiliteColor( window, info->color );
- GadgetListBoxSetHiliteBorderColor( window, info->borderColor );
- info = TheDefaultScheme->getImageAndColor( LISTBOX_HILITE_SELECTED_ITEM_LEFT );
- GadgetListBoxSetHiliteSelectedItemImageLeft( window, info->image );
- GadgetListBoxSetHiliteSelectedItemColor( window, info->color );
- GadgetListBoxSetHiliteSelectedItemBorderColor( window, info->borderColor );
- info = TheDefaultScheme->getImageAndColor( LISTBOX_HILITE_SELECTED_ITEM_RIGHT );
- GadgetListBoxSetHiliteSelectedItemImageRight( window, info->image );
- info = TheDefaultScheme->getImageAndColor( LISTBOX_HILITE_SELECTED_ITEM_CENTER );
- GadgetListBoxSetHiliteSelectedItemImageCenter( window, info->image );
- info = TheDefaultScheme->getImageAndColor( LISTBOX_HILITE_SELECTED_ITEM_SMALL_CENTER );
- GadgetListBoxSetHiliteSelectedItemImageSmallCenter( window, info->image );
- GameWindow *upButton = GadgetListBoxGetUpButton( window );
- if( upButton )
- {
- info = TheDefaultScheme->getImageAndColor( LISTBOX_UP_BUTTON_ENABLED );
- GadgetButtonSetEnabledImage( upButton, info->image );
- GadgetButtonSetEnabledColor( upButton, info->color );
- GadgetButtonSetEnabledBorderColor( upButton, info->borderColor );
- info = TheDefaultScheme->getImageAndColor( LISTBOX_UP_BUTTON_ENABLED_PUSHED );
- GadgetButtonSetEnabledSelectedImage( upButton, info->image );
- GadgetButtonSetEnabledSelectedColor( upButton, info->color );
- GadgetButtonSetEnabledSelectedBorderColor( upButton, info->borderColor );
- info = TheDefaultScheme->getImageAndColor( LISTBOX_UP_BUTTON_DISABLED );
- GadgetButtonSetDisabledImage( upButton, info->image );
- GadgetButtonSetDisabledColor( upButton, info->color );
- GadgetButtonSetDisabledBorderColor( upButton, info->borderColor );
- info = TheDefaultScheme->getImageAndColor( LISTBOX_UP_BUTTON_DISABLED_PUSHED );
- GadgetButtonSetDisabledSelectedImage( upButton, info->image );
- GadgetButtonSetDisabledSelectedColor( upButton, info->color );
- GadgetButtonSetDisabledSelectedBorderColor( upButton, info->borderColor );
- info = TheDefaultScheme->getImageAndColor( LISTBOX_UP_BUTTON_HILITE );
- GadgetButtonSetHiliteImage( upButton, info->image );
- GadgetButtonSetHiliteColor( upButton, info->color );
- GadgetButtonSetHiliteBorderColor( upButton, info->borderColor );
- info = TheDefaultScheme->getImageAndColor( LISTBOX_UP_BUTTON_HILITE_PUSHED );
- GadgetButtonSetHiliteSelectedImage( upButton, info->image );
- GadgetButtonSetHiliteSelectedColor( upButton, info->color );
- GadgetButtonSetHiliteSelectedBorderColor( upButton, info->borderColor );
- } // end if
- GameWindow *downButton = GadgetListBoxGetDownButton( window );
- if( downButton )
- {
- info = TheDefaultScheme->getImageAndColor( LISTBOX_DOWN_BUTTON_ENABLED );
- GadgetButtonSetEnabledImage( downButton, info->image );
- GadgetButtonSetEnabledColor( downButton, info->color );
- GadgetButtonSetEnabledBorderColor( downButton, info->borderColor );
- info = TheDefaultScheme->getImageAndColor( LISTBOX_DOWN_BUTTON_ENABLED_PUSHED );
- GadgetButtonSetEnabledSelectedImage( downButton, info->image );
- GadgetButtonSetEnabledSelectedColor( downButton, info->color );
- GadgetButtonSetEnabledSelectedBorderColor( downButton, info->borderColor );
- info = TheDefaultScheme->getImageAndColor( LISTBOX_DOWN_BUTTON_DISABLED );
- GadgetButtonSetDisabledImage( downButton, info->image );
- GadgetButtonSetDisabledColor( downButton, info->color );
- GadgetButtonSetDisabledBorderColor( downButton, info->borderColor );
- info = TheDefaultScheme->getImageAndColor( LISTBOX_DOWN_BUTTON_DISABLED_PUSHED );
- GadgetButtonSetDisabledSelectedImage( downButton, info->image );
- GadgetButtonSetDisabledSelectedColor( downButton, info->color );
- GadgetButtonSetDisabledSelectedBorderColor( downButton, info->borderColor );
- info = TheDefaultScheme->getImageAndColor( LISTBOX_DOWN_BUTTON_HILITE );
- GadgetButtonSetHiliteImage( downButton, info->image );
- GadgetButtonSetHiliteColor( downButton, info->color );
- GadgetButtonSetHiliteBorderColor( downButton, info->borderColor );
- info = TheDefaultScheme->getImageAndColor( LISTBOX_DOWN_BUTTON_HILITE_PUSHED );
- GadgetButtonSetHiliteSelectedImage( downButton, info->image );
- GadgetButtonSetHiliteSelectedColor( downButton, info->color );
- GadgetButtonSetHiliteSelectedBorderColor( downButton, info->borderColor );
- } // end if
- GameWindow *slider = GadgetListBoxGetSlider( window );
- if( slider )
- {
- // ----------------------------------------------------------------------
- info = TheDefaultScheme->getImageAndColor( LISTBOX_SLIDER_ENABLED_TOP );
- GadgetSliderSetEnabledImageTop( slider, info->image );
- GadgetSliderSetEnabledColor( slider, info->color );
- GadgetSliderSetEnabledBorderColor( slider, info->borderColor );
- info = TheDefaultScheme->getImageAndColor( LISTBOX_SLIDER_ENABLED_BOTTOM );
- GadgetSliderSetEnabledImageBottom( slider, info->image );
- info = TheDefaultScheme->getImageAndColor( LISTBOX_SLIDER_ENABLED_CENTER );
- GadgetSliderSetEnabledImageCenter( slider, info->image );
- info = TheDefaultScheme->getImageAndColor( LISTBOX_SLIDER_ENABLED_SMALL_CENTER );
- GadgetSliderSetEnabledImageSmallCenter( slider, info->image );
- // ----------------------------------------------------------------------
- info = TheDefaultScheme->getImageAndColor( LISTBOX_SLIDER_DISABLED_TOP );
- GadgetSliderSetDisabledImageTop( slider, info->image );
- GadgetSliderSetDisabledColor( slider, info->color );
- GadgetSliderSetDisabledBorderColor( slider, info->borderColor );
- info = TheDefaultScheme->getImageAndColor( LISTBOX_SLIDER_DISABLED_BOTTOM );
- GadgetSliderSetDisabledImageBottom( slider, info->image );
- info = TheDefaultScheme->getImageAndColor( LISTBOX_SLIDER_DISABLED_CENTER );
- GadgetSliderSetDisabledImageCenter( slider, info->image );
- info = TheDefaultScheme->getImageAndColor( LISTBOX_SLIDER_DISABLED_SMALL_CENTER );
- GadgetSliderSetDisabledImageSmallCenter( slider, info->image );
- // ----------------------------------------------------------------------
- info = TheDefaultScheme->getImageAndColor( LISTBOX_SLIDER_HILITE_TOP );
- GadgetSliderSetHiliteImageTop( slider, info->image );
- GadgetSliderSetHiliteColor( slider, info->color );
- GadgetSliderSetHiliteBorderColor( slider, info->borderColor );
- info = TheDefaultScheme->getImageAndColor( LISTBOX_SLIDER_HILITE_BOTTOM );
- GadgetSliderSetHiliteImageBottom( slider, info->image );
- info = TheDefaultScheme->getImageAndColor( LISTBOX_SLIDER_HILITE_CENTER );
- GadgetSliderSetHiliteImageCenter( slider, info->image );
- info = TheDefaultScheme->getImageAndColor( LISTBOX_SLIDER_HILITE_SMALL_CENTER );
- GadgetSliderSetHiliteImageSmallCenter( slider, info->image );
- //-----------------------------------------------------------------------
- info = TheDefaultScheme->getImageAndColor( LISTBOX_SLIDER_THUMB_ENABLED );
- GadgetSliderSetEnabledThumbImage( slider, info->image );
- GadgetSliderSetEnabledThumbColor( slider, info->color );
- GadgetSliderSetEnabledThumbBorderColor( slider, info->borderColor );
- info = TheDefaultScheme->getImageAndColor( LISTBOX_SLIDER_THUMB_ENABLED_PUSHED );
- GadgetSliderSetEnabledSelectedThumbImage( slider, info->image );
- GadgetSliderSetEnabledSelectedThumbColor( slider, info->color );
- GadgetSliderSetEnabledSelectedThumbBorderColor( slider, info->borderColor );
- info = TheDefaultScheme->getImageAndColor( LISTBOX_SLIDER_THUMB_DISABLED );
- GadgetSliderSetDisabledThumbImage( slider, info->image );
- GadgetSliderSetDisabledThumbColor( slider, info->color );
- GadgetSliderSetDisabledThumbBorderColor( slider, info->borderColor );
- info = TheDefaultScheme->getImageAndColor( LISTBOX_SLIDER_THUMB_DISABLED_PUSHED );
- GadgetSliderSetDisabledSelectedThumbImage( slider, info->image );
- GadgetSliderSetDisabledSelectedThumbColor( slider, info->color );
- GadgetSliderSetDisabledSelectedThumbBorderColor( slider, info->borderColor );
- info = TheDefaultScheme->getImageAndColor( LISTBOX_SLIDER_THUMB_HILITE );
- GadgetSliderSetHiliteThumbImage( slider, info->image );
- GadgetSliderSetHiliteThumbColor( slider, info->color );
- GadgetSliderSetHiliteThumbBorderColor( slider, info->borderColor );
- info = TheDefaultScheme->getImageAndColor( LISTBOX_SLIDER_THUMB_HILITE_PUSHED );
- GadgetSliderSetHiliteSelectedThumbImage( slider, info->image );
- GadgetSliderSetHiliteSelectedThumbColor( slider, info->color );
- GadgetSliderSetHiliteSelectedThumbBorderColor( slider, info->borderColor );
- } // end if, slider
- Color color, border;
- color = TheDefaultScheme->getEnabledTextColor();
- border = TheDefaultScheme->getEnabledTextBorderColor();
- window->winSetEnabledTextColors( color, border );
- color = TheDefaultScheme->getDisabledTextColor();
- border = TheDefaultScheme->getDisabledTextBorderColor();
- window->winSetDisabledTextColors( color, border );
- color = TheDefaultScheme->getHiliteTextColor();
- border = TheDefaultScheme->getHiliteTextBorderColor();
- window->winSetHiliteTextColors( color, border );
- // set default font
- window->winSetFont( TheDefaultScheme->getFont() );
- } // end if
- // contents have changed
- setUnsaved( TRUE );
- // notify the editor of the new window
- notifyNewWindow( window );
- return window;
- } // end newListbox
- // GUIEdit::newTextEntry ======================================================
- /** Create a new text entry */
- //=============================================================================
- GameWindow *GUIEdit::newTextEntry( GameWindow *parent,
- Int x, Int y,
- Int width, Int height )
- {
- GameWindow *window;
- WinInstanceData instData;
- UnsignedInt status = WIN_STATUS_ENABLED | WIN_STATUS_IMAGE;
- // validate the parent to disallow illegal relationships
- if( validateParentForCreate( parent ) == FALSE )
- return NULL;
- // keep inside a parent if present
- if( parent )
- clipCreationParamsToParent( parent, &x, &y, &width, &height );
- // initialize inst data
- instData.init();
- instData.m_style = GWS_ENTRY_FIELD | GWS_MOUSE_TRACK;
- instData.m_textLabelString = "Entry";
- // initialize listbox data
- EntryData entryData;
- memset( &entryData, 0, sizeof( entryData ) );
- entryData.maxTextLen = 64;
- // make control
- window = TheWindowManager->gogoGadgetTextEntry( parent,
- status,
- x, y,
- width, height,
- &instData,
- &entryData,
- NULL,
- TRUE );
- // set default colors based on the default scheme
- if( window )
- {
- ImageAndColorInfo *info;
- info = TheDefaultScheme->getImageAndColor( TEXT_ENTRY_ENABLED_LEFT );
- GadgetTextEntrySetEnabledImageLeft( window, info->image );
- GadgetTextEntrySetEnabledColor( window, info->color );
- GadgetTextEntrySetEnabledBorderColor( window, info->borderColor );
- info = TheDefaultScheme->getImageAndColor( TEXT_ENTRY_ENABLED_RIGHT );
- GadgetTextEntrySetEnabledImageRight( window, info->image );
- info = TheDefaultScheme->getImageAndColor( TEXT_ENTRY_ENABLED_CENTER );
- GadgetTextEntrySetEnabledImageCenter( window, info->image );
- info = TheDefaultScheme->getImageAndColor( TEXT_ENTRY_ENABLED_SMALL_CENTER );
- GadgetTextEntrySetEnabledImageSmallCenter( window, info->image );
- info = TheDefaultScheme->getImageAndColor( TEXT_ENTRY_DISABLED_LEFT );
- GadgetTextEntrySetDisabledImageLeft( window, info->image );
- GadgetTextEntrySetDisabledColor( window, info->color );
- GadgetTextEntrySetDisabledBorderColor( window, info->borderColor );
- info = TheDefaultScheme->getImageAndColor( TEXT_ENTRY_DISABLED_RIGHT );
- GadgetTextEntrySetDisabledImageRight( window, info->image );
- info = TheDefaultScheme->getImageAndColor( TEXT_ENTRY_DISABLED_CENTER );
- GadgetTextEntrySetDisabledImageCenter( window, info->image );
- info = TheDefaultScheme->getImageAndColor( TEXT_ENTRY_DISABLED_SMALL_CENTER );
- GadgetTextEntrySetDisabledImageSmallCenter( window, info->image );
- info = TheDefaultScheme->getImageAndColor( TEXT_ENTRY_HILITE_LEFT );
- GadgetTextEntrySetHiliteImageLeft( window, info->image );
- GadgetTextEntrySetHiliteColor( window, info->color );
- GadgetTextEntrySetHiliteBorderColor( window, info->borderColor );
- info = TheDefaultScheme->getImageAndColor( TEXT_ENTRY_HILITE_RIGHT );
- GadgetTextEntrySetHiliteImageRight( window, info->image );
- info = TheDefaultScheme->getImageAndColor( TEXT_ENTRY_HILITE_CENTER );
- GadgetTextEntrySetHiliteImageCenter( window, info->image );
- info = TheDefaultScheme->getImageAndColor( TEXT_ENTRY_HILITE_SMALL_CENTER );
- GadgetTextEntrySetHiliteImageSmallCenter( window, info->image );
- Color color, border;
- color = TheDefaultScheme->getEnabledTextColor();
- border = TheDefaultScheme->getEnabledTextBorderColor();
- window->winSetEnabledTextColors( color, border );
- color = TheDefaultScheme->getDisabledTextColor();
- border = TheDefaultScheme->getDisabledTextBorderColor();
- window->winSetDisabledTextColors( color, border );
- color = TheDefaultScheme->getHiliteTextColor();
- border = TheDefaultScheme->getHiliteTextBorderColor();
- window->winSetHiliteTextColors( color, border );
- // set default font
- window->winSetFont( TheDefaultScheme->getFont() );
- } // end if
- // contents have changed
- setUnsaved( TRUE );
- // notify the editor of the new window
- notifyNewWindow( window );
- return window;
- } // end newTextEntry
- // GUIEdit::newStaticText =====================================================
- /** Create a new static text*/
- //=============================================================================
- GameWindow *GUIEdit::newStaticText( GameWindow *parent,
- Int x, Int y,
- Int width, Int height )
- {
- GameWindow *window;
- WinInstanceData instData;
- UnsignedInt status = WIN_STATUS_ENABLED | WIN_STATUS_IMAGE;
- // validate the parent to disallow illegal relationships
- if( validateParentForCreate( parent ) == FALSE )
- return NULL;
- // keep inside a parent if present
- if( parent )
- clipCreationParamsToParent( parent, &x, &y, &width, &height );
- // initialize inst data
- instData.init();
- instData.m_style = GWS_STATIC_TEXT | GWS_MOUSE_TRACK;
- instData.m_textLabelString = "Static Text";
- // initialize listbox data
- TextData textData;
- memset( &textData, 0, sizeof( textData ) );
- textData.centered = TRUE;
- // make control
- window = TheWindowManager->gogoGadgetStaticText( parent,
- status,
- x, y,
- width, height,
- &instData,
- &textData,
- NULL,
- TRUE );
- // set default colors based on the default scheme
- if( window )
- {
- ImageAndColorInfo *info;
- info = TheDefaultScheme->getImageAndColor( STATIC_TEXT_ENABLED );
- GadgetStaticTextSetEnabledImage( window, info->image );
- GadgetStaticTextSetEnabledColor( window, info->color );
- GadgetStaticTextSetEnabledBorderColor( window, info->borderColor );
- info = TheDefaultScheme->getImageAndColor( STATIC_TEXT_DISABLED );
- GadgetStaticTextSetDisabledImage( window, info->image );
- GadgetStaticTextSetDisabledColor( window, info->color );
- GadgetStaticTextSetDisabledBorderColor( window, info->borderColor );
- info = TheDefaultScheme->getImageAndColor( STATIC_TEXT_DISABLED );
- GadgetStaticTextSetDisabledImage( window, info->image );
- GadgetStaticTextSetDisabledColor( window, info->color );
- GadgetStaticTextSetDisabledBorderColor( window, info->borderColor );
- Color color, border;
- color = TheDefaultScheme->getEnabledTextColor();
- border = TheDefaultScheme->getEnabledTextBorderColor();
- window->winSetEnabledTextColors( color, border );
- color = TheDefaultScheme->getDisabledTextColor();
- border = TheDefaultScheme->getDisabledTextBorderColor();
- window->winSetDisabledTextColors( color, border );
- color = TheDefaultScheme->getHiliteTextColor();
- border = TheDefaultScheme->getHiliteTextBorderColor();
- window->winSetHiliteTextColors( color, border );
- // set default font
- window->winSetFont( TheDefaultScheme->getFont() );
- } // end if
- // contents have changed
- setUnsaved( TRUE );
- // notify the editor of the new window
- notifyNewWindow( window );
- return window;
- } // end newStaticText
- // GUIEdit::createStatusBar ===================================================
- /** Create a status bar at the bottom of the editor */
- //=============================================================================
- void GUIEdit::createStatusBar( void )
- {
- RECT rect;
- Int width;
- Int sizes[ STATUS_NUM_PARTS ];
- // create the bar
- m_statusBarHWnd = CreateStatusWindow( WS_CHILD |
- WS_VISIBLE |
- WS_CLIPSIBLINGS |
- CCS_BOTTOM |
- SBARS_SIZEGRIP,
- "Ready",
- m_appHWnd,
- STATUS_BAR_ID );
-
- // get size of status bar
- GetWindowRect( m_statusBarHWnd, &rect );
- width = rect.right - rect.left;
- //
- // split the bar up into segments so we can put different text in
- // each of them
- //
- for( Int i = 0; i < STATUS_NUM_PARTS - 1; i++ )
- {
- sizes[ i ] = (i + 1) * (width / STATUS_NUM_PARTS);
- } // end for i
- sizes[ STATUS_NUM_PARTS - 1 ] = -1; // right edge
- SendMessage( m_statusBarHWnd, SB_SETPARTS, STATUS_NUM_PARTS, (LPARAM)sizes );
- } // end createStatusBar
- // GUIEdit::statusMessage =====================================================
- /** Set a message in the status bar */
- //=============================================================================
- void GUIEdit::statusMessage( StatusPart part, char *message )
- {
- // check for out of bounds part
- if( part < 0 || part >= STATUS_NUM_PARTS )
- {
-
- DEBUG_LOG(( "Status message part out of range '%d', '%s'\n", part, message ));
- assert( 0 );
- return;
- } // end if
- if( m_statusBarHWnd )
- SendMessage( m_statusBarHWnd, SB_SETTEXT, part, (LPARAM)message );
- } // end statusMessage
- // GUIEdit::createToolbar =====================================================
- /** Create the toolbar for the editor */
- //=============================================================================
- void GUIEdit::createToolbar( void )
- {
- } // end createToolbar
- ///////////////////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////////////////
- // GUIEdit::newLayout =========================================================
- /** Reset the editor for a new layout */
- //=============================================================================
- Bool GUIEdit::newLayout( void )
- {
- // delete all windows
- deleteAllWindows();
- // we are now fresh and new, like when everything was green and good
- setUnsaved( FALSE );
- // remove layout entries
- m_layoutInitString = GUIEDIT_NONE_STRING;
- m_layoutUpdateString = GUIEDIT_NONE_STRING;
- m_layoutShutdownString = GUIEDIT_NONE_STRING;
- return TRUE;
- } // end newLayout
- // GUIEdit::menuExit ==========================================================
- /** The user clicked on exit in the menu and wishes to exit the editor */
- //=============================================================================
- Bool GUIEdit::menuExit( void )
- {
- Int result;
- //
- // if the contents of the editor are unsaved ask the user if they want
- // to save before quitting
- //
- if( m_unsaved )
- {
- result = MessageBox( m_appHWnd, "Save file before quitting?",
- "Save?", MB_YESNOCANCEL );
- if( result == IDCANCEL )
- return TRUE; // no error
- else if( result == IDYES )
- {
- Bool success;
- // save all our data
- success = TheEditor->menuSave();
- //
- // if we were unable to save file ask them if it's still OK to
- // quit and lose the data
- //
- if( success == FALSE )
- MessageBox( m_appHWnd,
- "File not saved. If you continue to exit all data will be LOST!",
- "File Not Saved", MB_OK );
- } // end if
- } // end if
- // ask them if they really want to quit
- result = MessageBox( m_appHWnd, "Exit GUIEdit?", "Really Quit?", MB_YESNO );
- if( result == IDYES )
- DestroyWindow( m_appHWnd );
- return TRUE;
- } // end menuExit
- // GUIEdit::menuNew ===========================================================
- /** file->new menu option */
- //=============================================================================
- Bool GUIEdit::menuNew( void )
- {
-
- //
- // if the current data is unsaved ask the user if they want to save
- // before proceeding with a new layout
- //
- if( m_unsaved == TRUE )
- {
- Int result;
- result = MessageBox( m_appHWnd,
- "Current data is not saved. Save before proceeding?",
- "Save?",
- MB_YESNOCANCEL );
- if( result == IDCANCEL )
- return TRUE; // no error
- else if( result == IDYES )
- {
- Bool success;
- // do the save
- success = menuSave();
- // save failed, ask to proceed anyway with new layout
- if( success == FALSE )
- {
- result = MessageBox( m_appHWnd,
- "File not saved. Proceed with new layout anyway? Current layout will be LOST!",
- "File Not Saved",
- MB_YESNO );
- if( result == IDNO )
- return TRUE; // they chose to proceed anyway, no error
- } // end if
- } // end if
- } // end if
- // reset the layout in the editor
- strcpy( m_savePathAndFilename, "" );
- strcpy( m_saveFilename, "" );
- newLayout();
- return TRUE;
- } // end menuNew
- // GUIEdit::stripNameDecorations ==============================================
- /** Strip name decorations of the entire tree of windows */
- //=============================================================================
- void GUIEdit::stripNameDecorations( GameWindow *root )
- {
- // end of recursion
- if( root == NULL )
- return;
- // strip off this name if present
- WinInstanceData *instData = root->winGetInstanceData();
- if( !instData->m_decoratedNameString.isEmpty() )
- {
- char nameOnly[ MAX_WINDOW_NAME_LEN ];
- char *c;
- // skip past the "filename.wnd:" to the name only
- c = strchr( instData->m_decoratedNameString.str(), ':' );
- if( c )
- {
- // skip beyong the scope resolution colon
- c++;
- // copy the name
- strcpy( nameOnly, c );
- // put the name only in the decoration field
- instData->m_decoratedNameString = nameOnly;
- } // end if
- } // end if
- // strip from children
- GameWindow *child;
- for( child = root->winGetChild(); child; child = child->winGetChild() )
- stripNameDecorations( child );
- // onto the next
- stripNameDecorations( root->winGetNext() );
- } // end stripNameDecorations
- //=============================================================================
- /** After a load, we will restore default callbacks to all user windows
- * loaded from the file */
- //=============================================================================
- void GUIEdit::revertDefaultCallbacks( GameWindow *root )
- {
- // end recursion
- if( root == NULL )
- return;
- // if this is a user window, set the default callbacks
- if( windowIsGadget( root ) == FALSE )
- {
- root->winSetSystemFunc( TheWindowManager->getDefaultSystem() );
- root->winSetInputFunc( TheWindowManager->getDefaultInput() );
- root->winSetTooltipFunc( TheWindowManager->getDefaultTooltip() );
- root->winSetDrawFunc( TheWindowManager->getDefaultDraw() );
- } // end if
- // do the children
- revertDefaultCallbacks( root->winGetChild() );
- // do the next window
- revertDefaultCallbacks( root->winGetNext() );
- } // end revertDefaultCallbacks
- // GUIEdit::menuOpen ==========================================================
- /** User has clicked on file->open */
- //=============================================================================
- Bool GUIEdit::menuOpen( void )
- {
- char *filePath;
- //
- // if the current data is unsaved ask the user if they want to save
- // before proceeding with a new layout
- //
- if( m_unsaved == TRUE )
- {
- Int result;
- result = MessageBox( m_appHWnd,
- "Current data is not saved. Save before proceeding?",
- "Save?",
- MB_YESNOCANCEL );
- if( result == IDCANCEL )
- return TRUE; // no error
- else if( result == IDYES )
- {
- Bool success;
- // do the save
- success = menuSave();
- // save failed, ask to proceed anyway with new layout
- if( success == FALSE )
- {
- result = MessageBox( m_appHWnd,
- "File not saved. Proceed with open layout anyway? Current layout will be LOST!",
- "File Not Saved",
- MB_YESNO );
- if( result == IDNO )
- return TRUE; // they chose to proceed anyway, no error
- } // end if
- } // end if
- } // end if
- // open the standard window file browser
- filePath = openDialog();
- // if no filename came back they cancelled this operation
- if( filePath == NULL )
- return FALSE; // file not opened
- //
- // OK, given the full path to the file, save that full path and
- // just the filename in members of the editor
- //
- setSaveFile( filePath );
-
- // clear the contents of the editor
- newLayout();
-
- // load the new layout file
- WindowLayoutInfo info;
- TheWindowManager->winCreateFromScript( AsciiString(filePath), &info );
- // save the strings loaded for the layout callbacks
- setLayoutInit( info.initNameString );
- setLayoutUpdate( info.updateNameString );
- setLayoutShutdown( info.shutdownNameString );
- //
- // strip off all the decorations on each window name, they are
- // unnecessary complication in the editor
- //
- stripNameDecorations( TheWindowManager->winGetWindowList() );
- //
- // remove the user callbacks and set them to default draw, input, etc ...
- // we COULD use the real ones, but then we'd have to be assured that
- // every one we wrote would behave if in the editor or the game.
- // It's just easier to not worry about that, and the defaults are
- // good enough for general purpose in all situations
- //
- revertDefaultCallbacks( TheWindowManager->winGetWindowList() );
- // reset the tree view and add all the windows loaded
- TheHierarchyView->reset();
- GameWindow *window;
- for( window = TheWindowManager->winGetWindowList();
- window;
- window = window->winGetNext() )
- TheHierarchyView->addWindow( window, HIERARCHY_ADD_AT_BOTTOM );
- /** @todo should probably make the window manager interface for
- this a little nicer to tell us success and whatnot */
- return TRUE;
- } // end menuOpen
- // GUIEdit::menuSave ==========================================================
- /** file->save menu option */
- //=============================================================================
- Bool GUIEdit::menuSave( void )
- {
- Bool success;
- // if no filename is yet specified then go through the save as logic
- if( strlen( m_savePathAndFilename ) == 0 )
- return menuSaveAs();
- // save all our data to the specified filename
- success = saveData( m_savePathAndFilename, m_saveFilename );
- if( success == TRUE )
- {
- // our contents are now considered "unchanged"
- setUnsaved( FALSE );
- } // end if
- else
- {
-
- MessageBox( m_appHWnd, "Layout not saved!", "Error", MB_OK );
- } // end else
- return success;
- } // end menuSave
- // GUIEdit::menuSaveAs ========================================================
- /** file->saveAs menu option */
- //=============================================================================
- Bool GUIEdit::menuSaveAs( void )
- {
- char *filePath;
- Bool success;
- // open the standard window file browser
- filePath = saveAsDialog();
- // if no filename came back they cancelled this operation
- if( filePath == NULL )
- return FALSE; // save not done
- // OK, save the filename we're going to use
- setSaveFile( filePath );
- // save all our data to the specified filename
- success = saveData( m_savePathAndFilename, m_saveFilename );
- if( success == TRUE )
- {
- // our contents are now considered "unchanged"
- setUnsaved( FALSE );
- } // end if
- else
- {
-
- MessageBox( m_appHWnd, "Layout not saved!", "Error", MB_OK );
- } // end else
- return success;
- } // end menuSaveAs
- // GUIEdit::menuCopy ==========================================================
- /** Copy selected windows into clipboard */
- //=============================================================================
- Bool GUIEdit::menuCopy( void )
- {
- WindowSelectionEntry *select;
- // trivial case, nothing selected
- select = getSelectList();
- if( select == NULL )
- {
- MessageBox( m_appHWnd, "You must have windows selected before you can copy them.",
- "No Windows Selected", MB_OK );
- return TRUE;
- } // end if
- //
- // cut the selected windows out of the current window system, and
- // into the clipboard
- //
- TheGUIEditWindowManager->copySelectedToClipboard();
- return TRUE;
- } // end menuCopy
- // GUIEdit::menuPaste =========================================================
- /** Paste contents of clipboard into current layout */
- //=============================================================================
- Bool GUIEdit::menuPaste( void )
- {
- TheGUIEditWindowManager->pasteClipboard();
- return TRUE;
- } // end menuPaste
- // GUIEdit::menuCut ===========================================================
- /** Cut selected windows into the clipboard */
- //=============================================================================
- Bool GUIEdit::menuCut( void )
- {
- WindowSelectionEntry *select;
- // trivial case, nothing selected
- select = getSelectList();
- if( select == NULL )
- {
- MessageBox( m_appHWnd, "You must have windows selected before you can cut.",
- "No Windows Selected", MB_OK );
- return TRUE;
- } // end if
- //
- // cut the selected windows out of the current window system, and
- // into the clipboard
- //
- TheGUIEditWindowManager->cutSelectedToClipboard();
- return TRUE;
- } // end menuCut
- ///////////////////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////////////////
- // GUIEdit::isWindowSelected ==================================================
- /** Is the window selected */
- //=============================================================================
- Bool GUIEdit::isWindowSelected( GameWindow *window )
- {
- WindowSelectionEntry *entry;
- // sanity
- if( window == NULL )
- return FALSE;
- // find entry
- entry = findSelectionEntry( window );
- if( entry )
- return TRUE;
- else
- return FALSE;
- } // end isWindowSelected
- // GUIEdit::selectWindow ======================================================
- /** Add window to selection list */
- //=============================================================================
- void GUIEdit::selectWindow( GameWindow *window )
- {
- WindowSelectionEntry *entry;
- // sanity
- if( window == NULL )
- return;
- // do not add to list if already on it
- if( isWindowSelected( window ) == TRUE )
- return;
- // allocate new entry and add to list
- entry = new WindowSelectionEntry;
- if( entry == NULL )
- {
- DEBUG_LOG(( "Unable to allocate selection entry for window\n" ));
- assert( 0 );
- return;
- } // end if
- // fill out information and tie to head of list
- entry->window = window;
- entry->prev = NULL;
- entry->next = m_selectList;
- if( m_selectList )
- m_selectList->prev = entry;
- m_selectList = entry;
- // select this window in the hierarchy if there is only one selected
- if( selectionCount() == 1 )
- TheHierarchyView->selectWindow( window );
- } // end selectWindow
- // GUIEdit::unSelectWindow ====================================================
- /** Remove window from the selection list */
- //=============================================================================
- void GUIEdit::unSelectWindow( GameWindow *window )
- {
- WindowSelectionEntry *entry;
- // sanity
- if( window == NULL )
- return;
- // find entry
- entry = findSelectionEntry( window );
- if( entry )
- {
- // remove from list
- if( entry->next )
- entry->next->prev = entry->prev;
- if( entry->prev )
- entry->prev->next = entry->next;
- else
- m_selectList = entry->next;
- // delete the entry
- delete entry;
- } // end if
- } // end unSelectWindow
- // GUIEdit::clearSelections ===================================================
- /** Clear the entire selection list */
- //=============================================================================
- void GUIEdit::clearSelections( void )
- {
- while( m_selectList )
- unSelectWindow( m_selectList->window );
- } // end clearSelections
- // GUIEdit::selectionCount ====================================================
- /** How many items are selected */
- //=============================================================================
- Int GUIEdit::selectionCount( void )
- {
- WindowSelectionEntry *select;
- Int count = 0;
- select = m_selectList;
- while( select )
- {
- count++;
- select = select->next;
- } // end while
- return count;
- } // end selectionCount
- // GUIEdit::notifyNewWindow ===================================================
- /** The passed in window has just been added into the GUI layout. It
- * It may also contain children which we will recursively call upon
- * so that every window gets a chance to run through this method */
- //=============================================================================
- void GUIEdit::notifyNewWindow( GameWindow *window )
- {
- // end of recursion
- if( window == NULL )
- return;
- //
- // add this window to the hierarchy view at the top, we're adding it
- // at the bottom because presumabely this method was called directly after
- // the window was placed in the world, and it now resides on the top
- // of the window chain, therefore at the bottom of the hierarchy, drawn last
- //
- TheHierarchyView->addWindow( window, HIERARCHY_ADD_AT_TOP );
- //
- // call this notification method for any children we might have, we
- // do NOT notify for the children of gadget controls since those are
- // an "atomic" unit, (except for the Tab Control, which has window children)
- //
- if( (windowIsGadget( window ) == FALSE) || (window->winGetStyle() & GWS_TAB_CONTROL) )
- {
- GameWindow *child;
- for( child = window->winGetChild(); child; child = child->winGetNext() )
- notifyNewWindow( child );
- } // end if
- } // end notifyNewWindow
- // GUIEdit::deleteSelected ====================================================
- /** Delete the windows in the selection list */
- //=============================================================================
- void GUIEdit::deleteSelected( void )
- {
- Int count = TheEditor->selectionCount();
- Int i;
- GameWindow **deleteList;
- WindowSelectionEntry *select;
- //
- // the act of deleting things can actually change selections, like when
- // removing a hierarchy item, the selection is moved ... to avoid any
- // confusion we will build a list of windows to be deleted, independent
- // of the select list and delete those
- //
- deleteList = new GameWindow *[ count ];
- if( deleteList == NULL )
- {
-
- DEBUG_LOG(( "Cannot allocate delete list!\n" ));
- assert( 0 );
- return;
- } // end if
- // fill out the delete list
- for( i = 0, select = m_selectList; i < count; i++, select = select->next )
- deleteList[ i ] = select->window;
- // delete them all
- for( i = 0; i < count; i++ )
- deleteWindow( deleteList[ i ] );
- // free memory for the delete list
- delete [] deleteList;
- } // end deleteSelected
- // GUIEdit::bringSelectedToTop ================================================
- /** Bring the selected windows to the top so they draw on top of
- * other windows. For window with no parents this brings them to
- * the top of the window stack for all windows, for child windows it will
- * bring them to the top of the child list for their parent */
- //=============================================================================
- void GUIEdit::bringSelectedToTop( void )
- {
- Int count = TheEditor->selectionCount();
- // no-op
- if( count == 0 )
- return;
- //
- // build a list of selections to operate on, we need to do this
- // because the process of changing the hierarchy view will change the
- // select list on us
- //
- GameWindow **snapshot;
- snapshot = new GameWindow *[ count ];
- if( snapshot == NULL )
- {
- DEBUG_LOG(( "bringSelectedToTop: Unabled to allocate selectList\n" ));
- assert( 0 );
- return;
- } // end if
- // take the snapshot
- Int i;
- WindowSelectionEntry *select;
- for( i = 0, select = m_selectList; i < count; i++, select = select->next )
- snapshot[ i ] = select->window;
- // bring all the selected windows to the top
- for( i = 0; i < count; i++ )
- {
- // bring window to the top
- snapshot[ i ]->winBringToTop();
- // update the hierarchy to have the new window on the top
- TheHierarchyView->bringWindowToTop( snapshot[ i ] );
- } // end for i
- // delete the snapshot list
- delete [] snapshot;
- } // end bringSelectedToTop
- // GUIEdit::dragMoveSelectedWindows ===========================================
- /** Move all the windows in the selection list from a drag move, note
- * that we are keeping the positions within the screen and parent
- * windows */
- //=============================================================================
- void GUIEdit::dragMoveSelectedWindows( ICoord2D *dragOrigin,
- ICoord2D *dragDest )
- {
- WindowSelectionEntry *select;
- GameWindow *window;
- ICoord2D moveLoc, safeLoc;
- ICoord2D origin;
- // sanity
- if( dragOrigin == NULL || dragDest == NULL )
- return;
- // traverse selection list
- select = m_selectList;
- while( select )
- {
- // get window info
- window = select->window;
- window->winGetScreenPosition( &origin.x, &origin.y );
- // compute new location
- moveLoc.x = origin.x + (dragDest->x - dragOrigin->x);
- moveLoc.y = origin.y + (dragDest->y - dragOrigin->y);
- // snap move location to grid if on
- if( (TheEditor->getMode() == MODE_DRAG_MOVE) && TheEditor->isGridSnapOn() )
- TheEditor->gridSnapLocation( &moveLoc, &moveLoc );
- // kee the location legal
- computeSafeLocation( window, moveLoc.x, moveLoc.y, &safeLoc.x, &safeLoc.y );
-
- // move the window
- moveWindowTo( window, safeLoc.x, safeLoc.y );
- // goto next selected window
- select = select->next;
- } // end while
- } // end dragMoveSelectedWindows
- // GUIEdit::getSelectList =====================================================
- /** Return the selection list */
- //=============================================================================
- WindowSelectionEntry *GUIEdit::getSelectList( void )
- {
- return m_selectList;
- } // end getSelectList
- // GUIEdit::getFirstSelected ==================================================
- /** Get the first GameWindow * from the selection list */
- //=============================================================================
- GameWindow *GUIEdit::getFirstSelected( void )
- {
- if( m_selectList )
- return m_selectList->window;
- return NULL;
- } // end getFirstSelected
- // GUIEdit::computeSafeLocation ===============================================
- /** If we attempt to move the window to the given (x,y) it may result
- * in that location being either outside of the screen or outside of
- * the parent. This method will compute a location as close to the
- * desired (x,y) as possible but still remain within the parent
- * and on the screen */
- //=============================================================================
- void GUIEdit::computeSafeLocation( GameWindow *window,
- Int x, Int y, Int *safeX, Int *safeY )
- {
- Int dx, dy;
- ICoord2D origin, size;
- GameWindow *parent;
- IRegion2D region;
- // get window position and size
- window->winGetScreenPosition( &origin.x, &origin.y );
- window->winGetSize( &size.x, &size.y );
- // get region of the window in question
- window->winGetRegion( ®ion );
- // how far from window current position to new one
- dx = x - origin.x;
- dy = y - origin.y;
- // clip window to parent if there is one
- parent = window->winGetParent();
- if( parent )
- {
- ICoord2D parentSize;
- // get parent size
- parent->winGetSize( &parentSize.x, &parentSize.y );
- if( region.lo.x + dx < 0 )
- dx = 0 - region.lo.x;
- else if( region.hi.x + dx > parentSize.x )
- dx = parentSize.x - region.hi.x;
- if( region.lo.y + dy < 0 )
- dy = 0 - region.lo.y;
- else if( region.hi.y + dy > parentSize.y )
- dy = parentSize.y - region.hi.y;
- } // end else if, parent
-
- // Move the window, but keep it completely visible within screen boundaries
- IRegion2D newRegion;
- ICoord2D grabSize;
- window->winGetPosition( &newRegion.lo.x, &newRegion.lo.y );
- window->winGetSize( &grabSize.x, &grabSize.y );
- newRegion.lo.x += dx;
- newRegion.lo.y += dy;
- if( newRegion.lo.x < 0 )
- newRegion.lo.x = 0;
- if( newRegion.lo.y < 0 )
- newRegion.lo.y = 0;
- newRegion.hi.x = newRegion.lo.x + grabSize.x;
- newRegion.hi.y = newRegion.lo.y + grabSize.y;
- if( newRegion.hi.x > (Int)TheDisplay->getWidth() )
- newRegion.hi.x = (Int)TheDisplay->getWidth();
- if( newRegion.hi.y > (Int)TheDisplay->getHeight() )
- newRegion.hi.y = (Int)TheDisplay->getHeight();
- // compute new position
- newRegion.lo.x = newRegion.hi.x - grabSize.x;
- newRegion.lo.y = newRegion.hi.y - grabSize.y;
- // safe position is now all figured out
- *safeX = newRegion.lo.x;
- *safeY = newRegion.lo.y;
- } // end computeSafeLocation
- // GUIEdit::computeSafeSizeLocation ===========================================
- /** Like the method computeSafeLocation, this method also takes into
- * account the new position AND size, keeping them within the
- * screen and within any parents
- *
- * NOTE: this assumes it is for the resizing code which assumes that
- * the resize will not invert across the anchor point so we're
- * only checking origin points and sizes compared to parents
- * and the screen;
- *
- * Location returned is relative to parent window if present
- */
- //=============================================================================
- void GUIEdit::computeSafeSizeLocation( GameWindow *window,
- Int newX, Int newY,
- Int newWidth, Int newHeight,
- Int *safeX, Int *safeY,
- Int *safeWidth, Int *safeHeight )
- {
- GameWindow *parent;
- ICoord2D parentLoc;
- ICoord2D parentSize;
- ICoord2D topLeftLimit;
- ICoord2D bottomRightLimit;
-
- // get parent window and data is present
- parent = window->winGetParent();
- if( parent )
- {
- parent->winGetScreenPosition( &parentLoc.x, &parentLoc.y );
- parent->winGetSize( &parentSize.x, &parentSize.y );
- } // end if
- // upper left corner must be in screen or in parent
- topLeftLimit.x = 0; // screen top left
- topLeftLimit.y = 0; // screen top left
- if( parent )
- topLeftLimit = parentLoc;
- if( newX < topLeftLimit.x )
- {
- newWidth = newWidth - (topLeftLimit.x - newX);
- newX = topLeftLimit.x;
- }
- if( newY < topLeftLimit.y )
- {
- newHeight = newHeight - (topLeftLimit.y - newY);
- newY = topLeftLimit.y;
- }
- // check size at new position compared to parent or screen
- bottomRightLimit.x = TheDisplay->getWidth();
- bottomRightLimit.y = TheDisplay->getHeight();
- if( parent )
- {
- bottomRightLimit.x = parentLoc.x + parentSize.x;
- bottomRightLimit.y = parentLoc.y + parentSize.y;
- } // end if
- if( newX + newWidth > bottomRightLimit.x )
- newWidth = bottomRightLimit.x - newX;
- if( newY + newHeight > bottomRightLimit.y )
- newHeight = bottomRightLimit.y - newY;
- // all done, return location and width relative to parent
- *safeWidth = newWidth;
- *safeHeight = newHeight;
- *safeX = newX;
- *safeY = newY;
- if( parent )
- {
- *safeX = *safeX - parentLoc.x;
- *safeY = *safeY - parentLoc.y;
- }
- } // end computeSafeSizeLocation
- // GUIEdit::computeResizeLocation =============================================
- /** Given the current resize drag mode, the selected window to resize,
- * the start location of the drag, and the end location of the drag,
- * figure out what the upper left corner location and the size of the
- * window should be */
- //=============================================================================
- void GUIEdit::computeResizeLocation( EditMode resizeMode,
- GameWindow *window,
- ICoord2D *resizeOrigin,
- ICoord2D *resizeDest,
- ICoord2D *resultLoc,
- ICoord2D *resultSize )
- {
- Int newX, newY, newSizeX, newSizeY;
- Int sizeLimit = 5;
- // sanity
- if( window == NULL || resizeOrigin == NULL || resizeDest == NULL ||
- resultLoc == NULL || resultSize == NULL )
- return;
- // get the current position and size of the window
- ICoord2D origin, size, bottomRight;
- window->winGetScreenPosition( &origin.x, &origin.y );
- window->winGetSize( &size.x, &size.y );
- bottomRight.x = origin.x + size.x;
- bottomRight.y = origin.y + size.y;
- //
- // compute new size and width based on which resize mode we're
- // using for the anchor point of the window
- //
- switch( resizeMode )
- {
- // ------------------------------------------------------------------------
- case MODE_RESIZE_TOP_LEFT:
- // bottom right is the anchor
- newX = origin.x + (resizeDest->x - resizeOrigin->x);
- newY = origin.y + (resizeDest->y - resizeOrigin->y);
-
- // don't let it become too small or inverted
- if( newX >= bottomRight.x - sizeLimit )
- newX = bottomRight.x - sizeLimit;
- if( newY >= bottomRight.y - sizeLimit )
- newY = bottomRight.y - sizeLimit;
- // compute new size
- newSizeX = bottomRight.x - newX;
- newSizeY = bottomRight.y - newY;
- break;
- // ------------------------------------------------------------------------
- case MODE_RESIZE_TOP_RIGHT:
- // bottom left is the anchor
- newX = origin.x;
- newY = resizeDest->y;
- // don't let it become too small or inverted
- if( newY >= bottomRight.y - sizeLimit )
- newY = bottomRight.y - sizeLimit;
-
- // compute new size
- newSizeX = resizeDest->x - origin.x;
- newSizeY = (origin.y + size.y) - resizeDest->y;
- // don't let it invert
- if( newSizeX < sizeLimit )
- newSizeX = sizeLimit;
- if( newSizeY < sizeLimit )
- newSizeY = sizeLimit;
- break;
- // ------------------------------------------------------------------------
- case MODE_RESIZE_BOTTOM_RIGHT:
- // top left is anchor
- newX = origin.x;
- newY = origin.y;
- newSizeX = resizeDest->x - origin.x;
- newSizeY = resizeDest->y - origin.y;
- // don't let it invert or get too small
- if( newSizeX < sizeLimit )
- newSizeX = sizeLimit;
- if( newSizeY < sizeLimit )
- newSizeY = sizeLimit;
- break;
- // ------------------------------------------------------------------------
- case MODE_RESIZE_BOTTOM_LEFT:
- // top right is the anchor
- newX = resizeDest->x;
- newY = origin.y;
- // don't let it get too small or inverted
- if( newX >= bottomRight.x - sizeLimit )
- newX = bottomRight.x - sizeLimit;
- // compute new size
- newSizeX = bottomRight.x - newX;
- newSizeY = resizeDest->y - origin.y;
-
- // don't let it go inverted
- if( newSizeY < sizeLimit )
- newSizeY = sizeLimit;
- break;
- // ------------------------------------------------------------------------
- case MODE_RESIZE_TOP:
- // bottom SIDE is the anchor
- newX = origin.x;
- newY = resizeDest->y;
- // don't let it invert
- if( newY >= bottomRight.y - sizeLimit )
- newY = bottomRight.y - sizeLimit;
- // compute new size
- newSizeX = size.x;
- newSizeY = bottomRight.y - newY;
- break;
- // ------------------------------------------------------------------------
- case MODE_RESIZE_RIGHT:
- // left SIDE is the anchor
- newX = origin.x;
- newY = origin.y;
-
- // compute new size
- newSizeX = resizeDest->x - origin.x;
- newSizeY = size.y;
- // don't let it invert or get too small
- if( newSizeX < sizeLimit )
- newSizeX = sizeLimit;
- break;
- // ------------------------------------------------------------------------
- case MODE_RESIZE_BOTTOM:
- // top SIDE is the anchor
- newX = origin.x;
- newY = origin.y;
- // compute new size
- newSizeX = size.x;
- newSizeY = resizeDest->y - origin.y;
- // dont' let it invert or get too small
- if( newSizeY < sizeLimit )
- newSizeY = sizeLimit;
- break;
- // ------------------------------------------------------------------------
- case MODE_RESIZE_LEFT:
-
- // right SIDE is the anchor
- newX = resizeDest->x;
- newY = origin.y;
- // don't let it invert or get to small
- if( newX >= bottomRight.x - sizeLimit )
- newX = bottomRight.x - sizeLimit;
- // compute new size
- newSizeX = bottomRight.x - newX;
- newSizeY = size.y;
- break;
- } // end switch( resizeMode )
- // to finalize the size we must now clip to any parent or the screen
- computeSafeSizeLocation( window,
- newX, newY,
- newSizeX, newSizeY,
- &resultLoc->x, &resultLoc->y,
- &resultSize->x, &resultSize->y );
- } // end computeResizeLocation
- // GUIEdit::moveWindowTo ======================================================
- /** Move the window passed into the the absolute position (x,y),
- * note that there is NO SAFE checking done on that position */
- //=============================================================================
- void GUIEdit::moveWindowTo( GameWindow *window, Int x, Int y )
- {
- // set the position
- window->winSetPosition( x, y );
- // we've now made a change
- TheEditor->setUnsaved( TRUE );
- } // end moveWindowTo
- // GUIEdit::windowIsGadget ====================================================
- /** Return TRUE if this window is one of our predefined gadtet types */
- //=============================================================================
- Bool GUIEdit::windowIsGadget( GameWindow *window )
- {
- // sanity
- if( window == NULL )
- return FALSE;
- return BitTest( window->winGetStyle(), GWS_GADGET_WINDOW );
- } // end windowIsGadget
- // GUIEdit::gridSnapLocation ==================================================
- /** Given the source input point, return in 'snapped' the closest grid
- * point */
- //=============================================================================
- void GUIEdit::gridSnapLocation( ICoord2D *source, ICoord2D *snapped )
- {
- // sanity
- if( source == NULL || snapped == NULL )
- return;
- snapped->x = (source->x / m_gridResolution) * m_gridResolution;
- snapped->y = (source->y / m_gridResolution) * m_gridResolution;
- } // end gridSnapLocation
- // GUIEdit::checkMenuItem =====================================================
- /** Check the menu item from the guiedit main menu */
- //=============================================================================
- void GUIEdit::checkMenuItem( Int item )
- {
- HMENU menu = GetMenu( m_appHWnd );
- // sanity
- if( menu == NULL )
- return;
- // check it
- CheckMenuItem( menu, item, MF_CHECKED );
- } // end checkMenuItem
- // GUIEdit::unCheckMenuItem ===================================================
- /** Un-check the menu item from the guiedit main menu */
- //=============================================================================
- void GUIEdit::unCheckMenuItem( Int item )
- {
- HMENU menu = GetMenu( m_appHWnd );
- // sanity
- if( menu == NULL )
- return;
- // check it
- CheckMenuItem( menu, item, MF_UNCHECKED );
- } // end unCheckMenuItem
- // GUIEdit::isNameDuplicate ===================================================
- /** Is the name passed in found as the name of any window in in the
- * tree starting at root ... but we will ignore the window 'ignore'
- * if present */
- //=============================================================================
- Bool GUIEdit::isNameDuplicate( GameWindow *root, GameWindow *ignore, AsciiString name )
- {
- WinInstanceData *instData;
- // end of recursion, sanity for name, and empty name ("") is always OK
- if( root == NULL || name.isEmpty() )
- return FALSE; // name is a-ok! :)
- // get instance data
- instData = root->winGetInstanceData();
- // compare name
- if( root != ignore )
- if( instData->m_decoratedNameString == name )
- return TRUE; // no need to search anymore
-
- //You only call this on the first child since the call right after it will handle siblings (depth first)
- GameWindow *child = root->winGetChild();
- if( isNameDuplicate( child, ignore, name ) == TRUE )
- return TRUE; //duplicate was found
- // check the next window in the list
- return isNameDuplicate( root->winGetNext(), ignore, name );
- } // end isNameDuplicate
- // GUIEdit::loadGUIEditFontLibrary ============================================
- /** Load the set of fonts that we will make available to users in
- * in the editor */
- //=============================================================================
- void GUIEdit::loadGUIEditFontLibrary( FontLibrary *library )
- {
- // sanity
- if( library == NULL )
- return;
- AsciiString fixedSys("FixedSys");
- AsciiString times("Times New Roman");
- library->getFont( fixedSys, 12, FALSE );
- library->getFont( times, 14, FALSE );
- library->getFont( times, 14, TRUE );
- library->getFont( times, 12, FALSE );
- library->getFont( times, 12, TRUE );
- library->getFont( times, 10, FALSE );
- library->getFont( times, 10, TRUE );
- } // end loadGUIEditFontLibrary
- // GUIEdit::setShowHiddenOutlines =============================================
- //=============================================================================
- void GUIEdit::setShowHiddenOutlines( Bool show )
- {
- m_showHiddenOutlines = show;
- if( m_showHiddenOutlines )
- CheckMenuItem( GetMenu( m_appHWnd ), MENU_SHOW_HIDDEN_OUTLINES, MF_CHECKED );
- else
- CheckMenuItem( GetMenu( m_appHWnd ), MENU_SHOW_HIDDEN_OUTLINES, MF_UNCHECKED );
- } // end setShowHiddenOutlines
- // GUIEdit::setShowSeeThruOutlines ============================================
- //=============================================================================
- void GUIEdit::setShowSeeThruOutlines( Bool show )
- {
- m_showSeeThruOutlines = show;
- if( m_showSeeThruOutlines )
- CheckMenuItem( GetMenu( m_appHWnd ), MENU_SHOW_SEE_THRU_OUTLINES, MF_CHECKED );
- else
- CheckMenuItem( GetMenu( m_appHWnd ), MENU_SHOW_SEE_THRU_OUTLINES, MF_UNCHECKED );
- } // end setShowSeeThruOutlines
|