Home
Project Report
Contents
1. HPUBLIC void CClassWindow AddParent CClassWindow pTemp i CRelatedList pNew new CRelatedList pTemp pNew gt SetNext m pAdults m pAdults pNew H HPUBLIC void CClassWindow AddChild CClassWindow pTemp i CRelatedList pNew new CRelatedList pTemp pNew gt SetNext m pChildren m pChildren pNew H PUBLIC void CClassWindow AddInheritance void i moved from OnEvent called by new parent class which checks for cyclic inheritance checks if already parent etc CRelatedList pTchildren CClassWindow pChild if g pInheritor gt IsChild this TRUE CMainWindow CmwContents this gt m pParent gt GetParent gt SetStatusText Sorry No Cyclic inheritance aborted g plnheritor NULL 3 else f makesure not allready parent pTchildren m pChildren while pTchildren NULL pChild pTchildren gt GetClass if pChild g plnheritor CMainWindow CmwContents this gt m_pParent gt GetParent gt SetStatusText Class is allready parent g plnheritor NULL CmwContents m_pParent gt SetCursor 97 Project Report Bibliography new wxCursor wxCURSOR ARROW return H pTchildren pTchildren gt GetNext H adding this gt AddChild g pInheritor g plnheritor gt AddParent this reset pointer g plnheritor NULL CMainWindow CmwContents this gt m pParent gt GetParent gt SetStatusText
2. int i 0 int c c fgetc inFile while c n i pString i char c i c fgetc inFile H if feof inFile exit 1 pString i 0 Bool FlagFound char pLine 90 Bibliography Project Report Bibliography i if 0 strcmp pLine Start amp amp 0 stremp pLine HPRIVATE amp amp 0 stremp pLine HPROTECTED amp amp 0 strcmp pLine 4PUBLIC amp amp 0 stremp pLine Finish return FALSE return TRUE PUBLIC CClassWindow CClassWindow wxPanel parent CMvPanel parent m_pClassName char malloc g MaxNameLen sprintf m_pClassName NoName d GetID m currentHeight g SectionHeight Hifndef wx msw SetSize 1 1 Helse SetSize 0 0 1 1 Hendif m pCNHolder new CClassNameHolder wxPanel this 0 0 int g WindowWidth g SectionHeight m pMemberFuns NULL SetPen new wxPen g pColBLACK 3 wxSOLID m SeeMembers FALSE m pAdults NULL m pChildren NULL SetData Just enter the member variables in the same way n As in a class declaration n do not enter any functions declaration n e g t public n At tchar pAString n H PUBLIC CClassWindow CClassWindow void i Iwhile CClassWindow GetNext NULL delete CClassWindow GetNext delete m_pCNHolder delete m pAdults delete m pChildren delete m pMemberFuns free void m pClassName CmwContents m pParent
3. o O Week Ending o7 Feb Mae 21 Feb 28 Feb BADE 19 Ape meraspesteniasoriomo JE TS E implement ListModale E DO veses N mpenat A regu e gt O Implement other Modules o A Testomer modales eoe U Refnngsige i MW RetesModutes NN gt Au Tereon t 1 lt gt m Document Modules BD AA EA pebugrrogran Ey 1 gt U i e Re test with beta testers KN userdoumestion ZS Ea m owm MN MM gt BM lt y Complete Program Figure 9 Proposed Project time schedule 35 Project Plan Bibliography 1 7 Bibliography 1 7 1 Programs Used CodeWarrior MetroWerks Think C Semantic Visual C Version 4 02 Borland International Incorporated 1993 Developer Studio Microsoft Corporation 1994 1995 Editres Version 1 1 Part of standard X11 distribution Motif Version 1 2 Open Systems Foundation wx Windows Version 1 66b Julian Smart Artificial Inteligence Applications Institute Edinburgh May 9 1 7 2 Books Used Object Oriented Specification and Design with C Peter Henderson 1993 University Press Cambridge Turbo C Version 3 0 User s Guide Borland International 1992 1 7 3 WWW Resources Used wx Windows Homepage http www aiai ed ac uk jacs wxwin html Nov 96 Introduction to the Booch Method http
4. Unlink cwtest classes BOOL CDoublyLinkedListE Link lt CDoublyLinkedListEl pPrev gt BOOL fRet pPrev NULL gt CDoublyLinkedListEl pNext NULL m pPrev pPrev if fRet gt pNext pPrev gt GetNext pPrev gt SetNext this gt 3 end if mpNext pNext if CpNext NULL gt pNext gt SetPrev this gt end if Figure 2 MetroWerks CodeWarrior 10 Project Plan Context Survey 1 2 1 2 Semantic Think C Semantics Think C uses a graphical class browser see fig 3 This means it is far easier to interpret the inheritance trees although using arrows would help clarify things Unfortunately the user has no way of manipulating the layout of the class hierarchies Another drawback is that it is not possible to see the member functions of a class unless the mouse button was pressed over the selected class This is a hindrance as it is often useful to see the member functions of a number of classes at the same time To see the code associated with the member functions all that is reguired is to release the mouse button over the member functions whose code is to be viewed The code was displayed in a separate window Again the source code is not editable Overall this browser looks better than CodeWarrior s but the user interface leaves a lot to be desired Class Browser CFileTree CDoublyLinkedList CDoublyLinkedLi
5. H return TRUE 92 Project Report Bibliography PUBLIC Bool CClassWindow HasParent void i if m pAdults NULL return FALSE return TRUE H PUBLIC void CClassWindow DeleteFunction CMemberFunction pFun because of updating pointers withinthe list of functions a function may not delete its self This could be rectified by using a doubly linked list CMemberFunction pTemp pTemp m_pMemberFuns if m_pMemberFuns pFun m_pMemberFuns m_pMemberFuns gt GetNext pFun gt SetNext NULL m_currentHeight m_currentHeight g SectionHeight delete pFun Display return else while pTemp gt GetNext NULL if pTemp gt GetNext pFun pTemp gt SetNext pTemp gt GetNext gt GetNext pFun gt SetNext NULL delete pFun m currentHeight m currentHeight g SectionHeight Display return 3 else f pTemp pTemp gt GetNext H PUBLIC void CClassWindow RecursiveDelete CClassWindow pDeletingParent i CRelatedList pTadults NULL CClassWindow pParent NULL CClassWindow pChild NULL this is really wierd but it works call it a futuristic side effect while m_pChildren NULL pChild m_pChildren gt GetClass pChild gt RecursiveDelete this if pChild gt HasParent FALSE delete pChild pTadults m_pAdults while pTadults NULL 93 Project Report pParent pTadults gt GetClass if pPare
6. H PUBLIC CMemberFunction CMemberFunction void i free m pFunctName if m pNext NULL delete m pNext H PUBLIC void CMemberFunction GetDims float amp w float amp h i char funName GetFunctionName wxDC pDC GetPanelDC pDC gt GetTextExtent funName amp w amp h PUBLIC void CMemberFunction EditFunction void CEditWindow pEdit new CEditWindow NULL this Edit Member Function 100 100 400 400 pEdit gt Show TRUE H PUBLIC char CMemberFunction GetFunctionName void i H PUBLIC return m_pFunctName 130 Bibliography Project Report Bibliography void CMemberFunction OnPaint void if CClassWindow m pParent gt m SeeMembers i wxDC pDC GetPanelDC pDC gt Clear int w 0 h 0 GetSize amp w amp h pDC gt DrawRectangle float 0 float 0 float w float h wxColour OldCol OldCol wxColour malloc sizeof wxColour OldCol pDC gt GetTextForeground if m Access PROTECTED pDC gt SetTextForeground g pColProtected else if m Access PRIVATE pDC gt SetTextForeground g pColPrivate else if m Access PUBLIC pDC gt SetTextForeground g pColPublic pDC gt DrawText GetFunctionName float 5 float g SectionHeight 2 g SectionHeight 4 pDC gt SetTextForeground OldCol free OldCol H H PUBLIC CMemberFunction CMemberFunction GetN
7. The program may be changed in two ways Firstly bugs may be fixed and secondly new features may be added This section is a guide to how to go about making these changes 7 3 1 Recommended Changes Here is a list of changes which should be made to the code given time 1 The class CClassWindow should be broken down into a number of classes Firstly a class dealing with a directional graphs Secondly a class which contains and edits the data Thirdly a Class which deals with the loading and saving of data 2 Extending inheritance so that it may be either public private or protected 3 Loading and saving does more code analysis to determine its inheritance so that when a class is imported its hierarchy may also be imported 4 Support for global variables and non member functions 7 3 2 Adding New Features There are many features which could be added to Resworb and it would be impossible to cover all possibilities here Before a feature is added I would recommend that the implementers familiarises themselves with the structure of Resworb and note where they feel the new feature would fit The next guestion would be How would the user perceive this new feature as this is often a more realistic indication as to where the new code should fit After a new feature is added it is very important that the entire application is retested 7 3 3 Fixing bugs In the unlikely event of a bug becoming apparent then the first step should
8. pTemp gt Show FALSE if O stremp pLine PRIVATE pTemp gt MakeFunc PRIVATE else if 0 strcmpf pLine PUBLIC pTemp gt MakeFunc PUBLIC 3 else if 0 strcmp pLine HPROTECTED pTemp gt MakeFunc PROTECTED 3 else pTemp gt MakeFunc PUBLIC find lentgh of function so space may be created long startoffun endoffun startoffun ftell pCodeFile do GetLine pCodeFile pLine while FALSE FlagFound pLine endoffun ftell pCodeFile fseek pCodeFile startoffun SEEK SET char pFunCode create block to put function in pFunCode char malloc endoffun startoffun rd func pFunCode 0 0 GetLine pCodeFile pLine do strcat pFunCode pLine strcat pFunCode n GetLine pCodeFile pLine while FALSE FlagFound pLine the function is now read in off the disk now strip out the classname part char pPos char pClname pClname strdup GetClassName strcat pClname pPos strstr pFunCode pClname free pClname if pPos pFunCode i pFunCode 0 0 104 Project Report Bibliography 3 else pFunCode pPos pFunCode 1 0 pPos pPos strlen GetClassName 1 pPos 0 strcat pFunCode pPos put codestream into function pTemp gt SetData pFunCode release the codestream free pFunCode GetLine pCodeFile pLine finish
9. endif 82 Bibliography Project Report Bibliography 8 2 Assert h J RFR A ao ol lol aja loe ad lle al le leal al leal al lol al la alea Assert H EEES Cause asserts 24 12 96 SO ifndef ASSERT H Hdefine ASSERT H int AssertCrash void used to test if something is true If not quit application not used in relase version Hdefine assert exp void exp 0 AssertCrash endif 83 Project Report Bibliography 8 3 Assert cpp J PR PR A ao ol loe ol aja aja lle al lle al al leal al lol al la al ll Assert cpp FKK KKK K KK 2K K K KK causes application to crash after asserting 24 12 96 PBB likka include lt wx_prec h gt include lt wx h gt int AssertCrash void wxMessageBox Assertion Failure Assertion Failure its harder than it seems getting the application to die fast but this work very well wxButton die NULL die gt SetLabel Just some jibberish to kill the app return 0 84 Project Report 8 4 CClassNameHolder h J RFR A a od loe a loe ad loe al al leal A leal leal o ame h KAA Aaa hee ak leo kk kk 23 11 96 code for managing class names bindings and display Martin Bramley J PR PR A o od aj is oe ad le leal le leal ol lo aja le al lle al aj laaja aja aja ll al ll all lol ll ifndef UNIX Hinclude lt wx prec h gt Hendif Hinclude lt wx h gt Hinclude app def h Hifndef CLASSNAME H Hdefine CLASSNAME H include CMenuP
10. www itr ch courses case BoochReference Nov 96 Relational Rose C http www relational com pst products rosecpp html Nov 96 36 Project Plan 1 8 Glossary C A S E Class Encapsulation G U I Hungarian notation Inheritance amp Multiple inheritance Member access control Motif Napier Small talk Eifell Object orientated R C S Glossary Computer Aided Software Engineering An entity similar to C s struct and union which combines functions and data This is the welding of code and data into a single class type object Graphical User Interface A common style of varaible and object naming allowing ease of understanding Classes may inherit properties of other many classes A parent class is a class from which the current class inherits properties and a child class is a class which inherits properties of the current class Members of classes may be private public or protected A private member may only be accessed by other members in the same class A protected member may be accessed by any member of its or its childrens classes A puplic member may be accessed by anything A set tools widgets used for generating Graphical User Interfaces These are other Object Oriented languages A programing paradigm which C is a member The paradigm attempts to mimick the way we see the real world Revision Control System Definition taken from Turbo C Version 3 User s
11. 26 11 96 Martin Bramley J PR PR A ol aj ajaa lle al le leal laaja aja aja lle al le leal aja aja aja aja aa laj le lo ll ifndef MENUPNL H define MENUPNL H ifndef UNIX Hinclude lt wx prec h gt Hendif Hinclude lt wx h gt include CLinkedMenu h include CListPanel h class CMenuPanel public CListPanel Start protected CLinkedMenu m_pMenu Finish public CMenuPanel wxPanel int int int int CMenuPanel void OnEvent wxMouseEvent amp event virtual void OnPaint void void SetNext CMenuPanel CMenuPanel GetNext void endif 136 Bibliography Project Report 8 23 CMenuPanel cpp D PEKKAA ATA A AAA AA A A AERA menypnl cpp EEES 26 11 96 Martin Bramley J PR PR A aa aj ls oe al lle al le leal al lol lo a aja ll al le leal aja aj ajaja aja aja laj al lo ale Hinclude lt stdlib h gt Hinclude lt wx prec h gt Hinclude lt wx h gt Hinclude CMvPanel h Hinclude CmwContents h Hinclude CMainWindow h Hinclude CMenuPanel h Hinclude assert h Hinclude app def h Hinclude CEditWindow h Hinclude CClassWindow h extern CClassWindow g plnheritor extern CMvPanel g pMover PUBLIC CMenuPanel CMenuPanel wxPanel pParent int x int y int w int h CListPanel pParent x y w h m_pMenu new CLinkedMenu this SetTextBackground g pColWHITE PUBLIC CMenuPanel CMenuPanel delete m_pMenu
12. Designed preliminary graphical user interface Fri Oct 18 Returned to library and continued looking for relevant articles or books nothing found Sun Oct 20 Searched B I D S still no articles found Tues Oct 22 25 Got motif installed and started to examine it Mon Oct 28 Revised user interface Thurs Oct 31 32 Project Plan Commentary Brainstormed over possible implementation styles and file access methods Fri Nov 1 Started collating information and drafted project plan Found possible references in library and on the W W W Sat Nov 2 10 Expanded project plan Continued to experiment with motif 33 Project Plan Project Monitoring 1 6 Project Monitoring The project timetable is shown on the following page It gives approximate starting and completion dates for different components within the program Delays are inevitable as with all large projects although allowance has been made for these in the timetable So far the project plan has been completed on schedule 1 6 1 Dealing with Delays As previously mentioned delays are inevitable especially if modules keep failing their acceptance test Each stage has been given 25 more time than originally planned and it is hoped to have the project completed a few weeks before the dead line to allow debugging and fine tuning 34 Project Plan Project Monitoring 1 6 2 Project Monitoring Sheet weno o fof 2 ll 1
13. Save Class pMenu gt Append DELETE BRANCH Delete Branch pMenu gt Append DELETE CLASS Delete Class HPUBLIC CClassNameHolder CClassNameHolder wxPanel parent int x 1 int y 1 int w 1 int h 1 CMenuPanel parent x y w h i m pParent parent MakeClassMenu m pMenu SetData pConstDefaultDesc H PUBLIC CClassNameHolder CClassNameHolder void G wxPanel CClassNameHolder GetParent void i return m pParent JN 86 Project Report Bibliography PUBLIC void CClassNameHolder GetDims float amp w float amp h char clName CClassWindow GetParent gt GetClassName wxDC pDC GetPanelDC pDC gt GetTextExtent cIName amp w amp h PUBLIC void CClassNameHolder OnPaint void i wxDC pDC GetPanelDC pDC gt Clear int w 0 h 0 GetSize amp w amp h pDC gt DrawRectangle float 0 float 0 float w float h pDC gt DrawText CClassWindow m pParent gt GetClassName float 5 float g_SectionHeight 2 g SectionHeight 4 PUBLIC void CClassNameHolder EditData void i CEditWindow pEdit new CEditWindow NULL this Edit Class Description 100 100 400 400 pEdit gt Show TRUE H PUBLIC void CClassNameHolder SetData const char pDesc i if m pData NULL free m pData m pData strdup pDesc H Finish last line 87 Project Report 8 6 CClassWindow h SR O ggwin
14. pCode strdup pFun gt GetData Get function name char pFunName pFunName pFun gt FindFunName find position of Fun Name char ppos ppos strstr pCode pFunName copy rest of fun into tempstr char tempstr tempstr strdup ppos put end of string at ppos pCode ppos pCode 0 append classname and to pCode strcat pCode GetClassName strcat pCode concat pCode and tempstr strcat pCode tempstr write newdata fprintf pCodeFile pCode finished writing function code tidy up fprintf pCodeFile n pFun pFun gt GetNext free pFunName free pCode H fprintf pCodeFile n Finish n n n Do not delete this line finished writing function code finished writing data files finish fclose pHeaderFile fclose pCodeFile return TRUE H PUBLIC 102 Project Report Bibliography Bool CClassWindow LoadMe void FILE pHeaderFile FILE pCodeFile char pHeaderName 400 char pCodeName 400 sprintf pHeaderName s h GetClassName sprintf pCodeName s cpp GetClassName open code files if pHeaderFile fopen pHeaderName r NULL return FALSE H if pCodeFile fopen pCodeName r NULL return FALSE files are now open lets load the stuff the longest a line may be is 1K thats huge thats a loading limit char pLine 1024 s
15. pFun m_pMemberFuns while pFun NULL char pFunct pFunct strdup pFun gt GetData char pEndDecl1 char pEndDecl2 pEndDecl1 strstr pFunct pEndDecl2 strstr pFunct if pEndDecl2 NULL amp amp pEndDecl2 lt pEndDecl1 pEndDecl1 pEndDecl2 pEndDecl1 0 pEndDecl1 1 0 strip out new lines do pEndDecl1 strstr pFunct W if pEndDecl1 NULL pEndDecl1 0 while pEndDecl1 NULL print it to header file if pFun gt GetAccess PUBLIC fprintf pHeaderFile s t s n public pFunct else if pFun gt GetAccess PROTECTED fprintf pHeaderFile s t s n protected pFunct 3 else fprintf pHeaderFile s t s n private pFunct free pFunct pFun pFun gt GetNext H finished writing header file fprintf pHeaderFile n n 4th write functions to code file CMemberFunction pFun 101 Project Report Bibliography pFun m_pMemberFuns while there are member functions while pFun NULL i put start on function flag in file fprintf pCodeFile n Start n if pFun gt GetAccess PUBLIC fprintf pCodeFile n HPUBLIC n else if pFun gt GetAccess PROTECTED fprintf pCodeFile n HPROTECTED n else else private fprintf pCodeFile n PRIVATE n H copy code to instert classname in function declaration char pCode
16. update graphics CmwContents this gt GetParent gt Clear CmwContents this gt GetParent gt OnPaint CmwContents m_pParent gt SetCursor new wxCursor wxCURSOR_ARROW H HPUBLIC void CClassWindow RemoveChild CClassWindow pTemp i CRelatedList pTChild m_pChildren CClassWindow pChild pTChild gt GetClass if pChild pTemp m_pChildren m_pChildren gt GetNext pTChild gt SetNext NULL delete pTChild return 3 else while pTChild gt GetNext NULL amp amp pTChild gt GetNext gt GetClass pTemp i pTChild pTChild gt GetNext pTChild gt SetNext pTChild gt GetNext gt GetNext H HPUBLIC void CClassWindow RemoveParent CClassWindow pTemp i CRelatedList pTParent m pAdults CClassWindow pParent pTParent gt GetClass 1f pParent pTemp i 3 else m_pAdults m_pAdults gt GetNext pTParent gt SetNext NULL delete pTParent return while pTParent gt GetNext NULL amp amp pTParent gt GetNext gt GetClass pTemp 98 Project Report pTParent pTParent gt GetNext pTParent gt SetNext pTParent gt GetNext gt GetNext H HPUBLIC void CClassWindow OnPaint void i m pCNHolder gt OnPaint if m SeeMembers CMemberFunction pFun pFun m_pMemberFuns while pFun NULL pFun gt OnPaint pFun pFun gt GetNext H H PUBLIC Bool CClass W
17. 147 Bibliography Project Report Bibliography assert pTemp gt GetNext NULL pTemp gt SetNext CClassWindow CClassWindow pTemp gt GetNext gt GetNext H HPUBLIC void CmwContents CreateClass create new class and give it a name CClassWindow pTemp new CClassWindow this insert new class into list managed by frame pTemp gt SetNext m pContents m pContents pTemp pTemp gt SetFocus pTemp gt Display int dx int dy dx float 0 dy float 0 int XXX yyy CMainWindow pt CMainWindow GetParent pt gt GetSize amp xxx amp yyy ifndef wx msw pt gt SetSize xxx yyy Helse int nx ny pt gt GetPosition amp nx amp ny pt gt SetSize nx ny xxx yyy Hendif OnPaint H PUBLIC CClassWindow CmwContents GetClass char pCINameln CClassWindow pClass Bool found FALSE pClass m_pContents while pClass NULL amp amp found FALSE if 0 strcmp pCINameln pClass gt GetClassName i found TRUE yelse pClass CClassWindow pClass gt GetNext H return pClass H Finish 148 Project Report 8 28 CRelatedList h J PR PR A a ol loe od aja loe ad lle al ll all lol la al le classlist h FKK aa ol ole 2K 2K ale ale 2K le ae ale ok ifndef UNIX Hinclude lt wx prec h gt Hendif Hinclude lt wx h gt ifndef CLASSLIST H define CLASSLIST H class CClassWindow class CRelatedList i Start p
18. Guide pg 127 37 Project Plan Resworb TCL TK Virtual functions Wx Windows Glossary The name of the application It is the reverse of browser and is named such because of the way it allows the users to do the oposite of most browsers by allowing them to browse and generate classes before compilation A multiple platform scriting language used for createing Graphical User Interfaces GUIs A function which is declared in a base classes but is actually defined in a derived class A set of C modules to generate user intefaces with a number of widget sets including Motif 38 Part 2 Changes to Project Plan Project Report Changes to Project Plan Context Survey Conclusion Section 2 1 6 It is not possible to manipulate the layout of the classes in Semantic Think C This is because there is only one mouse button available which is used to display the available member functions This is often frustrating as it is often useful for the user to position the classes in different positions Editres allows the user to see the resource type while the mouse button is depressed over the name of the resource This is a novel idea and could be incorporated into a class browser where the entire function header is displayed when a mouse button is depressed over a member function Changes to Project Specifications Section 3 1 1 The Menus Creation When the system starts a new project will be opened automatically L
19. PUBLIC void CMenuPanel SetNext CMenuPanel pNext i PUBLIC CMenuPanel CMenuPanel GetNext void i CListPanel SetNext CListPanel pNext return CMenuPanel CListPanel GetNext PUBLIC void CMenuPanel OnEvent wxMouseEvent amp event 137 Bibliography Project Report Bibliography i float x y event Position amp x amp y if event RightDown amp amp g plnheritor NULL amp amp g pMover NULL PopupMenu m pMenu x y 3 else int tempx int x int tempy int y ClientToScreen amp tempx amp tempy CMvPanel m pParent gt ScreenToClient amp tempx amp tempy event x float tempx event y float tempy CMvPanel m pParent gt OnEvent event Finish last line 138 Project Report Bibliography 8 24 CMvPanel h PRM A E AEE ll Re IIE MOV GDN HEE EEA AN NANA 23 11 96 header for frame containing canvas and menus 1 for class and members Martin Bramley J RR A aa aja ajaa lle al le leal al lea aja aja ll al al leal ajaja aja ll al ll all lol alaa e ifndef MOVEPNL H define MOVEPNL H ifndef UNIX Hinclude lt wx prec h gt Hendif Hinclude lt wx h gt include CListPanel h class CMvPanel public CListPanel Start private int m XOffSet int m YOffSet Finish public CMvPanel wxPanel CMvPanel void OnEvent wxMouseEvent amp event void Move int int virtual
20. Report Project Summary this class hierarchy would be stored in memory like this Handle to all user classes Child Lists As can be seen the single pointer which points to the previously created class makes up a list of all classes where each class is only on the list once This is ideal for traversing all user classes The list pointing to class parents is necessary so that the inheritance links may be drawn while the list pointing to the classes children is necessary to test if a potential parent is already a child see section 3 4 2 56 Project Report Project Summary 3 5 Conclusion Overall the project was successful it achieved all of its primary aims and implemented some of its secondary ones The implementation has been well structured making future enhancements trivial given time With hard work Resworb may even be extended to become a complete program development tool Resworb provides a clean and simple user interface making it very pleasant and easy to use Unfortunately using wxWindows makes the graphics a little slow However Resworb is able to browse its own class hierarchy which proves its effectiveness and I certainly will continue developing future versions of Resworb and use Resworb to develop other C applications 57 Part 4 Testing Summary Project Report Testing Summary The testing had to be carried out in many stages due to the way Resworb fits together as an object oriented program mak
21. be to fully document the bug describing exactly what happens and in what circumstances it occurs The next step is to see if the bug still exists when a debug version of Resworb is ran through a debugger If this is the case then the bug may easily be tracked down T1 Project Report Maintenance Document and fixed If on the other hand the bug is no longer apparent then add comments around the code where it is suspected the bug may be and add lots of print statements which may be used to track the programs execution 7 3 4 Rebuilding amp Testing the program after Developing The version of wx Windows which was used is 1 66b this may be compiled by following the installation instructions provided with wx Windows However it was noticed that there is a bug in their code for motif pop up menus The fix may also be down loaded from the wx Windows web site Once wx Windows has been built the compilation of Resworb is trivial First edit the Makefile to point to the relevant libraries and include paths then just type make 78 Part 8 Software Listings Project Report Bibliography Contents 80 Project Report Bibliography 8 1 App Def h APPEAR HE Hee Mee eke e lll lll Hee He EE A TJ Def H ol oso ole leo ale le oe ale ie Application default settings file 21 12 96 J PR PR a od aja aja ls leal al leal al lol a aja le al aja al le all la al aja aja ll al aa a la ake ll include lt stdlib h gt inc
22. beware what come in here PUBLIC CResworbApp CResworbApp H 152 Bibliography Project Report HPUBLIC wxFrame CResworbApp Onlnit void i g pColBLACK wxTheColourDatabase gt FindColour BLACK g pColWHITE wxTheColourDatabase gt FindColour WHITE FILE pDefaultsFile char pName 1000 strcpy pName getenv HOME strcat pName resworb def if pDefaultsFile fopen pName r NULL char pLine 100 header line GetLine pDefaultsFile pLine bg colour GetLine pDefaultsFile pLine g pColBGround wxTheColourDatabase gt FindColour pLine pub col GetLine pDefaultsFile pLine g pColPublic wxTheColourDatabase gt FindColour pLine pri col GetLine pDefaultsFile pLine g pColPrivate wxTheColourDatabase gt FindColour pLine pro col GetLine pDefaultsFile pLine g pColProtected wxTheColourDatabase gt FindColour pLine font specs int fsize GetLine pDefaultsFile pLine sscanf pLine d n amp fsize GetLine pDefaultsFile pLine if strstr pLine DEFAULT NULL Bibliography g pAppFont new wxFont fsize wx DEFAULT wxNORMAL wxBOLD yelse if strstr pLine DECORATIVE NULL g pAppFont new wxFont fsize wDECORATIVE wxNORMAL wxBOLD yelse if strstr pLine ROMAN NULL g pAppFont new wxFont fsize wxROMAN wxNORMAL wxBOLD else if strstr pLin
23. both files fprintf pHeaderFile n now for include files n fprintf pCodeFile n now for include files n CRelatedList pT Adults CClassWindow pClass pT Adults m_pAdults fprintf pCodeFile include s n pHeaderName while pTAdults NULL pClass pTAdults gt GetClass fprintf pHeaderFile include s h n pClass gt GetClassName fprintf pCodeFile include s h n pClass gt GetClassName pTAdults pTAdults gt GetNext fprintf pHeaderFile Finishedincludes n fprintf pCodeFile Finishedincludes n finished writing in include files 3rd write class structure to header file CClassWindow pTemp pT Adults m_pAdults write class header and inheritance structure if pTAdults NULL fprintf pHeaderFile class s n GetClassName 3 else fprintf pHeaderFile class s n t GetClassName while pT Adults NULL 100 Project Report Bibliography pTemp pT Adults gt GetClass fprintf pHeaderFile public s pTemp gt GetClassName pT Adults pT Adults gt GetNext if pT Adults NULL fprintf pHeaderFile fprintf pHeaderFile An H finished writing header and inheritaance structure print member variables fprintf pHeaderFile Start n s n Finish n n n GetData function delcalations should go in here although not just yet CMemberFunction pFun
24. browser s inheritance tree is the simplest to understand and may be collapsed or expanded by the user The top window contains the member functions and member variables of the class The level of detail shown in this window may be changed by using the combo boxes in the toolbar It is however the bottom window which makes this browser more usable than any of the others The window contains references to where the selected member function is defined and called This is useful because when the user double clicks on one of the references the function containing the reference is brought up in an editable window The only drawbacks with this browser is that you may only browse once the application has been successfully compiled therefore any changes to a class structure may only be seen once the application has been rebuilt and there is a lot of extra disk space reguired to contain the class data mi CDoublyLinkedListEl Derived Classes and Members X o 2 Functions A All Data A All y en CMultiTreeEl CMultiTreeEl void E LMU fee CMU I TEST VOIC AGA CMultiTresEt CMultiTreeE void Re TICE CMultiTreeEl AddChild class CMultiTreeEl CMultiTreeEl AddSibling class CMultiTreeE CMultiTreeEl GetChild void CMultiTreeEl GetParent void CMultiTreeEl GetSibling void CMultiTreeEl HasChild void CMultiTreeEl HasParent void CMultiTreeEl HasSibling woid CMultiTreeEl IsRoot void CMultiTreeE
25. clutter free However there is no option to snap the user classes to a grid The program window may be resized and the inheritance pad is scrollable However the inheritance pad is only of finite size 62 Part 6 Technical Documentation Resworb User Manual Resworb User Manual Contents 65 Resworb Before You Start Reguirements This program is designed to run on the DEC Alpha Workstations in the Philip Lee laboratory at the university of St Andrews using a Colour monitor a two button mouse and keyboard It will also run on Linux machines and under Windows95 66 User Manual Using This Manual It is also assumed that the reader is familiar with C programming and the UNIX operating systems and using graphical user interfaces It is not necessary to read this manual from beginning to end however to gain a full understanding of the application a study of this manual should be made This manual has been designed as an extended example starting with installing Resworb to creating and finishing a project Typefaces used in this Manual square brackets denote optional parameters to programs Italics Italics are used for smaller sections of example code lt gt Angle brackets denote key presses on the keyboard Resworb Compiling Resworb Assuming the wx Windows library has been successfully compiled Resworb may be compiled by changing to the directory in which the Resworb code is s
26. for accessing the object which called the pop up menu The menus are not created in this class as they are created in the classes which call the menu But the function which is called after a menu event PopupFunction is here This function deciphers 75 Project Report Maintenance Document what menu event occurred using a large switch statement and then calls the relevant member function 7 2 6 Class CRelatedList A user class may contain many parents and children The parents and children of a user class are stored in a list of pointers which is implemented using the class CRelatedList 7 2 7 Class CClassWindow This is the largest and most complex class within the entire application Each object of this class maintains an entire user_class It points to its member functions member variables and all of its relations The class contains code from four modules The first part of the file contains entirely graphical code for displaying inheritance arrows function names and class names The next section of the file contains the entire graphs module which maintains the parent and child lists and it also checks for cyclic inheritance The third section contains code from the classes module which maintains the users class data The last section of the code file contains code from the files module This sections contains code to load and save the user_class 76 Project Report Maintenance Document 7 3 Guide to Further Developments
27. gt In this case the user will be prompted whether or not to discard the current inheritance pad then the user must select a project to load Importing An entire project may be imported into the current project This is useful if the user wishes to import an entire class hierarchy achieved through the file menu The drawback of this is that there is no intelligent placing and imported class may be displayed on top of current classes and imported classes with the same name as currently loaded classes will not be imported 71 User Manual Single classes may also be imported into a project When a single class is imported it is places at the top left of the screen and all its information about inheritance is lost from Resworb User Preferences The users preferences are stored in a file in the users home directory These preferences may be edited through the preferences menu The first line of the preferences file contains brief instructions on how the preferences may be changed Resworb Importing External Projects C class hierarchies which have not been created using Resworb may be viewed in Resworb with a little manipulation by the user This is best achieved by the user editing each class so that it may be imported by Resworb and then the user specifying the inheritance of the classes once in Resworb This may be done in a number of stages 1 In before each function in the code files insert H lt access permiss
28. gt RemoveClassf this PUBLIC void CClassWindow SetViewable i if m SeeMembers m SeeMembers FALSE else m SeeMembers TRUE CMemberFunction pFun pFun m_pMemberFuns 91 Project Report Bibliography while pFun NULL i pFun gt Show m SeeMembers pFun pFun gt GetNext H Display PUBLIC Bool CClass Window DeletingClass CRelatedList pTadults NULL CRelatedList pTchildren NULL CClassWindow pParent NULL CClassWindow pChild NULL add classes children to classes parents pTadults m_pAdults while pTadults NULL pParent pTadults gt GetClass pT children m_pChildren while pTchildren NULL pChild pTchildren gt GetClass pParent gt AddChild pChild pT children pTchildren gt GetNext pTadults pTadults gt GetNext pT children m_pChildren while pTchildren NULL pChild pTchildren gt GetClass pTadults m pAdults while pTadults NULL i pParent pTadults gt GetClass pChild gt AddParent pParent pTadults pTadults gt GetNext pT children pTchildren gt GetNext H pTadults m_pAdults while pTadults NULL pParent pTadults gt GetClass pParent gt RemoveChild this pTadults pTadults gt GetNext J pTchildren m pChildren while pTchildren NULL pChild pTchildren gt GetClass pChild gt RemoveParent this pTchildren pTchildren gt GetNext
29. h Hinclude CmwContents h Hinclude CMenuBar h Hinclude CClassWindow h Hinclude CEditWindow h Finishedincludes extern CClassWindow g plnheritor PUBLIC Bool CMainWindow GetClassName FILE pInFile char pOutString i int 1 C for 1 0 c fgetc pInFile amp amp feof pInFile i pOutString i char c if feof pInFile fclose pInFile cout lt lt unexpected end of file n return FALSE H pOutString i 0 return TRUE H PUBLIC CMainWindow CMainWindow wxFrame parent char title int posx int posy int height int width long style char name wxFrame parent title posx posy height width style name CData m_pContents new CmwContents this m_pContents gt OnPaint m_pMenubar new CMenuBar SetMenuBar m_pMenubar CreateStatusLine 1 CClassWindow pClassListhd CClassWindow pClass pClassListhd m_pContents gt GetContents while pClassListhd NULL pClass pClassListhd 120 Project Report pClassListhd CClassWindow pClassListhd gt GetNext delete pClass H m pContents gt SetContents NULL m pContents gt Clear PUBLIC CMainWindow CMainWindow i delete m pContents delete m pMenubar HPUBLIC void CMainWindow OnSize int x int y i wxFrame OnSize x y m pContents gt OnPaint PUBLIC int CMainWindow OnClose void what happens when a close command
30. is sent to the window hide the window wxFrame Show FALSE delete this return TRUE PUBLIC void CMainWindow OnPaint void wxFrame OnPaint m_pContents gt OnPaint PUBLIC void CMainWindow ImportClass void i char pTemp char pDir char pFileName char pClassName int pos CClassWindow pClass pTemp wxFileSelector Import a class NULL NULL NULL h if pTemp pDir strdup wxPathOnly pTemp pFileName strdup wxFileNameFromPath pTemp pClassName char malloc 2000 pos strstr pFileName h pFileName 121 Bibliography Project Report Bibliography strncpy pClassName pFileName pos pClassName pos 0 wxSetWorkingDirectory wxPathOnly pTemp pClass m_pContents gt GetClass pClassName if pClass NULL pClass new CClassWindow m_pContents pClass gt SetClassName pClassName add new class to list of maintained classes pClass gt SetNext m_pContents gt GetContents m_pContents gt SetContents pClass Load data pClass gt LoadMe set attributes of new class pClass gt Display 0 0 else wxMessageBox Class already exists Importing Error wxOK wxCENTRE H free pDir free pTemp free pFileName free pClassName H HPUBLIC void CMainWindow LoadthisProject char pTemp i CClassWindow pClass CClassWindow pRelation NULL FILE pDataF
31. le leal laaja aj al lo ale CData h EEES 26 11 96 Martin Bramley J PR PR A ao ol aja ajaa ls leal le leal laaja aj a aja lle al ajajaa a aja ll al ll all lll lo ale ifndef DATA H Hdefine DATA H ifndef UNIX Hinclude lt wx prec h gt Hendif Hinclude lt wx h gt Hinclude app def h class CData i Start protected char m_pData Finish public CData void virtual CData void free void m_pData virtual void SetData const char cout lt lt A set data not defined in super class n char GetData void ja endif 107 Bibliography Project Report 8 9 CData cpp PR PR A a ol loe od aja lle al le leal le lol al lol lol le CData cpp Ad ae ale ode fs 2K ole 2K 2k 2 26 11 96 Martin Bramley J PR PR A ol loe a aja ls leal le leal laaja lo a aja ll al aj ajaja aja ll al ll al al la al aj ale Hinclude lt wx prec h gt Hinclude lt wx h gt Hinclude lt stdlib h gt include CData h include assert h PUBLIC CData CData void i m_pData char malloc 1 PUBLIC char CData GetData void i H FFinish return m_pData last line 108 Bibliography Project Report 8 10 CEditWindow h O gt dityin h 3 kaka kak kk kkk 27 12 96header file for text window Martin Bramley E A od aj aja leal le leal al lol aj le al lle al le leal laj laj a aja ll al ll all la ake ll ifndef U
32. link to it g plnheritor pRelation pClass gt AddInheritance g plnheritor NULL fscanf pDataFile n finished reading if RetVal FALSE i wxMessageBox Loading Error Aborting Load wxOK wxFrame this m pContents gt UpdateLinks free pDir free pFileName fclose pDataFile pClass CClassWindow m pContents gt m pContents while pClass NULL pClass gt Show TRUE pClass CClassWindow pClass gt GetNext void CMainWindow LoadProject int flag char pTemp if flag 0 if FALSE DiscardEdits return 123 Project Report Bibliography 3 else if wxOK wxMessageBox Problems may a rise with duplicate file names Import Project wxOK wxCANCEL wxFrame this return H pTemp wxFileSelector Load a project NULL NULL NULL rwb if pTemp LoadthisProject pTemp H PUBLIC void CMainWindow SaveCurrent void i CClassWindow pClass CClassWindow pClassListhd FILE pDataFile char pFileName 256 char pTemp int posx posy Bool RetVal TRUE pTemp wxFileSelector Save a project NULL NULL NULL rwb if pTemp wxSetWorkingDirectory wxPathOnly pTemp sprintf pFileName s wxFileNameFromPath pTemp int namelen namelen strlen pFileName if 0 strcmp amp pFileName namelen 4 rwb sprintf pFileName s rwb pFileName if pDataFile fopen pFileName w NULL
33. lt wx h gt Hinclude lt stdlib h gt include CData h include CListPanel h include assert h int maxFrameNo 0 PUBLIC CListPanel CListPanel wxPanel pParent wxPanel wxWindow pParent 1 1 1 1 wxBORDER CData m_pNext NULL m_pParent pParent maxFrameNo maxFrameNo 1 m_ID maxFrameNo wxDC ptemp GetPanelDC ptemp gt SetFont g pAppFont m_pData char malloc 1 PUBLIC CListPanel CListPanel wxPanel pParent int x int y int w int h wxPanel wx Window pParent x y w h wxBORDER CData i m pNext NULL m pParent pParent maxFrameNo maxFrameNo 1 m ID maxFrameNo wxDC ptemp GetPanelDC ptemp gt SetFont g pAppFont m_pData char malloc 1 PUBLIC CListPanel CListPanel free void m_pData PUBLIC wxPanel CListPanel GetContainer void 117 Project Report i H PUBLIC void CListPanel SetNext CListPanel pNext i PUBLIC CListPanel CListPanel GetNext void PUBLIC int CListPanel GetID return m_pParent m_pNext pNext return m pNext return m ID PUBLIC void CListPanel GetPosition int x int y wxPanel GetPosition x y PUBLIC char CListPanel GetData void Ik return m_pData IN FFinish last line 118 Bibliography Project Report 8 16 CMainWindow h J PR PR A a ol loe od aja lea
34. plnheritor this PUBLIC void CClassWindow Cut void CClassWindow pParent while m_pAdults NULL pParent m pAdults gt GetClass pParent gt RemoveChild this this gt RemoveParent pParent m_pAdults m_pAdults gt GetNext H m pParent gt Clear CmwContents m pParent gt OnPaint PUBLIC void CClassWindow AddFunction void i CMemberFunction pTemp pTemp new CMemberFunction wxPanel this 1 1 int g WindowWidth g SectionHeight pTemp gt Move 0 m currentHeight m currentHeight m currentHeight g SectionHeight pTemp gt SetNext m pMemberFuns m pMemberFuns pTemp Display PUBLIC char CClassWindow GetClassName void i PUBLIC void CClassWindow SetClassName char pName i PUBLIC void CClassWindow ChangeClassName void return m_pClassName sprintf m_pClassName s pName char pText char msg char malloc 100 sprintf msg Class name must be less than d 96 Project Report Bibliography n characters long nand contain no spaces or s n g MaxNameLen do pText wxGetTextFromUser msg Enter Class Name GetClassName while pText NULL amp amp FALSE pText NULL amp amp strlen pText lt 32 amp amp NULL strstr pText amp amp NULL strstr pText if pText NULL SetClassName pText OnPaint Display free void msg
35. program will not be multi user and it will not support having more than one project open at a time although it will allow multiple instances of itself to be run at a time 1 3 3 2 Documentation There will be two forms of documentation supplied with the finished system one for the user and one for the maintainer The users documentation will assume an elementary knowledge of C and will emphasis the concepts behind object oriented programming whilst explaining how the application may be used There may also be some on line help The maintenance document will contain a complete listing of the heavily commented source code a document containing the concepts applied to develop the application where specific modules may be found and what they do and a list of possible enhancements with suggestions on how they may be achieved 1 3 3 3 Hardware The application will be implemented using motif or motif and C and thus it should fairly portable although it will be specifically designed to run on the computers in the Philip Lee Laboratory which are Dec Alpha 300LX Workstations with 32 megabytes of Internal RAM and 512 megabytes of internal disk space The processor is a 125MHz RISC CPU 22 Project Plan Problem Specification 1 3 3 4 Performance Constraints The application will be expected to run at a speed which will feel comfortable to the user and so the user should not be left waiting In general the system will respond in l
36. void OnPaint void void SetNext CMvPanel CMvPanel GetNext void J Hendif 139 Project Report Bibliography 8 25 CMvPanel cpp JP PEKKAA ATA ANTAA AATATAAKKKTEETT movepnl cpp EEES 23 11 96 code for frame containing canvas and menus for class and members Martin Bramley J PR PR A a ol aj ajaa ls leal le leal aja aja aja lle al le leal aja aja aja ll al ll all lol alea ale Hinclude lt string h gt Hinclude lt wx_prec h gt Hinclude lt wx h gt Hinclude CClassWindow h Hinclude CMvPanel h include CmwContents h Hinclude CMainWindow h Hinclude assert h Hinclude app def h CMvPanel g pMover NULL float dx float 1 float dy float 1 PUBLIC CMvPanel CMvPanel wxPanel pParent CListPanel pParent i a couple of hacks to deal with application bars m XOffSet 0 m_YOffSet 0 PUBLIC CMvPanel CMvPanel o PUBLIC void CMvPanel SetNext CMvPanel pNext i PUBLIC CMvPanel CMvPanel GetNext void i PUBLIC void CMvPanel Move int x int y CListPanel SetNext CListPanel pNext return CMvPanel CListPanel GetNext i if defined wx_msw amp amp Idefinedl WATCOMC wxWindow Move x y Helse hopefully allows ve positions by overriding defualt Move code 140 Project Report Bibliography this may get very nasty Widget drawingArea Widget handle Bool managed XtIsManaged bor
37. 2 midx1 x1 w1 2 midyl yl h1 2 variable for arrow heads float dx dy dz midx midy p dx p dy n dx n dy float ex1 eyl ex2 ey2 CRelatedList pList CClassWindow pChild pList m_pChildren while pList NULL i pChild pList gt GetClass pChild gt GetPosition amp x2 amp y2 pChild gt GetSize amp w2 amp h2 midx2 x2 float w2 2 midy2 y2 float h2 2 CmwContents m_pParent gt SetSolidBlackPen parent gt child CmwContents m_pParent gt DrawLine midx1 midyl midx2 midy2 now for arrows midx midx1 midx2 2 midy midyl midy2 2 dx midx1 midx2 dy midyl midy2 dz sgrt dx dx dy dy p_dx 10 dx dz p_dy 10 dy dz n_dx 5 dy dz n_dy 5 dx dz exl midx p dx n dx eyl midy p dy n dy ex2 midx p dx n_dx ey2 midy p_dy n_dy CmwContents m pParent gt DrawLine midx midy ex1 ey1 CmwContents m pParent gt DrawLine midx midy ex2 ey2 end arrow code pList pList gt GetNext H CmwContents m pParent gt SetBluePen Hifdef wx msw this gt OnPaint Hendif H 95 Project Report Bibliography PUBLIC void CClassWindow Changelnheritance void i CmwContents m pParent gt SetCursor new wxCursor wxCURSOR_CROSS CMainWindow CmwContents this gt m pParent gt GetParent gt SetStatusText Click on Class to become parent g
38. Container gt MakeFunc PROTECTED CMemberFunction menu GetContainer gt OnPaint break case MAKE PRIVATE CMemberFunction menu GetContainer gt MakeFunc PRIVATE CMemberFunction menu GetContainer gt OnPaint break default cout lt lt error anot defined yet n break H Finish 115 Project Report 8 14 CListPanel h J PR PR A ao e loe ol aja aja lle al le leal ll all lol lo ale listpnl h Ft ee ies 26 11 96 Martin Bramley J EPR A aa aj ajaa lle al le leal al lol ol lo a loe al lle al aj aj aja aja ll al ll all lol lo ale Hifndef LISTPNL H Hdefine LISTPNL H ifndef UNIX Hinclude lt wx prec h gt Hendif Hinclude lt wx h gt Hinclude CData h Hinclude app def h class CListPanel public wxPanel public CData i Start protected CListPanel m_pNext private int m_ID public wxPanel m_pParent Finish public CListPanel wxPanel CListPanel wxPanel int int int int CListPanel void GetPosition int int void SetNext CListPanel CListPanel GetNext void int GetID void wxPanel GetContainer void 3 endif 116 Bibliography Project Report Bibliography 8 15 CListPanel cpp JD PETAH AA A E AA AAA A AERA Liston cpp EEES 26 11 96 Martin Bramley J PR PR A ol loe a aja ls leal le leal laaja lo a aja ll al aj ajaja aja ll al ll al al la al aj ale Hinclude lt wx prec h gt Hinclude
39. Contents NULL return TRUE H return FALSE H PUBLIC void CMainWindow EditPrefs void FILE pDefaultsFile char pName 1000 strcpy pName getenv HOME strcat pName resworb def if pDefaultsFile fopen pName r NULL long startoffile endoffile startoffile ftell pDefaultsFile fseek pDefaultsFile 0 SEEK END endoffile ftell pDefaultsFile fseek pDefaultsFile 0 SEEK SET free void m_pData m_pData char malloc endoffile startoffile 2 fread m pData endoffile startoffile 1 pDefaultsFile fclose pDefaultsFile 3 else m pData strdup A an appdef file for resworb In 2 bgcol 3 Public 4 private 5 protected 6 fontsize 7 font nBLUE nRED nGREEN nBLUE n12 nDEFAULT n n CEditWindow pEdit new CEditWindow NULL this 125 Project Report Bibliography Edit Class Description 100 100 400 400 pEdit gt Show TRUE H PUBLIC void CMainWindow SetData const char pData i if NULL strstr pData RESWORB HELP i if m pData NULL free m pData m pData strdup pData FILE pDefaultsFile char pName 1000 strcpy pName getenv HOME strcat pName resworb def if pDefaultsFile fopen pName w NULL fwrite m_pData strlen m_pData 1 pDefaultsFile fclose pDefaultsFile H 3 else do nothing H PUBLIC void CMainWindow ShowHelp void i free voi
40. It is impossible to test the classes with all data so the implementer should examine the class and select test data which may be border line cases 1 4 4 2 Of the Program Once all the classes have been extensively tested and accepted the testing of the entire program may begin This will be tested in five stages The first stage is when the programmer tests the program entering correct data The next stage is again tested by the programmer but this time using erroneous data The rest of the test stages are by potential users Firstly they will test the program with valid test data and then again using the same erroneous data Lastly the test users will be able to use the system on their own If possible beta versions of the program may be made available for testing This will be used to allow potential users to comment on or suggest improvements for the program 31 Project Plan Commentary 1 5 Commentary 1 5 1 Project Log Tues Sept 24 Undertook the project Wed Sept 25 28 Brainstormed on ideas and possibilities Fri Oct 4 Searched Internet for related articles and similar programs Mon Oct 7 Searched for related texts in library nothing found Tues Oct 8 Sent away for demonstration software which seem to do similar Thurs Oct 10 Examined news groups for useful information Fri Oct 11 14 Wrote simple non platform specific C program and used this to review other class browsers Wed Oct 16
41. NIX Hinclude lt wx prec h gt Hendif Hinclude lt wx h gt Hifndef CEDITWIN H define CEDITWIN H Hinclude CClassWindow h class CClassWindow include CData h class CEditWindow public wxDialogBox i Start private wxFrame m_pFrame void OnSize int w int h wxButton m_pOKbutt wxButton m_pCANCELbutt public CListPanel m_pRetClass CData m_pRetClass Finish public CEditWindow wxFrame CData char int int int int CEditWindow void wxTextWindow m pTextWindow int OnClose void E endif 109 Bibliography Project Report Bibliography 8 11 CEditWindow cpp E A ao aj aja loe ad lle al le leal al leal lol ll editwin cpp EEES 27 12 96code for createing Edit window Martin Bramley PR PR A oo ol aj aja lle al le leal al lo ol aja le al lle al al leal jaja aja aja ll al al le all lol al ll include lt stdlib h gt include lt stdio h gt include lt wx_prec h gt include lt wx h gt include lt malloc h gt Hinclude app def h Hinclude CEditWindow h Hdefine OK TAG 1 define CANCEL TAG2 void buttonProc wxButton amp but wxCommandEvent amp event i long tag long but GetClientData if tag OK TAG i char buff buff char malloc g MaxDescriptionLen CEditWindow pTemp CEditWindow but GetParent buff pTemp gt m pTextWindow gt GetContents char pos pos strstr buff r n while
42. Project Report The University of St Andrews 17 April 1997 CS3015 Senior Honours Project A Computer Aided Software Engineering Tool Project Report Martin Bramley Project Report Abstract Abstract The aim of writing this project was to design and implement a graphical class hierarchy designer for the object oriented programming language C The plan covered a survey of similar tools the specifications for the implementation and the outline implementation plans The report summarises the project and its implementation Overall the project was successful resulting in a working class browser which was editable enabling users to load save and generate C class hierarchies Project Report Declaration Declaration In submitting this project to the University of St Andrews I give permission for it to be made available for use in accordance with the regulations of the University Library I also give permission for the title and abstract to be published and for copies of the report to be made and supplied at cost to any bona fide library or research worker I retain the copyright in this work Project Report Contents Contents LE PROIECT PEAN oa re NESSI 2 CHANGES TO PROJECT PLAN mmmmimmn nm nnie ana 3 PROJECT SUMMARY ci samt 4 TESTING SUMMARY conc stn Taen ESSEET EEE S eaaa SB B STATUS REPORT narra noo ooo usin io opi asa ana Ol 6 TECHNICAL DOCUMENTATION ssmmmmmsssss sos ss nonsense sssusa 63
43. Y MAINTENANCE DOCUMENT it maista mt onn mn msn 9 SOFTWARE LISTINGS 11111 TN T NL htl P CEtt Y Part 1 Project Plan The University of St Andrews 15 November 1996 CS3015 Senior Honours Project Resworb A C A S E Tool Project Plan Martin Bramley Project Plan Contents Contents N VAA Testi semmoset uesssuuunuuss 371 Project Plan Problem Definition 1 1 Problem Definition Class browsers are useful because they allow the user to see how classes are interrelated by inheritance containment or reference with one another This enables the user to see how classes interact with one another There are many class browsers available for a wide range of object oriented languages The fundamental drawback of all of these browsers is that they may only be used after the code has been compiled This is because most class browsers are actually packaged within a programming environment for example Borland C and Microsoft Developer Studio which contain its own compiler such as Borland C s BCC EXE It is within the compilation process that the browser data is generated Would it not be better to browse and even edit the class hierarchy before any code was compiled by separating the generation of this browser data from the compilation process This would allow the browsing of class data of incomplete programs A system like this would facilitate the design and implementation of other programming projects by en
44. _recth gt h m recty h m recth 12 SetBlackPen OnPaint else if event LeftUp amp amp g pMover NULL amp amp m positnew FALSE SetBluePen CClassWindow g pMover gt Display m rectx m recty float m rectw float m recth g pMover gt OnPaint ShowRect FALSE g pMover NULL OnPaint CMainWindow GetParent gt SetStatusText SetCursor new wxCursor wxCURSOR ARROW else if event RightDown i dx x dy y PopupMenu m pMenu x y 146 Project Report PUBLIC Bool CmwContents AddingNew void i return m_positnew HPUBLIC void CmwContents SetBluePen void i PUBLIC void CmwContents SetBlackPen void i PUBLIC void CmwContents SetSolidBlackPen void SetPen m pBluePen SetPen m pBlackPen SetPen m pSolidBlackPen HPUBLIC void CmwContents SetRect int x int y int w int h i m rectx x m recty y m rectw w m recth h PUBLIC void CmwContents ShowRect Bool flag PUBLIC void CmwContents RemoveClass CClassWindow pClass m_ShowRect flag CClassWindow pTemp pTemp m_pContents if pTemp pClass i m pContents CClassWindow m_pContents gt GetNext return 3 else while CClassWindow pTemp gt GetNext pClass amp amp CClassWindow pTemp gt GetNext NULL pTemp CClassWindow pTemp gt GetNext
45. a aja ll al ll all la ake ll ifndef UNIX Hinclude lt wx prec h gt Hendif Hinclude lt wx h gt Hinclude app def h Hifndef CMEMBERFUNCT H define CMEMBERFUNCT H include CMenuPanel h Hinclude CClassWindow h class CMemberFunction public CMenuPanel i Start private CMemberFunction m_pNext wxPanel m_pParent char m_pFunctName char m_pCode int m_Access Finish public CMemberFunction wxPanel int int int int CMemberFunction void char FindFunName void wxPanel GetContainer void void EditFunction void void OnPaint void CMemberFunction GetNext void SetNext CMemberFunction void GetDims float amp float amp char GetFunctionName void void SetData const char void MakeFunc int int Get Access void endif 128 Bibliography Project Report Bibliography 8 19 CMemberFunction cpp Paria AA AKK AAKKKEER Jn MeCpp EEES 10 02 97 code for managing member functs and display Martin Bramley J PR PR A aa ol loe od ls oe ad lle al le leal al lol a aja le al aja aj aja aja aja ll al ll all lol ake ll Hinclude lt stdlib h gt include lt stdio h gt Hinclude lt string h gt Hinclude lt wx prec h gt Hinclude lt wx h gt Hinclude CClassWindow h Hinclude CMemberFunction h include CEditWindow h const char pConstFunct void NoName void n n Enter Code as usual except comments must n be with in the functi
46. abling the programmer to visually interact with their code on a class basis This would allow the programmer to construct a class hierarchy in similar method to that of constructing a cloud diagram For example the following diagram fig 1 would be easier to understand than a lot of code separated into a number of modules Class CDoublyLinkedListEl CCDoublyLinkedListEl m pNextElement CCDoublyLinkedListEl m pPrevElement Shows a possible class functs inheritance hierarch y CCDoublyLinkedListEl GetNextElement CCDoublyLinkedListEl GetPrevElement Figure 1 CCTreeEl m pChildList functs AddChild CTreeEl int m Opriority functs Insert CPriorityQueueEl Class CDirectoryStructureEl Class COueueEI functs CQueueEl GetNext Add CQueueEl char m_pFilename functs char GetFilename Project Plan Context Survey 1 2 Context Survey 1 2 1 Reviewed Software After reviewing a few software packages which contain class browsers it became apparent that the majority of them were post compilation browsers which made the class browsers non editable After extensive research on the Internet it was concluded that there are two browsers which work before compilation These were Relational Rose and Visual Thought Unfortunately demonstration packages were not available to be evaluated The post compilation packages surveyed were MetroWerks CodeWarrior Semantic Think C Borland C and Microsoft Developer S
47. addressed once unless multiple inheritance is used 53 Project Report Project Summary File Prefences c1ass_2 If class 2 required to inherit class 1 then class 2 will ask all of its descendants if they are class 1 In doing this class 6 will be asked twice and class 7 will be asked 3 times It was also at this time that a contemporary suggested banning multiple inheritance as they claimed it was rarely used properly and causes many problems However multiple inheritance has been used in creating this browser and so it should be available to its users 54 Project Report Project Summary 3 4 3 Storing the users hierarchy The user class hierarchy is very similar to a non cyclic directed graph So for example This is valid And this is not because it contains a cycle The user classes are similar to the nodes on the graph except user classes also store data about their member variables and member functions For each user class to keep track of its parents and its children lists of pointers are used Each user class maintains two lists and one pointer The first list contains pointers to all of the class children the second list contains pointers to all of the class parents and the pointer points to the previously created user_class so that all classes may be easy accessed without performing a complicated traversal For example File Prefences crassa fetase 1 crasse enass a crass 5 55 Project
48. anel h class CClassNameHolder public CMenuPanel Start private wxPanel m_pParent Finish public CClassNameHolder wxPanel int int int int CClassNameHolder void wxPanel GetParent void void GetDims float amp float amp void OnPaint void void EditData void void SetData const char 3 endif 85 Bibliography Project Report Bibliography 8 5 CClassNameHolder cpp Parodias C name cpp EEES 23 11 96 code for managing class names bindings and display Martin Bramley J PR PR A aa ol ls oe od loe al leal al lea ajaja aja le al lle al aj aja aja aja ll al ll all lol ll include lt stdlib h gt include lt stdio h gt include lt string h gt include lt wx_prec h gt include lt wx h gt include CClassWindow h include CClassNameHolder h include CEditWindow h const char pConstDefaultDesc Default Class Description n Maximum length is 512 charaxters n void MakeClassMenu CLinkedMenu pMenu i pMenu gt Append VIEW MEMBERS Show Hide Member Functions pMenu gt Append ADD FUNCTION Add Member Function pMenu gt Append ADD VARIABLE Edit Member Variables pMenu gt AppendSeparator pMenu gt Append EDIT NAME Edit Class Name pMenu gt Append EDIT DESC Edit Class Description pMenu gt Append ADD PARENT Add Parent pMenu gt Append CUT Separate pMenu gt AppendSeparator pMenu gt Append SAVE CLASS
49. ater the user may wish to discard the current project and start afresh this is achieved by the user selecting the new menu option The user will then be prompted for confirmation of discarding current edits after which a blank Inheritance pad will be created N B the default base class has now been removed Loading a Project Loading a project will be as before except now the user selects a project file rather than a directory This allows multiple projects to co exist in a single directory although care will have to be taken as to not inadvertently replace files in non open projects Saving a Project Because of the changes in the creation of projects the previous save menu option has been discarded and the save as menu option has been renamed to save This is because when a new project is created the user is no longer prompted for a project name When a project is saved two files will be saved for each class a C header file and a C code file These files will contain structured comments which enables the files to 40 Project Report Changes to Project Plan be loaded Also the single binary file is now a structured ASCII file This allows the user to edit the file if wished Importing A new menu option will be available to import classes from other projects When the user selects the import menu option the user will be prompted to select the header file of the class to import After which a class will be created for the given fi
50. button Editing Classes Once the user has created the class properties may be assigned to the class The first thing the user will wish to change is the class name This is achieved moving the mouse pointer over the class name and then depressing the right mouse button to display a pop up menu The user may then select the Edit class name option After which a message box will be displayed prompting for the user to enter the new class name Following this the user may wish to give the class a description This also is achieved in a similar manor 69 User Manual Member Functions Member functions may be added to by selecting the add member function option from the pop up menu when the right mouse button is depressed over the class name To delete member functions depress the right mouse button over the function to be removed and select the delete option In the same way the member access control may be specified When editing functions it is important to remember three things 1 The function definition must be on the first line 2 Pointers to functions may not be returned unless by using typedefs 3 Do insert the class name in the function definition Resworb will do it for you Resworb Inheritance When user wishes to inherit the properties of one class into another the user It is achieved by the user bringing up the pop up menu over the class name and selecting the add parent option The mouse pointer will then
51. change into a cross hair until a valid parent class has been selected Removing inheritance is achieved in much the same way except that all of the class inheritance is removed Deleting Classes Deleting classes should be done with care as there is no undo option available There are two forms of delete The first deletes the current class and all child classes delete branch The second just deletes the current class and makes the current class children point to the current class parent if one exists 70 User Manual Saving There are two forms of saving the first is the saving of the current project and the second is the saving of the current class To save the current project the user selects the save option from the file menu or the user can press lt Control S gt In both cases a dialog box will appear prompting the user to enter the name of the project and the directory in which it is to be stored N B care must be taken here as existing file in the same directory may be over wrote if the files are the same name as a class To store just a single class simple select the save option from the class names pop up menu The class is then saved to the current directory Resworb Loading A project may be loaded in two ways The first is by specifying the project as a command line parameter when starting Resworb and the second is by using the oad option from the file menu also accessed by pressing lt Control L
52. d m pData m pData strdup WtRESWORB HELP n tDO NOT CHANGE THE ABOVE LINE Mn Loading and Saving Projects n tjust use the file menus or the n tassociated short cuts n nUsing the mouse n tLeft Button Drag Class n tMiddle Button Does Nothing n tRight Button Context Menun CEditWindow pEdit new CEditWindow NULL this Edit Class Description 50 50 500 500 pEdit gt Show TRUE PUBLIC void CMainWindow OnMenuCommand int id switch id i case EDIT PREFS EditPrefs break case LOAD PROJECT LoadProject 0 break case SAVE PROJECT SaveCurrent break case NEW PROJECT DiscardEdits break 126 Project Report Bibliography case IMPORT CLASS ImportClass break case IMPORT PROJECT LoadProject 1 break case OUIT RESWORB if wxOK wxMessageBox Ouit without Saving Quit Resworb wxOK wxCANCEL wxFrame this OnClose break case ABOUT RESWORB wxMessageBox Resworb n A Graphical class Browser AND generator n By Martin Bramley Feb 1997 About Resworb wxOK wxCENTRE break case SHOW_HELP ShowHelp break default break H Finish a few extra lines 127 Project Report 8 18 CMemberFunction h J PR PR aa eaa a aja eaa ea alakaa er fun h AA k ak a ak k ak akak akk akk 10 02 97 code for managing member functs and display Martin Bramley J PR PR A oo ol aj aja lle all leal lo al aja le al ll al aj laj aj
53. d by the end of this stage the implementer should know all the whats of the problem This is achieved by generating uses cases A uses case specifies a relationship between two entities for example a footballer owns football boots Once all these uses cases have been generated they are split down using interaction diagrams helping express the functionality captured For example Footballer scores goal footballer selects angle footballer kicks ball Ball moves Ball Stops Does Goal contain Ball The differing levels of indentation signify different entities It is now obvious that these real world entities which have interactions may also be modelled as classes within an object oriented model 15 Project Plan Context Survey The second stage of the technigue is used to specify which entities must exist if another object exists and the last stage is to implement the classes 16 Project Plan Context Survey 1 2 2 1 Conclusion Both technigues have their advantages and disadvantages The Booch technigue unfortunately has a very large set of symbols which may confuse matters but by having this large set of symbols it is possible to generate the ideal abstraction and then to directly translate the symbols within the abstraction to working code The bonus of the first technigue must be its simplicity There is a adaptation of this system which closely allows the code to evolve more than be designed This is achieved by implementi
54. depending on the class for which the data is for for example extracting the function name 52 Project Report Project Summary 3 4 2 User Inheritance The original plan was to give the user as much freedom as possible by doing little or no sanity checking It later became apparent that the browser could become very confused if there were no restrictions on inheritance when it came to inheritance tree traversal The first step was to disallow cyclic inheritance This was achieved by getting the potential child to ask all of its off spring if the potential parent is an offspring of the child Here is the section of code which was devised to do just this Bool CClassWindow IsChild CClassWindow pSearch i CRelatedList pTchildren CClassWindow pChild Bool ret FALSE pTchildren m_pChildren while pTchildren NULL amp amp ret FALSE i pChild pTchildren gt GetClass if pChild pSearch return TRUE ret pChild gt IsChild pSearch pT children pTchildren gt GetNext i return ret In essence this algorithm steps along its list of children asking the question Are you the potential parent If the answer in negative then the child asks all of its children the same question recursively until there are no more children or a positive answer is given For a fuller explanation see section 3 4 3 The complexity of this is approximately O n where n is the number of user_classes as each class is only
55. derWidget borderWidget scrolledWindow endif if managed XtUnmanageChild borderWidget borderWidget scrolledWindow XtVaSetValues drawingArea XmNresizePolicy XmRESIZE ANY NULL XtVaSetValues borderWidget borderWidget scrolledWindow XmNx x XmNy y NULL if managed XtManageChild borderWidget borderWidget scrolledWindow XtVaSetValues drawingArea XmNresizePolicy XmRESIZE NONE NULL PUBLIC void CMvPanel OnEvent wxMouseEvent amp event FFinish static float x y event Position amp x amp y if event LeftDown g pMover this int tx ty tx int x ty int y ClientToScreen amp tx amp ty m pParent gt ScreenToClient amp tx amp ty CmwContents m pParent gt SetCursor new wxCursor wxCURSOR CROSS int x2 y2 h w GetPosition amp x2 amp y2 GetSize amp w amp h CmwContents m pParent gt SetRect x2 y2 w h CmwContents m pParent gt ShowRect TRUE dx float tx x2 dy float ty y2 CMainWindow CmwContents else last line m_pParent gt GetParent gt SetStatusText Moving Class int tx int x int ty int y ClientToScreen amp tx amp ty m_pParent gt ScreenToClient amp tx amp ty event x float tx event y float ty m_pParent gt OnEvent event 141 Project Report 8 26 CmwContents h J PR PR A a ol loe od aja lo
56. directly portable to Microsoft windows and use the standard Microsoft user interface secondly it might become confusing for the user if all the mouse buttons were used It may however be possible for the user to 41 Project Report Changes to Project Plan specify the action of the middle mouse button using an X11 resource file optional utilities like this will only be implemented time permitting Section 3 3 5 Error Handling and Extreme Conditions In addition to the other types of errors previously mentioned the user may also have errors in the code the user enters in the user member functions Although it is possible to implement a code analyser for this code it would be by no means an easy task A possible solution would be to compile the class each time the user changes some aspect of it and then display the results This however could prove to be unacceptably slow and so will not be implemented 42 Project Report Contents Project Report Contents 43 Part 3 Project Summary Project Report Project Summary 3 1 Aims and Achievements The aim in producing Resworb is to provide experienced object oriented programmers with an interactive tool which facilitates the design and implementation of C class hierarchies The main idea is that programmers should be able to graphically create manipulate and edit C classes This tool proves to be useful in the first stages of implementing medium to large programming project
57. e SCRIPT NULL g pAppFont new wxFont fsize wxSCRIPT wxNORMAL wxBOLD else if strstr pLine SWISS NULL g pAppFont new wxFont fsize wxSWISS wxNORMAL wxBOLD 3 else f g pAppFont new wxFont fsize wMODERN wxNORMAL wxBOLD finihsed fclose pDefaultsFile 153 Project Report Bibliography 3 else cout lt lt no resworb def file found using defaults n g pColBGround wxTheColourDatabase gt FindColour YELLOW g pColPublic wxTheColourDatabase gt FindColour RED g pColPrivate wxTheColourDatabase gt FindColour BLUE g pColProtected wxTheColourDatabase gt FindColour GREEN g pAppFont new wxFont 10 wx MODERN wxNORMAL wxBOLD H create Application window m_pApp Window new CMainWindow NULL resworB Browser 0 0 600 600 wxDEFAULT FRAME resworb display created window m_pAppWindow gt Show TRUE m_pAppWindow gt wx Window SetSize 600 600 if arge 2 m_pAppWindow gt LoadthisProject argv 1 m_pAppWindow gt OnPaint return application window so that 1t may be managed return m pAppWindow FFinish a few lines 154 Project Report Bibliography 8 32 Makefile Program name PROGRAM resworb H Which compiler you want CXX g CC gcc Uncomment this line for debugging support DEBUG g Wall Uncomment this line for normal optimisation DEBUG 02 These lines set up includes and l
58. e ad lle al le leal al lo al lol al ll mwcont h EEES N 24 12 96header file for stuff in main window Martin Bramley PR PR A ol aj ls oe ad lle all leal leo al aj aja lle al aj aja aja ajaa ll al ll all lol ake ll ifndef MWCONT H define MWCONT H ifndef UNIX Hinclude lt wx prec h gt Hendif Hinclude lt wx h gt include CClassWindow h include CLinkedMenu h class CmwContents public wxPanel i Start private wxPen m_pBluePen wxPen m_pBlackPen wxPen m_pSolidBlackPen CLinkedMenu m_pMenu int m_rectx m_recty m_rectw m_recth Bool m_ShowRect Bool m_positnew public CClassWindow m_pContents Finish public CmwContents wxFrame CClassWindow GetContents void CClassWindow GetClass char void SetContents CClassWindow virtual CmwContents void CClassWindow GetFrames void void OnPaint void void OnEvent wxMouseEvent amp event void ShowRect Bool void SetRect int int int int void OnScroll wxCommandEvent amp Bool AddingNew void SetBluePen void void SetSolidBlackPen void void SetBlackPen void void UpdateLinks void void RemoveClass CClassWindow void CreateClass 3 endif 142 Bibliography Project Report 8 27 CmwContents cpp J PR PR A a ol ajaja aja loe al lle al le leal al la al lol ll mwcont cpp EEES 24 12 96code stuff in main window Martin Bramley PR PR A aa e aj aja lle al al leal lol aja le al
59. e displayed and what classes does each class inherit from Also addressed at the design stage was the problem of how to find the balance between using structured comments and code analysing Too many structured comments would make it difficult for a user to hack conversely too few comments would make code analysis necessary which is extremely complicated A balance was found where the definition of member variables were stored between two structured comments and a structured flag between each member function This meant that the only code analysis necessary was to extract the name of a function out of its declaration 46 Project Report Project Summary 3 2 3 User Extensions The browser has been implemented using motif and so it may be possible for the user to change the user interface and add extra functionality by using motif resource files Unfortunately this option was not implemented due to time constraints 47 Project Report Project Summary 3 3 The user interface 3 3 1 Project Space On start up a new project space is created This is a large sub window in which the user may create and view their classes The original intention was to create a project space of variable size where the size would be dynamically adjusted as more space for the users project was reguired Unfortunately dynamic resizing is not possible under wx Windows and the maximum size of a panel is the size of the screen This causes problems when user c
60. e intersection between the line and the class window The drawing of the arrowheads was also by no means trivial as complicated mathematical functions should be avoided in freguently called functions Although the arrowheads could have been simply implemented using such functions a more complicated option was used involving Pythagoras theorem Another problem which had to be addressed was how do programmers perceive inheritance and in which direction do they program i e do they make the super class first and then the sub classes which the super class inherits or visa versa When specifying inheritance the browser expects parents sub classes to be added to children super classes It would be preferable to have both options available but this is not possible due to the way the inheritance tree is traversed 49 Project Report Project Summary 3 3 5 Editing Member Variables When a user specifies that they want to edit the member variables all the member variables are loaded into an edit window The user may then use this window to add remove or change access permissions of member variables When the user selects OK the edit window is closed and the member variables for the class are updated from the new contents of the edit window The contents of the window are not checked for errors as this may be extremely complicated Member variables are by default private unless otherwise stated 3 3 6 Member Functions Fach time a member
61. eal aj a aj 6 al lle al aj laaja aja aja ll al ll all lol ake ll Hinclude lt wx prec h gt Hinclude lt wx h gt Hinclude CClassWindow h Hinclude CLinkedMenu h Hinclude app def h include CmwContents h PUBLIC CLinkedMenu CLinkedMenu wxPanel parent wxMenu NULL wxFunction PopupFunction i SetContainer parent PUBLIC CLinkedMenu CLinkedMenu i SetContainer NULL H PUBLIC void CLinkedMenu SetContainer wxPanel pParent i m pParentFrame pParent PUBLIC wxPanel CLinkedMenu GetContainer void i return m pParentFrame void PopupFunction CLinkedMenu amp menu wxCommandEvent amp event switch event commandInt i case VIEW MEMBERS CClassWindow CClassNameHolder menu GetContainer gt GetParent gt SetViewable break case NEW BASE CLASS CmwContents menu GetContainer gt CreateClass break case ADD VARIABLE 113 Project Report Bibliography CClassWindow CClassNameHolder menu GetContainer gt GetParent gt EditMembers break case EDIT NAME CClassWindow CClassNameHolder menu GetContainer gt GetParent gt ChangeClassName break case EDIT DESC CClassNameHolder menu GetContainer gt EditData break case EDIT FUNCTION CMemberFunction menu GetContainer gt EditFunction break case ADD FUNCTION CClassWindow CClassNameHolder menu GetContainer gt GetPa
62. ed class A feasible solution to this bug would be to stop using context sensitive menus to create user classes The creation of new classes could then be achieved by using double mouse clicks 48 Project Report Project Summary 3 3 3 Short Cuts There are short cuts available for all items on the file menu It would have been good to avoid having to use the context sensitive menu to do common operations such as creating a class in the project window or editing a member function while a double click on the mouse should suffice This does not seem possible as motif captures double click events as two single clicks 3 3 4 Inheritance Arrows To show inheritance within a class hierarchy it was concluded that arrows should be used between the parent class and the child class This seems confusing to many people as to which way the arrow should point One suggested solution was to place a visible reminder within the program however this was not implemented because a new sub window would have to be created to display this and in doing so the G U I would become unbalanced and so less aesthetically pleasing To rectify this would take a long time as the entire graphical user interface would have to be rewritten due to time constraints this has not been implemented Another problem which arose was the positioning of the arrowheads It was decided that positioning the arrowheads in the middle of the line would be far easier than calculating th
63. ed loading now close the files fclose pHeaderFile fclose pCodeFile free pLine return TRUE PUBLIC int CClassWindow GetParentList char pOutList int number 0 CRelatedList pT Adults CClassWindow pClass pT Adults m pAdults set outlist to be initially empty pOutList 0 0 while pT Adults NULL i number pClass pT Adults gt GetClass sprintf pOutList s s pOutList pClass gt GetClassName pT Adults pTAdults gt GetNext H sprintf pOutList s pOutList return number PUBLIC int CClassWindow GetChildList char pOutList int number 0 CRelatedList pTChildren pT Children m_pChildren CClassWindow pClass set outlist to be initially empty pOutList 0 0 while pTChildren NULL i number pClass pTChildren gt GetClass sprintf pOutList s s pOutList pClass gt GetClassName pT Children pTChildren gt GetNext H sprintf pOutList s pOutList return number 105 Project Report PUBLIC void CClassWindow EditMembers void CEditWindow pEdit new CEditWindow NULL this Edit Member Function 100 100 400 400 pEdit gt Show TRUE PUBLIC void CClassWindow SetData const char pDesc i if m pData NULL free m pData m pData strdup pDesc FFinish last line 106 Bibliography Project Report 8 8 CData h J PR PR A a ol lol aja aja lle al
64. eously i e when a corner was encountered The forth stage used a class which was larger than the window so that one part of the class window must be off the viewable inheritance pad The final stage of the test was to get other people to test drag and drop After all the modules had been implemented the entire project needed to be tested exhaustively this was achieved by using Resworb to create load and save projects The most complete of these tests was to load the source code for Resworb into Resworb allowing the projects class hierarchy to be viewed 59 Part 5 Status Report Project Report Status Report The current state of Resworb is that all of the specified functions work although possible not in the same way as specified in the plans functional reguirements section 1 3 1 However none of the possible modifications stated in the project plan have been implemented due to lack of time However importing functions have been added Creating User Classes The user may create or import classes into the current project Editing User Classes Member Functions Member functions may be added and deleted from user classes They may not be copied between classes A restriction with member functions is that the function declaration must be the first line of the function in the edit window and the member function may not return pointers to functions unless achieved using either defines or typedefs Editing member variables Me
65. ess than three seconds unless the computer is busy on another task Exceptions to this will be starting loading and saving processes in which large amounts of data is being manipulated The finished application will only be capable of having one project open at a time In addition the graphics pad may be of finite size 1 3 3 5 Error Handling and Extreme Conditions There are three classes of errors environmental errors application errors and user errors Environmental errors are errors which occur due to no fault of the application or the user for example poorly set up environment paths lack of space on the file system or a bad network connection In general it will be hoped that the application will catch most of these errors and report back to the user However this can not be guaranteed due to the wide range of possible errors Application errors are errors in the application itself due to poor implementation In implementing the project a very defensive stance will be taken with two levels of assertion catching debug asserts and release asserts The implementer should use debug asserts whenever a decision within the program is made When a debug assert fails the user should be alerted to the nature of the assertion failure and where it happened These asserts should be changed to release asserts in the release version The second type of assertion is a release assertion These assertions should be used when anything potentially di
66. ext void i PUBLIC wxPanel CMemberFunction GetContainer void i H PUBLIC void CMemberFunction SetNext CMemberFunction pNext i PUBLIC void CMemberFunction SetData const char pDesc return m pNext return m pParent m pNext pNext if m pData NULL free m pData m pData strdup pDesc m pFunctName FindFunName CClassWindow m pParent gt Display 131 Project Report HPUBLIC void CMemberFunction MakeFunc int access i PUBLIC int CMemberFunction GetAccess void i H FFinish m_Access access return m_Access last line 132 Bibliography Project Report 8 20 CMenuBar h J PR PR A AR HR e lol aja aja le al lle al al leaf lll RR p eny Ja HAA al lea k ak kk kk k N 21 12 96 header file for main window menus Martin Bramley J PR PR A a ol aj aja ls leal le leal laaja aja lo al ll al ajaja ajaja aja ll al ll all la ake ll ifndef UNIX Hinclude lt wx_prec h gt Hendif Hinclude lt wx h gt ifndef MENU H define MENU H class CMenuBar public wxMenuBar Start no mem vars Finish public CMenuBar void CMenuBar void 35 endif 133 Bibliography Project Report Bibliography 8 21 CMenuBar cpp PRP RIE ANTA ll e A ETE MEN CDP EEES N 21 12 96code for main window menus Martin Bramley J PR PR A ol aj ls oe ad lle al le leal laaja aja le al lle al
67. function is committed after editing the function name is extracted so that it may be displayed in the class window The extraction of the function name from the function body can be very complicated and one restriction is that pointers to functions may not be returned as the procedure which extracts the function names will not accept spaces or braces in return types However it is possible to get around this problem by using typedefs to define the return type This however is not too great a restriction as returning functions are rarely used and even sometimes discouraged 3 3 7 Separating When a class is separated it is disconnected from all of its parents this allows its and its children s inheritance to be redefined This is often useful as it permits new classes to be inserted into an existing inheritance tree 3 3 8 Response Times A common complaint is that screen updates are slow especially when scrolling This is due to wx Windows the object oriented extension of motif wx Windows was chosen as the toolkit to use while implementing the user interface primarily because it is extremely portable between operating systems and widget sets This enables Resworb to theoretically compile under most UNIX operating systems including Linux using motif or XView as the widget sets making its portability an advantage 50 Project Report Project Summary Resworb would also compile on PC s using Microsoft Windows 95 In retrospect the
68. ght 2 now free the buffer memory free void buff m_pContents NULL SetScrollbars 20 20 50 50 4 4 SetScrollRange wx HORIZONTAL 100 SetScrollRange wx VERTICAL 100 EnableScrolling TRUE TRUE m positnew FALSE m pMenu new CLinkedMenu this m pMenu gt Append NEW BASE CLASS New Class OnPaint HPUBLIC CmwContents CmwContents void i CClassWindow temp while m pContents NULL temp CClassWindow m pContents gt GetNext m pContents gt SetNext NULL delete m pContents m pContents temp H HPUBLIC CClassWindow CmwContents GetContents void return m_pContents HPUBLIC void CmwContents SetContents CClassWindow pClass m_pContents pClass H HPUBLIC void CmwContents UpdateLinks void CClassWindow pClass m_pContents int x y int w h while pClass NULL i 144 Project Report Bibliography pClass gt GetPosition amp x amp y pClass gt GetSize amp w amp h pClass gt UpdateChildLinks x y float w float h pClass CClassWindow pClass gt GetNext PUBLIC void CmwContents OnScroll wxCommandEvent amp event CClassWindow pTemp int xmov 1 ymov 1 int x y GetVirtualSize amp x amp y xmov x GetScrollRange wxHORIZONTAL ymov y GetScrollRange wx VERTICAL static int prevx 0 prevy 0 int XOffset 0 int YOffset 0 if event extraLong wxHORIZONTAL XOffset xm
69. h EPR aak ak ak kak kak kk kk k 23 11 96 code for managing class names bindings and display Martin Bramley PR PR A oo ol aja aja lle al le leal al lo aja aja lle al aj ajaja aja ll al ll all la ake ll ifndef UNIX Hinclude lt wx prec h gt Hendif Hinclude lt wx h gt include lt stdlib h gt ifndef CLASSWINDOW_H define CLASSWINDOW_H Hinclude app def h Hinclude CMvPanel h Hinclude CClassNameHolder h Hinclude CMemberFunction h Hinclude CRelatedList h class CClassWindow public CMvPanel i Start private char m_pClassName int m_currentHeight CMemberFunction m_pMemberFuns CRelatedList m pAdults CRelatedList m pChildren public CClassNameHolder m pCNHolder Bool m SeeMembers Finish public CClassWindow wxPanel CClassWindow void void Display int int float float void Display int int void Display void void OnPaint void void UpdateChildLinks int int float float void AddFunction void char GetClassName void void ChangeClassName void void CreateChild void void SetClassName char void NewClass void void AddParent CClassWindow void AddChild CClassWindow void RemoveParent CClassWindow void RemoveChild CClassWindow 88 Bibliography Project Report 1 endif Bool DeletingClass void Bool DeletingTree void void DeleteFunction CMemberFunction void RecursiveDelete CClassW
70. he generated resource files to add their own menus and functions The underlying language which will be used to implement the application will be C because the nature of the application being implemented is very object based and 1 feel that an object oriented language will prove to make its implementation easier To enable ease of future maintenance an adaptation of the Hungarian notation will be used throughout the applications code The drawback with Hungarian notation is that it names variables with regard to what they are whereas most programmers would prefer to name variables by what they do The adaptation uses an abbreviated form of Hungarian notation to let the user know what he is dealing with and the rest of the name will be used to describe the purpose of the variable Due to the nature of object oriented design it is possible to separate the program into distinct modules However because the user is generating classes and the application will contain classes there is a chance this report may become unclear Anything the 25 Project Plan Implementation and Testing Plans user generates i e classes and code will be referred to as user classes and user code and anything which is part of the program s implementation will be referred to as program classes and program code 1 4 2 The user interface Within Editres it seems although this is not certain that each resource is actually a button The implementation of thi
71. hould rd member variables section of header file here repeat untill FSTART do GetLine pHeaderFile pLine while NULL strstr pLine Start long startofmems endofmems startofmems ftell pHeaderFile do GetLine pHeaderFile pLine while NULL strstr pLine Finish endofmems ftell pHeaderFile fseek pHeaderFile startofmems SEEK SET char pMemVars create block to put member variables in pMemVars char malloc endofmems startofmems rd variables pMemVars 0 0 GetLine pHeaderFile pLine do strcat pMemVars pLine strcat pMemVars n GetLine pHeaderFile pLine while NULL strstr pLine Finish SetData pMemVars free pMemVars finished loading member variables Now starting to load member functions skip over includes and other stuff until 1st funct or eof flag is encountered repeat until Start or Finish 103 Project Report Bibliography do GetLine pCodeFile pLine while FALSE FlagFound pLine continue rding funcs until eof flag is found while 0 stremp pLine Finish i now create item to hold function in CMemberFunction pTemp pTemp new CMemberFunction wxPanel this 1 1 int _WindowWidth g SectionHeight pTemp gt Move 0 m currentHeight m currentHeight m currentHeight g SectionHeight pTemp gt SetNext m pMemberFuns m pMemberFuns pTemp
72. i wxMessageBox Saving Error Killing Resworb wxOK wxFrame this OnClose pClassListhd m_pContents gt GetContents while pClassListhd NULL amp amp RetVal pClass pClassListhd pClassListhd CClassWindow pClassListhd gt GetNext RetVal pClass gt SaveMe write class name fprintf pDataFile s pClass gt GetClassName write position pClass gt GetPosition amp posx amp posy fprintf pDataFile d d posx posy write children getnumber of Children and string char pList pList char malloc 1024 40 int num pClass gt GetChildList pList fprintf pDataFile d s n num pList free pList end of datafile saving if RetVal FALSE i wxMessageBox Saving Error Killing Resworb 124 Project Report Bibliography wxOK wxFrame this OnClose H fclose pDataFile PUBLIC Bool CMainWindow DiscardEdits void CClassWindow pClassListhd CClassWindow pClass if NULL m pContents gt GetContents i m pContents gt Clear m pContents gt SetContents NULL return TRUE if wxOK wxMessageBox discard current project New Project wxOK wxCANCEL wxFrame this i pClassListhd m pContents gt GetContents while pClassListhd NULL i pClass pClassListhd pClassListhd CClassWindow pClassListhd gt GetNext delete pClass H m pContents gt Clear m pContents gt Set
73. ibraries You will probably need to change them INCLUDE I wx include base I wx include x LIBRARIES L user sh common lib L wx lib wx lib libwx_motif a 1Xm IXt 1X11 lcurses Im H You shouldn t need to change anything beyond here CFLAGS DEBUG Dwx motif DDEBUG 0 OBJS assert o CClassNameHolder o CListPanel o CMenuPanel o mwContents o ClassWindow o MainWindow o MvPanel o EditWindow o MemberFunction o RelatedList o LinkedMenu o CMenuBar o CResworbApp o CData o C C C C C C C C all S PROGRAM shared OBJS CXX o PROGRAM OBJS user sh common lib libwx_motif sa L user sh common lib L lib IXmu lwx_motif IXm 1Xt 1X11 Icurses Im PROGRAM OBJS CXX o S PROGRAM OBJS LIBRARIES 155 Project Report Bibliography clean purge RM f o S PROGRAM purge RM f depend CC M INCLUDE CFLAGS echo OBJS sed e s 0 cpp g gt depends mk include depends mk 0 cpp CXX CFLAGS INCLUDE c lt 156
74. ile char pFileName char pClassName 32 int posx posy Bool RetVal TRUE char pDir pDir strdup wxPathOnly pTemp pFileName strdup wxFileNameFromPath pTemp wxSetWorkingDirectory wxPathOnly pTemp if pDataFile fopen pFileName r NULL wxMessageBox Loading Error Aborting Load wxOK wxFrame this return while feof pDataFile amp amp RetVal RetVal GetClassName pDataFile pClassName fscanf pDataFile d d amp posx amp posy create new class pClass m_pContents gt GetClass pClassName 122 Project Report Bibliography 1 PUBLIC if pClass NULL pClass new CClassWindow m_pContents pClass gt SetClassName pClassName add new class to list of maintained classes pClass gt SetNext m_pContents gt GetContents m_pContents gt SetContents pClass pClass gt Show FALSE Load data pClass gt LoadMe set attributes of new class pClass gt Display posx posy rd Child Line int num counter fscanf pDataFile d amp num for counter 0 counter lt num counter i GetClassName pDataFile pClassName pRelation m_pContents gt GetClass pClassName if pRelation NULL pRelation new CClassWindow m_pContents pRelation gt SetClassName pClassName pRelation gt SetNext m_pContents gt GetContents m_pContents gt SetContents pRelation H
75. indow Bool HasParent void void Changelnheritance void void Cut void void OnEvent wxMouseEvent amp event Bool IsChild CClassWindow Bool SaveMe void Bool LoadMe void int GetParentList char void AddInheritance void int GetChildList char void SetData const char void EditMembers void void SetViewable void Bool IsViewable void 89 Bibliography Project Report 8 7 CClassWindow cpp JD PEKKAA oia O ASSWIN cpp EEES 23 11 96 code for managing class names bindings and display Martin Bramley J PR PR A o ol loe od aja le leal le leal laaja aj le al lle al al leal al la al aja aja ll al ll all lol ake ll Hinclude lt string h gt Hinclude lt wx prec h gt Hinclude lt wx h gt Hinclude lt stdlib h gt Hinclude lt stdio h gt Hinclude lt math h gt Hinclude assert h Hinclude app def h Hinclude CClassWindow h Hinclude CMemberFunction h Hinclude CmwContents h Hinclude CMainWindow h Hinclude CRelatedList h Hinclude CEditWindow h extern CMvPanel g pMover extern float dx extern float dy pointer to class which is doing the inheriting user selects add parant inheritor set to currentclass user select new parent class detects inheritor is not null so it is becoming a parent Q E D CClassWindow g pInheritor NULL Function to read a line of text from a file void GetLine FILE inFile char pString
76. indow IsChild CClassWindow pSearch i CRelatedList pTchildren CClassWindow pChild Bool ret FALSE pTchildren m_pChildren while pTchildren NULL amp amp ret FALSE pChild pTchildren gt GetClass if pChild pSearch return TRUE ret pChild gt IsChild pSearch pTchildren pTchildren gt GetNext H return ret HPUBLIC void CClassWindow OnEvent wxMouseEvent amp event i if g pInheritor NULL CMvPanel OnEvent event else if g pInheritor NULL amp amp event LeftDown event RightDown amp amp g plnheritor this Addlnheritance H HPUBLIC Bool CClassWindow SaveMe void i FILE pHeaderFile FILE pCodeFile 99 Bibliography Project Report Bibliography char pHeaderName 40 char pCodeName 40 sprintf pHeaderName s h GetClassName sprintf pCodeName s cpp GetClassName wxRemoveFile pHeaderName wxRemoveFile pCodeName open files if pHeaderFile fopen pHeaderName w NULL return FALSE H if pCodeFile fopen pCodeName w NULL return FALSE 1st write header to both files fprintf pHeaderFile n This file is generated by Resworb copyright Martin Bramley n This file may be edited within reason n n fprintf pCodeFile n This file is generated by Resworb copyright Martin Bramley n This file may be edited within reason n n 2nd write include files to
77. ing it impossible to test each module independently For example the program class which stores user classes inherits a graphical class and so the storage of user classes could not be tested without using the G U I module Therefore a very rigorous and methodical approach was necessary to extensively test each module This was achieved by retesting the module currently being implemented after each significant function was completed The tests were broken into five distinct stages The first stage was using one piece of valid data the second using many pieces of valid data and the third using no data The fourth stage intentionally used invalid data in an attempt to break the procedure and the fifth stage involved contemporaries using the program Testing each significant function in each module this way does not prove that the function is sound and correct although it does give a very good indication After all the modules were complete the entire project was extensively tested using a similar method where both valid and invalid data were used For example when the drag amp drop of classes was being tested during the implementation of the user interface module The first stage of the test was to see if a class could be moved without touching the edge of the window The second was to ensure that when an edge was encountered the class stopped moving The third stage was to assert that the class would stop moving when two edges were encountered simultan
78. ions gt for example PUBLIC for a member function which has public access 2 At the end of the code file append a Finish then a few blank lines 3 In each header file the start of the member variables should be flagged by a Start and the end of the member variables should be flagged by a Finish 72 User Manual Part 7 Maintenance Document Project Report Maintenance Document 7 1 The Modularisation Due to the way Resworb has been implemented it is difficult to perceive how modularisation has been achieved This is because Resworb is made up of classes and each class may contain code for a number of modules The two key modules are the graphical user interface module and the user class module In general the code for the graphical user interface module will be found near the start of the class code file while the code for the user class module may be found towards the end of the class code file 7 2 The Class Hierarchy The source code is well commented but just to clarify things here is the Resworb class Hierarchy The key Resworb classes are briefly summarised in this section N B All classes from the wx Windows toolkit start with wx while all classes belonging to Resworb start with C oxapp wxDialogBox m CResworbApp CEditWindow xtonui CMenuPanel cmveane1 Crunk oamena CClassWindow A CClassNameHolder CRelatedList CMemberFunction 74 Project Report Maintenance Documen
79. ise the project outline the testing done a user manual a maintenance manual and a status report The plan is due in at 4 p m on 15 November 1996 and the report is due in on 4 p m on the 19 of April 1997 In addition the project will be presented to staff and students at a later date 24 Project Plan Implementation and Testing Plans 1 4 Implementation and Testing plans 1 4 1 Implementation The implementation of the program must run on the DEC Alpha in a UNIX windowing environment See Non functional Requirements The graphical user interface will be implemented using an object oriented extension of the standard motif widget set called wx Windows There are a number of benefits of using this system instead of TCL TK which is another possibility The primary benefit is that the implementer has more power over how the interface interacts with the underlying program whereas TCL TK is restrictive in the way that it communicates with the underlying code since it has to be achieved entirely by string manipulation Another benefit is that wxWindows code may be precompiled while TCL TK code is interpreted at run time which make large TCL TK applications sluggish Thirdly wx Windows is very portable as it may use any widget library and not just motif so in theory it should be possible to compile and run the system under Linux and Microsoft Windows 95 The last benefit of using the motif library is that the user may modify t
80. l SetChild class CMultiTreeE CMultiTreeEl SetSibling class CMultiT reeE CMultiTreeEl UnLink void Protected d CMultiTreeEl m_pSibling f CMultiTreeEl SetParent class CMultiT reeE Private References F Source project src Mlitree h 18 Figure 6 Microsoft Developer Studio 13 Project Plan Context Survey 1 2 1 5 Editres This is not a class browser but a resource viewer for motif applications The user interface is very good as it allows the user to see how the resources fit together to create the finished program and it leaves no room for confusion The only drawback for this package is that different levels of resource inheritance are not contractible i e the entire resource tree is always shown Although this is not a problem it may generate a resource tree which is cumbersome to view Another drawback is the fact that the tree is not user manipulable Widget Tree for client editres Editres dumpTreeToFile commands h getResourceLl ist Figure 7 Editres 1 2 1 6 Conclusion The class browsers reviewed provide the ability to browse class hierarchies to a greater or lesser extent CodeWarrior s browser was an interesting solution as it managed to convey a lot of information without the use of graphics The browser within Microsoft Developer Studio is by far the most usable although this seems to fall some what short of fulfilling the problem primarily because of it post compilation na
81. l le leal le leaf al lol la ICAI pyy Jy k ak akak akak akk kkk k 21 12 96header file for main window Martin Bramley N J PR PR A aa aj aja lle al le leal al lo ol aj le al lle al aj aja aja aja ll al ll all la al ll ifndef UNIX Hinclude lt wx_prec h gt Hendif Hinclude lt wx h gt ifndef CMAINWIN H define CMAINWIN H Hinclude CmwContents h Hinclude CMenuBar h Hinclude CListPanel h Hinclude CData h Finishedincludes class CMainWindow public wxFrame public CData i Start private CMenuBar m_pMenubar CmwContents m pContents Finish public Bool GetClassName FILE char CMainWindow wxFrame char int int int int long char void OnMenuCommand int id CMainWindow void void OnPaint void void OnSize int int void ImportClass void int OnClose void void SaveCurrent void void LoadProject int void LoadthisProject char Bool DiscardEdits void void EditPrefs void void SetData const char void ShowHelp void i endif 119 Bibliography Project Report Bibliography 8 17 CMainWindow cpp PR AI A I OI ATA EI IIE TI ODP EEES 21 12 96code for createing main window Martin Bramley PR PR A od aja ls oe ad lle al le leal al lo ol aja loe al lle al al leal jaja aja aja ll al ll all la al ll Hinclude lt wx_prec h gt Hinclude lt wx h gt Hinclude lt stdlib h gt Hinclude app def h Hinclude CMainWindow
82. lasses are larger than the size of the panel If this happens the user should try to move the user class upwards By doing this the class will be snapped to a viewable position within the panel and then the show hide member functions menu option may be selected 3 3 2 Context Menus The user interface was initially designed for experienced computer users who may reguire complex tools However the browser has been implemented giving the users the power reguired while leaving the user interface relatively clutter free The user interface relies heavily on context sensitive menus This is primarily because it is easy to use as there can be no confusion over whether to select the object first and then the action or whether to specify the action and then to specify the object on which the action is to be performed as with other menuing systems Context sensitive menus are also ideal in object oriented programs because the target for the action is always the current object and the action to be performed should be a member function However a programming bug which did arise early in the implementation process was a confusion as to which context sensitive menu should be displayed This was due to an item with a context sensitive menu being placed on top of another item which also contained a context sensitive menu This bug has been fixed although it is still possible to get the wrong menu when pressing the right hand mouse button over a newly creat
83. le and displayed at the top left hand corner of the screen Section 3 1 2 Editing a Project There have been two minor changes to the specification in editing a project The first is the user will now be able to edit rather than just add or delete their member variables This is preferable as it allows the user to add comments to the variables The second change is that instead of specifying the inheritance when creating a new class by using the Create child class option on the context sensitive menu a new class may be created which does not contain any inheritance and then the inheritance may be specified latter by adding parent classes sub classes This is preferable for two reasons Firstly a new base case may be created rather than the previous restriction that all classes must inherit from a predefined base class Secondly the user may specify the inheritance at a later stage rather than at the time of creation allowing the user to create the top level class and then define the sub classes it inherits rather than visa versa Section 3 1 3 Other Operations An auto save option would be very useful and would allow the user to back track to a previously saved version if they make an unrecoverable mistake This will be implemented if time permits using a countdown timer Section 3 3 3 Hardware Only the left hand and right hand mouse buttons will be used This is for two reasons The first is that the application should then be
84. le leal laj al lo al ll al ll al ll all lol ll Hinclude lt wx_prec h gt Hinclude lt wx h gt Hinclude app def h Hinclude CMenuBar h PUBLIC CMenuBar CMenuBar void wxMenu file_menu new wxMenu wxMenu pref_menu new wxMenu wxMenu help_menu new wxMenu file menu gt Append NEW PROJECT amp NewWCtrl N Create new resworb project file menu gt Append LOAD PROJECT amp Open ProjectWCtrl O Opens a Resworb Project file menu gt Append SAVE PROJECT amp Save ProjectWCtrl S Saves current Project file menu gt AppendSeparator file menu gt Append IMPORT CLASS amp Import Class tCtrl 1 Ouits Resworb with no saving file menu gt Append IMPORT PROJECT amp Import Project Import other project file menu gt AppendSeparator file menu gt Append OUIT RESWORGB amp Quit Resworb tCtrl X Quits Resworb with no saving pref_menu gt Append EDIT_PREFS Edit Preferences Opens preferences file help menu gt Append ABOUT RESWORGB amp About About Resworb help menu gt Append SHOW HELP amp Help Display Help Window this gt Append file menu amp File this gt Append pref menu amp Prefences this gt Append help menu amp Help 134 Project Report PUBLIC CMenuBar CMenuBar void i FFinish the extra line 135 Bibliography Project Report 8 22 CMenuPanel h Pasco AA A A ERE menypni h EEES
85. lle al ajaja ajaja aja ll al ll all la ake ll include lt stdlib h gt include lt stdio h gt include lt wx_prec h gt include lt wx h gt include lt malloc h gt include assert h include app def h Hinclude CmwContents h Hinclude CClassNameHolder h Hinclude CMainWindow h extern CMvPanel g pMover extern float dx extern float dy PUBLIC CmwContents CmwContents wxFrame frame wxPanel frame i m rectx 0 m recty 0 m rectw 0 m recth 0 m_ShowRect FALSE wxBrush pBrush new wxBrush g pColBGround wxSOLID SetBackground pBrush m pBluePen new wxPen g pColBGround 1 int wxSOLID m pBlackPen new wxPen g pColBLACK 1 int wxSHORT_DASH m pSolidBlackPen new wxPen g pColBLACK I int wxSOLID determine width of windows to contain variable names maximum no of chars g MaxNameLen g MaxNameLen 2 buffer to contain chars to find width char buff buff char malloc g MaxNameLen memset buff A g MaxNameLen add end of string terminator bufflg MaxNameLen 0 Get DC and find width wxDC pDC GetPanelDC float TempMaxHeight SetFont g pAppFont pDC gt SetFont g pAppFont 143 Bibliography Project Report Bibliography float to be converted g WindowWidth 0 pDC gt GetTextExtent buff amp to be converted amp TempMaxHeight g WindowWidth int to be converted g WindowWidth 5 g SectionHeight int TempMaxHei
86. lude lt stdio h gt Hifndef DEFAULTS H define DEFAULTS H Hdefine MAX a b a lt b b a extern wxColour g pColBLACK extern wxColour g pColWHITE extern wxColour g pColBGround Background colour extern wxColour g pColProtected Protected member function colour extern wxColour g pColPrivate privated n ti extern wxColour g pColPublic public s Y v maximum length of classname extern int g MaxNameLen maximum length of window claculated from name lengh and font width extern int g WindowWidth extern int g SectionHeight extern int g MaxDescriptionLen Global application font extern wxFont g pAppFont canvas popup menu define NEW BASE CLASS 1 defines for classname pop up menu define ADD FUNCTION 10 define ADD VARIABLE 11 define EDIT DESC 12 define CUT 13 define DELETE BRANCH 14 define DELETE CLASS 15 define EDIT NAME 16 define ADD PARENT 17 define VIEW_MEMBERS 18 define SAVE CLASS 19 file menu define LOAD PROJECT 20 define SAVE PROJECT 21 define NEW PROJECT 22 define OUIT RESWORB 23 define EDIT PREFS 24 define ABOUT RESWORB 25 Hdefine SHOW HELP 26 Hdefine IMPORT CLASS27 define IMPORT PROJECT 28 81 Project Report defines for member function pop up menu define EDIT FUNCTION 29 define DELETE FUNCTION 30 define MAKE PUBLIC 31 define MAKE PROTECTED 32 define MAKE PRIVATE 33 Hdefine PRIVATE 34 define PROTECTED 35 define PUBLIC 36
87. mber functions may be edited within the browser There are two restrictions one the first line in the edit function window must be the function declaration This is so that the function name may easily be extracted The second restriction is that pointers to functions may not be the returned from functions this also is due to extracting the name of the function from its definition Changing Inheritance Inheritance may added and removed from classes Move Classes may be moved anywhere within the graphics pad Deleting of Classes User class may deleted in two ways The entire tree below the current may be deleted or just the current class may be deleted with its children inheriting properties of the current classes parents Save As well as entire projects being saved it is possible for just the current class to be saved This an ideal way of making back ups as it is not possible undo actions User Projects New The current project may be discarded giving the user a clear inheritance pad 61 Project Report Status Report Save The current project may be saved to a single directory in standard C format Open A previously saved project and a project the user has created manually may be loaded into a graphics pad with all previous user classes being deleted Importing A previously saved project may be imported into the current project The Graphical User Interface The user interface is easy to use and
88. ng a very basic system and then extending it as the problem is refined 17 Project Plan Problem Specification 1 3 Problem Specification 1 3 1 Functional Reguirements The user of the system will want to perform four key operations create a new project load a project save the current project and edit the current project 1 3 1 1 The Menus There will be a single menu with in the application labelled File This file menu will contain a Create New option Load Option Save Option possibly a Save As Option and a Quit option Creation The first operation a user will require is to create a new project This may be achieved by the user selecting the Create New menu option Once selected the user will be prompted for a project name and location this will be achieved by using a graphical file window After an acceptable project name has been entered a project directory of that name will created and it is within this directory that all the files generated by the application will be stored All projects will contain a default class from which all other classes must inherit This class will contain some virtual debugging and printing facilities such as a function which will return the type of the object as a string There may be a little performance hit in doing this but as specified in the Non functional requirements the user should be able to remove this base class themselves Loading a Project To load a project the user must select
89. nheritance This is obviously a reguired feature So far there has been a heavy emphasis on hierarchy trees whilst really it should lie on hierarchy graphs This emphasis is primarily to reduce the potential confusion of the user A possible solution would be to add a function such as add a parent to the pop up menu which will make the following class clicked become the parent of the class from which the function was called 20 Project Plan Problem Specification So far inheritance is the only form of class relationship covered The other forms of relationship containment and pointer have not been addressed This will be shown graphically using different coloured arrows for each relationship This may have to be discarded if it makes the inheritance tree too convoluted 1 3 1 3 Other Operations Other operations the user may wish to perform could be changing the size of the graphics pad or using snap to grid Operation such as these will be accessible using the menus at the top of the window They should be saved in an application defaults file 1 3 2 The Graphical User Interface As defined the system is aimed at advanced users The G U I Graphical User Interface will be designed for use by someone who is competent with graphical programs The interface should be as free of clutter unnecessary button bars etc as possible This will be achieved by using context sensitive pop up menus There will be a set of menus at the top
90. nt pDeletingParent pDeletingParent NULL i pParent gt RemoveChild this this gt RemoveParent pParent pTadults pTadults gt GetNext PUBLIC Bool CClassWindow DeletingTree void RecursiveDelete NULL return TRUE PUBLIC void CClassWindow Display void i Int x y this gt GetPosition amp x amp y Display x y H PUBLIC void CClassWindow Display int x int y i float MaxHeight CurrentHeight float MaxWidth CurrentWidth CMemberFunction pTemp1l m pMemberFuns m pCNHolder gt GetDims CurrentWidth CurrentHeight MaxWidth CurrentWidth MaxHeight 2 CurrentHeight if m SeeMembers while pTemp1 NULL some new code pTemp1 gt Move 1 int MaxHeight end of new pTemp1 gt GetDims CurrentWidth CurrentHeight if Max Width lt CurrentWidth Max Width CurrentWidth MaxHeight MaxHeight 2 CurrentHeight pTemp1 pTemp1 gt GetNext H Display x y MaxWidth 15 MaxHeight H PUBLIC void CClassWindow Display int x int y float w float h CmwContents m pParent gt Clear ifndef wx msw SetSize int w int h 94 Bibliography Project Report Bibliography Helse SetSize x y int w int h Hendif Move x y 1 OnPaint CmwContents m_pParent gt OnPaint H PUBLIC void CClassWindow UpdateChildLinks int x1 int yl float w1 float h1 int x2 y2 w2 h2 float midx1 midx2 midyl midy
91. of the window for application and project manipulation tools i e saving and loading In general the left hand mouse button will be used to manipulate the position of the classes and links on the screen whilst the right hand mouse button will be used to display the context sensitive pop up menus which will contain options for editing the class When the right hand mouse button is pressed over a class name the pop up menu options will be create a child class add member function add member variable edit class name edit class description cut delete branch and delete class If the right hand mouse button is pressed over a member variable or function the pop up menu options will be edit member delete member make private make public and make protected There is a program available to view the resources of motif applications called Editres See context survey This program has a similar graphical user interface to that which it is hoped will be achieved herein 21 Project Plan Problem Specification 1 3 3 Non Functional Reguirements 1 3 3 1 The User The user of this application is expected to be relatively experienced in the use of the object oriented programming language C It is expected that the user will be confident with Graphical User Interfaces The user should also be able to grasp the basic concepts of the application with ease and with the aid of the instruction manual they should be able to master the application The
92. on or after it Not before the declaration n n void MakeFunctionMenu CLinkedMenu pMenu i pMenu gt Append EDIT FUNCTION Edit Function pMenu gt Append DELETE FUNCTION Delete Function pMenu gt Append MAKE PRIVATE Make Private pMenu gt Append MAKE PROTECTED Make Protected pMenu gt Append MAKE PUBLIC Make Public PUBLIC CMemberFunction CMemberFunction wxPanel parent int x 1 int y 1 int w 1 int h 1 CMenuPanel parent x y w h for some really obscure reason the following 2 lines must occur before the following malloc m_pParent parent MakeFunctionMenu m pMenu m pNext NULL SetData pConstFunct m pFunctName FindFunName m Access PUBLIC H PUBLIC char CMemberFunction FindFunName void i char pData char pCode char pCrap char pName 1024 pCode strdup GetData 129 Project Report pData pCode pCrap strstr pData pData pCrap pData 0 if virtual in fun decl jump over pCrap strstr pData virtual if pCrap NULL pData pCrap strlen virtual H while pData 0 pData should be at start of return type name pCrap strstr pData if pCrap NULL pData pCrap 1 now stepped over return type while pData 0 pData if pData 0 pData while pData 0 pData sscanf pData s pName delete pCode return strdup pName
93. ons and m_pVariables are going to be pointers to a doubly linked lists of program objects wherein each object in the list is going to be either a user member variable or a user member function 29 Project Plan Implementation and Testing Plans 1 4 3 4 Members Module This module will contain the classes CMemberFunction and CMemberVariable which are used by the classes module The classes will contain character data for the members it contains and functions to access such data The classes will inherit from a class called CMember which in turn inherit from a list class defined in the misc module The CMember class will contain labels to specify what member access control the member has 1 4 3 5 Miscellaneous Module This module will contain service classes It will contain a class lists to be used by the members module a class graphs to be used by the classes module and a class strings which will be used in a number of places It will be hoped that some of these may not have to be implemented 30 Project Plan Implementation and Testing Plans 1 4 4 Testing 1 4 4 1 Of the Classes At each stage of implementation of the classes each one should be able to be tested rigorously for its correctness Every public function within every class must be tested for its correctness This may be achieved by writing simple test harness programs which access the classes being tested through the member functions and monitor the return results
94. ov event commandlnt prevx prevx event commandint 3 else Y Offset ymov event commandlnt prevy prevy event commandInt pTemp m_pContents int curx cury while pTemp NULL pTemp gt GetPosition amp curx amp cury pTemp gt Move curx XOffset cury YOffset pTemp CClassWindow pTemp gt GetNext H Clear OnPaint PUBLIC void CmwContents OnPaint void i Define the repainting behaviour if m_ShowRect Clear IntDrawLine m_rectx m_recty m_rectx m_rectw m_recty IntDrawLine m_rectx m_rectw m_recty m_rectx m_rectw m recty m recth IntDrawLine m rectx m rectw m recty m recth m rectx m recty m recth IntDrawLine m rectx m recty m recth m rectx m recty UpdateLinks 145 Project Report Bibliography PUBLIC CClassWindow CmwContents GetFrames void i PUBLIC void CmwContents OnEvent wxMouseEvent amp event return m_pContents float x y event Position amp x amp y if g pMover NULL amp amp event LeftIsDown amp amp event Dragging amp amp m_positnew FALSE int w h GetSize amp w amp h remove old outline SetBluePen OnPaint finished remove outline m_rectx int x dx m_recty int y dy if m_rectx lt 1 m_rectx 0 if m recty lt 1 m_recty 0 if m_rectx m_rectw gt w m_rectx w m_rectw 12 if m_recty m
95. pand or collapse a branch of the inheritance tree This will be implemented entirely by the use of the mouse The second type of editing is the editing of individual classes The user may edit the user classes by the use of context sensitive menus which will be bound to the right hand mouse button The first thing a user will wish to do when editing a project is to create a class This will be achieved by the user pressing the right mouse button over the intended parent s class name This will cause a pop up menu to appear where one of the options will be to create a child class A new class will then be created on the screen which will have a default name and description which the user must modify Once the user has created a class the user may wish to add member variables or member functions This will be achieved by the user pressing the right mouse button over the class name and then selecting add variable or add function from the pop up 19 Project Plan Problem Specification menu which will appear If a variable is to be added a dialogue box will be displayed asking for the user to enter the variable type and name If a function is to be added an editable text window will be displayed allowing the user to enter the function and with it a comment or description Next the user may wish to edit or delete member variable or member functions from a class This may be achieved by the user selecting the member to be removed within the class
96. pos NULL buff pos buff 0 strcat buff pos 1 pos strstr buff r n if buff NULL CEditWindow but GetParent gt m_pRetClass gt SetData buff delete buff should delete edit window CEditWindow but GetParent gt Close PUBLIC CEditWindow CEditWindow wxFrame parent CData pReturnClass char title int x int y int w int h wxDialogBox parent title TRUE x y w h 110 Project Report Bibliography constructor for user class window m pTextWindow new wxTextWindow this 0 0 w h 50 wxNATIVE_IMPL wxHSCROLL textwindow m pTextWindow gt SetFont g pAppFont m pTextWindow gt DragAcceptFiles TRUE m pTextWindow gt WriteText pReturnClass gt GetData m pTextWindow gt Show TRUE do something so that it resizes properly m pRetClass pReturnClass m pOKbutt new wxButton this wxFunction amp buttonProc OK w 2 75 h 40 60 30 m pOKbutt gt SetClientData char OK TAG m_pCANCEL butt new wxButton this wxFunction amp buttonProc Cancel w 2 25 h 40 60 30 m pCANCEl butt gt SetClientData char CANCEL TAG PUBLIC CEditWindow CEditWindow i H PUBLIC void CEditWindow OnSize int w int h i w and h are needed so funct is called properly int width height GetClientSize amp width amp height m_pTextWindow gt SetSize 0 0 w h 50 delete m_pOKbutt delete m pCANCEL butt m pOKbutt new
97. position data to the binary file and then calling the member function save class 28 Project Plan Implementation and Testing Plans 1 4 3 3 Classes Module This module will contain the implementation of the program class which contains the user classes The program class will inherit from a labelled cyclic graph implemented in the misc module to enable multiple inheritance It will also inherit from two wx Windows classes which will contain all the graphical information i e position and size This program class will contain four member variables and a number of member functions The structure of this program class maybe something like class CDisplayClass private CWeightedCyclicGraph private char m_pClassName char m_ClassDescription 256 CMemberFunction m_pFunctions a Double linked list of functions CMemberVariables m pVaraibles a Double linked list of variables public AddVariable AddFunction MakeChild AddParent UnLinkParent EditName EditDescription LoadClass SaveClass Where the public functions except LoadClass and SaveClass are the functions available to the context sensitive pop up menu available through the right hand mouse button The AddVariable AddFunction and MakeChild functions will create default instances of the sub object which will be added to the lists for the user to edit The LoadClass and SaveClass functions will be called by the file access module The private variables m_pFuncti
98. r interface module will be implemented 1 4 3 1 User Interface Module This module will contain the code which will generate the bare bones of the graphical user interface The module will create the main window the menus and the canvas which will contain the users inheritance tree All menu actions which occur within the File menu will make calls to the file access module All actions which occur within the canvas will be dealt with by the classes module 21 Project Plan Implementation and Testing Plans 1 4 3 2 File access module This module will contain a number of functions which may be called externally These functions will do a number of checks and then call one of the following two functions a load function and a save function The load function will load the project name given as a parameter and if the project name does not exist then it will create the project The load function will firstly read the binary file within the project directory which will contain information about what user classes exist and where they are to be positioned on the screen It will also contain information on how the user class hierarchy should be traversed to get the class relationships corrects The function will then traverse the generated users class hierarchy calling the member function load class The save function will save the users project to the specified directory This function will actually traverse the users class tree firstly saving
99. rent gt AddFunction break case ADD PARENT CClassWindow CClassNameHolder menu GetContainer gt GetParent gt Changelnheritance break case CUT CClassWindow CClassNameHolder menu GetContainer gt GetParent gt Cut break case SAVE CLASS CClassWindow CClassNameHolder menu GetContainer gt GetParent gt SaveMe break case DELETE CLASS i CClassWindow pClass CClassWindow CClassNameHolder menu GetContainer gt GetParent CmwContents pmwC CmwContents pClass gt GetContainer Bool ret ret pClass gt DeletingClass if ret TRUE delete pClass pmwC gt Clear pmwC gt UpdateLinks H break case DELETE BRANCH i CClassWindow pClass CClassWindow CClassNameHolder menu GetContainer gt GetParent CmwContents pmwC CmwContents pClass gt GetContainer Bool ret ret pClass gt DeletingTree if ret TRUE delete pClass pmwC gt Clear pmwC gt UpdateLinks break case DELETE FUNCTION 114 Project Report Bibliography CClassWindow CMemberFunction menu GetContainer gt GetContainer gt DeleteFunction CMemberFunction menu GetContainer break case MAKE PUBLIC CMemberFunction menu GetContainer gt MakeFunc PUBLIC CMemberFunction menu GetContainer gt OnPaint break case MAKE PROTECTED CMemberFunction menu Get
100. rivate CRelatedList m_pNext CClassWindow m_pClass Finish public CRelatedList CClassWindow CRelatedList void CRelatedList GetNext void void SetNext CRelatedList CClassWindow GetClass void void SetClass CClassWindow S endif 149 Bibliography Project Report 8 29 CRelatedlist cpp J 8 PR A ao eaa aja aja le leal le leal al lol lol le classlst cpp FKK K K K K KK K K alea K K a K KK include lt wx_prec h gt include lt wx h gt include CClassWindow h include CRelatedList h HPUBLIC CRelatedList CRelatedList CClassWindow pClass SetNext NULL SetClass pClass PUBLIC CRelatedList CRelatedList void i if m pNext NULL delete m pNext PUBLIC CRelatedList CRelatedList GetNext void i PUBLIC void CRelatedList SetNext CRelatedList pNext i return m pNext m pNext pNext PUBLIC CClassWindow CRelatedList GetClass void i PUBLIC void CRelatedList SetClass CClassWindow pClass i FFinish return m_pClass m pClass pClass last line 150 Bibliography Project Report Bibliography 8 30 CResworbApp h 18 11 96Resworb Main application header file Martin Bramley R lkka This file defines the class structure of the application ifdef WX PRECOMP Hinclude lt wx prec h gt Hendif Hinclude lt wx h gt Hinclude app def h Finishedincludes cla
101. rt Project Summary 3 2 Ideas of Design 3 2 1 Modularisation In many programs the code for the graphical user interface is in a separate module to the data storage code as it is in this project However most programmers consider that each module should be self contained in a distinct number of files This is by no means necessary and within Resworb it is not always possible This is because the graphical toolkit wx Windows has been used which provides a comprehensive set of classes to implement the graphical user interface These classes are inherited by the classes in Resworb which store data and its access functions relevant to Resworb while at the same time containing methods calling of wx Windows graphical methods to provide the graphical capabilities reguired To this end it is apparent that code from the graphical user interface module and code from the data access module may often be found in the same files 3 2 2 Design Decisions A crucial aspect which was addressed at the design stage was the saving of projects The original specification stated there would be two files for each class a code file and a header file and a binary file containing application specific information This seemed too restrictive as a plain text file is easy for debugging by the implementer and easier to hack by a user The text file now only specifies which classes in the current directory are part of the project where on the screen each class should b
102. s To this end the project has been very successful In achieving the aim of the project a great deal of thought had to be put into the differing styles of object oriented programming a prospective user may adopt After all Resworb should prove to be useful to both very strict and rigorous object oriented programmers as well as programmers who adopt a more traditional approach This is best emphasised by example In many programs there are certain variables which the programmer would like to be available to all parts of the program This is freguently achieved by using global variables However a very strict object oriented programmer may wish to bind this variable into every class by creating a base class which every class would inherit where this base class would contain a static version of the variable Although Resworb can handle both approaches it is unfortunately by far easier to adopt the stricter approach while using Resworb as it is then possible to visualise it through the class hierarchy For programmers who prefer to use global variables Resworb may be used to design the class hierarchy but afterwards the programmer must edit the code adding non member functions and global variables A global section could have been added to Resworb accessible through the menu bar which may have alleviated this problem But this has not been implemented as Resworb is primarily a class browser before a program developing environment 45 Project Repo
103. s project will use a similar method where each user class is actually a window which will contain a number of buttons These buttons will act as bindings to the context sensitive menus which will occur when the right mouse button is pressed Fach user class will contain at least one button which will be the class name This button will contain the binding which controls the context sensitive pop up menu of the user class The other buttons within these windows will be for either the user member variables or the user member functions These buttons will contain bindings to a different set of pop up menus which will enable the user to change the access level delete or edit the member 26 Project Plan Implementation and Testing Plans 1 4 3 The Modules The application will contain four main modules and one module which will contain miscellaneous utilities and class These modules will fit together in the following way User Interface Module Files Module Classes Module IMembers Module l EV n Windows Buttons Graphs ists Strings Figure 8 How the modules connect The modules will be implemented in the following order A basic G U I will be implemented to allow testing during development then the miscellaneous and classes module will be developed and finally the files module and the interface code between the classes module and the use
104. sastrous may occur When a release assertion fails the user will be told that an internal error has occurred and then the application will try to save the current project User errors are errors generated when the user attempts to do something illegal The application should not allow this to happen and when a user attempts this the user should be alerted of the error 23 Project Plan Problem Specification 1 3 3 6 System Modifications Areas of the application which may be improved upon at a later date are e An interface to an R C S e Support for other languages apart from C possibly Napier Small talk or Eiffel e Fxtendingitto a fully integrated programming environment with a debugging tool e Fxtending it to have multiple projects open at a time with cut and paste facilities between projects e Adding some error checking within the modules i e checking the user declares a variable before using it 1 3 3 7 Deliverables There are two sets of deliverables The first will be a project plan and the second being a project report The plan will define the problem survey existing products and relevant back ground material specify the problem in terms of what reguirements it should fulfil a document covering how the project should be implemented and finally a project monitoring sheet specifying the estimated timings of the project The report will outline the project contain an updated version of the plan summar
105. ss CResworbApp public wxApp i Start private Application has one window public CMainWindow m_pAppWindow Finish public CResworbApp void CResworbApp wxFrame Onlnit void 5 151 Project Report 8 31 CResworbApp cpp UAA AAE ATA AA AAA AKKA AKKKTEE N CPP FKK KK K K K K K K K ale ale K ajo 2K ale ale e K OK K 2K 18 11 96Resworb Main application file Martin Bramley J PR PR A ao ol aj aja ajajaa aj laaja aj a le al lle al aj aja aja aja ll al ll all lol ake ll Hinclude lt wx prec h gt Hinclude lt wx h gt Hinclude lt stdio h gt Hinclude CMainWindow h Hinclude CResworbApp h The instance of the application CResworbApp ResworbApp Global application font wxFont g pAppFont NULL Global application colours wxColour g pColBLACK NULL wxColour g pColWHITE NULL wxColour g pColBGround NULL wxColour g pColProtected NULL wxColour g pColPrivate NULL wxColour g pColPublic NULL max name length of variables int g MaxNameLen 32 int g MaxDescriptionLen 512 worked out from max name length 2 2 for and space 2 for this is actaully set in the creation of the main window mwcont cpp int g WindowWidth int g SectionHeight extern void GetLine FILE char PUBLIC CResworbApp CResworbApp void i Application constructor There should only be one instance of the application which is made statically at run time hence
106. stElH_CMultiTreeEl CrileTreeEl CFileTreeEl char int ChangeDirectory char ContainsFile char ContainsSubDir char CreateDirectory char CreateFile char DeleteObject char DisplayDirectory void GetNamelvoid GetSubObj char CFileTreeEl void Figure 3 Semantic Think C 11 Project Plan Context Survey 1 2 1 3 Borland Visual C As you can see in figure 4 this package s object browser is at first glance surprisingly similar to that of Semantic Think C However there are some improvements which are mostly in the user interface To view the functions available to a class a double click on the class brings up another window see Fig 5 which contains all the functions available to the class and shows where they originate To view the code within a function a double click with the mouse on the function brings up the code within a text viewer Here the function code may be edited but any changes to the class structure may not be viewed until the entire application is rebuilt CD oublyLinkedListEl CMultiTreeEI CFileTreeEI CDoublyLinkedList Figure 4 Borland Visual C Object Browser class CDoublyLinkedListEl CD oublyLinkd73 m CFileTreeEl CD oublyLinkedListE Gl i717 71 1 lt 1 lt Figure 5 Borland Visual C Class Browser 12 Project Plan Context Survey 1 2 1 4 Microsoft Developer Studio This browser is by far the best of those reviewed The
107. t 7 2 1 Class CResworbApp All programs which use the wx Windows toolkit must contain an object not a pointer to an object of a class which inherits the wxApp class The name of the object is ResworbApp The member function On nit is similar to the main function in other programs and instantiates the application The function On nit creates the global variables and constants and also creates and returns the application window 7 2 2 Class CMainWindow The class CMainWindow creates and manages the main window to the application It contains a pointer to the applications pulldown menus CMenuBar and also a pointer to the inheritance pad The functions which are called through the pulldown menus are also in this class 7 2 3 Class CEditWindow This is the generic class through which all data is edited The class constructor takes as a parameter the class CData which all classes which contain data inherit In this way all classes which contain data may be passed to this class to be edited 7 2 4 Class CData This class is inherited by all classes which contain data In this way these classes may be passed to the class CEditWindow This class contains a virtual functions SetData which is redefined as necessary in each class which inherits CData The function SetData is called by CEditWindow hence it must be virtual 7 2 5 Class CLinkedMenu Originally this was not implemented but it became apparent that a method was needed
108. the Load option from the file menu The user will then be asked to select the project directory they wish to load through a graphical file window 18 Project Plan Problem Specification Saving a Project To save a project the user must select either Save or Save As from the File menu Save will save to the same project directory it was loaded from and Save As will save to a new project directory which the user must enter through a graphical file window Within the directory a project is saved two files will be generated for each class a C header file and a C code file and additionally a single binary file which will contain information about the positions of classes on the screen and other display options The user may edit the generated C files although it will not be possible for the user to add or remove classes as they will have entries in the binary file The user may add or remove member variables or member functions to the classes as long as the order they occur in the header file is the same as the order the occur in in the code file 1 3 1 2 Editing a Project There are two main types of editing a user may wish to perform The first is editing the layout of the class inheritance tree This is simply the user moving the classes around the graphical canvas and the computer updating the links between the classes A single class may be moved or a selection group of classes may be moved together The user may also wish to ex
109. tored and typing make lt Return gt It may be necessary to edit the Makefile according to your system Once the Resworb binary has been built it may then be copied to a directory within the path 67 User Manual Starting Resworb Within a Unix windowing session open an command terminal Then if Resworb binary is in the users path type Resworb lt Return gt Else change directory to where the binary may be found and then repeat the last step N B If Resworb is in the users path then a project may be opened with by changing to the project directory and typing Resworb project name rwb Resworb User Manual The Main Window Inheritance Pad The inheritance pad is the large area of the window in which the Ty users classes are created and displayed Using Resworb Creating Classes The first thing a user would wish to do is create a new class This is achieved by the user depressing the right mouse button over the inheritance pad A pop up menu will then displayed giving the user to create a new class where the mouse pointer is The new class will be created with a default name at the position Moving Class ee specified Inheritance Pad Once you have followed the steps in Starting Resworb a window similar to above will be displayed 68 Resworb Moving Classes A class may be moved by holding the left mouse button down over the class and dragging to the new position and then releasing the mouse
110. tudio Project Plan Context Survey 1 2 1 1 MetroWerks CodeWarrior The class browser with this package used four text windows see fig 2 below The top left window contains the class hierarchy which seems a little on the small side considering there may be many classes within an application Within this window inheritance was indicated by indenting the child class in from its parent This is not very clear if there is a large inheritance tree as it is too easy to make mistakes in interpretation The middle window contained a listing of all the member functions declared within the selected class This may seem fairly acceptable but would it not be better to show all the functions available to the class including the inherited functions which could be shown in a different colour The bottom window contained the code for the selected member function This is fine although as it is post compilation browser the code is not editable The top right window contains the declared member variables within the currently selected class Overall this browser served its purpose although it is not always necessary to see the code for the associated member functions and improvements to the display of the class hierarchy would be a bonus L gt CDoublyLinkedListEl if CDoubluLinkedListEl a m pPrev CLinkedListEl GetNext m_pNext CDoubl yLinkedList GetPrev Link CDoublyLinkedListEl SetNesct CDoubl yLinkedListl SetPrev CDoubl yLinkedListEl
111. ture which restricts the easy manipulation of class structures 14 Project Plan Context Survey 1 2 2 Background Research With the project aiming to facilitate the implementation of C classes it seemed appropriate to examine the technigues available in the design and implementation of object oriented programs The first technigue was designed by Coad and Yourdon who broke the problem down into three distinct stages The first stage is the analysis of the problem The implementer starts at this stage with a broad overview of the problem in terms of objects then the implementer refines the objects by adding a little detail and finally iterates through this stage again continually adding details until a simple hierarchy which solves the problem is derived This may be augmented by a real world representation of the model to help capture the problem and understand it The second stage of the technigue is known as the design stage Within this stage the solution from the first stage is taken and the computational restraints of the model are addressed and solved The last stage is the implementation of the refined problem with the constraints applied by the second stage The second technigue is Booch method This technigue addresses the analysis and design of object oriented systems It may be simplified and be broken down into three stages The first stage is the analysis of the problem At this stage the problem is analysed specified and define
112. use of wx Windows was a poor choice Although wx Windows is actually very good and achieves its aim as a multiple operating systems G U I development tool it is however very slow to the extent that Resworb could run faster if the G U I was implemented from raw motif Also wx Windows contains some strange peculiarities which did not always make sense For example a panel is not scrollable and a canvas cannot contain any widgets Because a panel is not scrollable when the scroll bars are used each user class is moved individually and with large projects this may become very jerky 51 Project Report Project Summary 3 4 Special Algorithms and Data structures 3 4 1 Using Multiple Inheritance Originally when data in an object was to be edited the entire object would have to be passed to the edit window class Only in this way could the data be safely edited using the access functions This was irritating as for each type of object which contained data to be manipulated it was necessary to have a separate implementation of the edit window class This problem was eventually overcome using multiple inheritance with the class CData which contains virtual functions which must be over ridden by the inheriting class This enabled only one instance of the edit window to be implemented Also by using virtual functions in this way when the changes in the edit window are committed different types of analysis may be performed on the data being committed
113. with the right mouse button and then selecting delete member from the pop up menu The user may wish to do two forms of deletion The first is to delete a branch of the class hierarchy To do this the user should select the class at the top of the branch to be deleted and then indicate that it is to be deleted This again will be by using the right hand mouse button to bring up a pop up menu but the option to delete will reguire keyboard confirmation This should not be made too easy as the process will be irreversible and all sub classes will be deleted at the same time The second form of deletion which will be available is where the contents of the deleted class are copied down into it children and the deleted class s children are linked to the deleted class s parent Again this will be achieved by using the pop up menu bound to the right mouse button The user may also wish to move an entire class to a different point within the inheritance tree This will be achievable in two ways the first by making the links between classes drag amp drop able themselves and the second being where the user can select a branch of the tree and cut it out and then paste it within the tree at another point A move like this is potentially very dangerous as the class may depend on its previous parent and the application will not do any checking for inconsistencies One of the most powerful tools in object oriented programming is the idea of multiple i
114. wxButton this wxFunction amp buttonProc OK w 2 75 h 40 60 30 m pOKbutt gt SetClientData char OK TAG m_pCANCELbutt new wxButton this wxFunction amp buttonProc Cancel w 2 25 h 40 60 30 m_pCANCELbutt gt SetClientData char CANCEL TAG PUBLIC int CEditWindow OnClose void what happens when a close command is sent to the window hide the window Show FALSE return TRUE FFinish last line 111 Project Report 8 12 CLinkedMenu h J RFR A aa e aa a aja aja A hee 2 hee 2 inkmenuy aka ak aak aak 23 11 96 header for frame containing canvas and 1 menus for class and members Martin Bramley E A a od aja jaja lle al le leal ajaja aja loe al ll al al leal al lol al aj a aja ll al ll all lol ll ifndef UNIX Hinclude lt wx prec h gt Hendif Hinclude lt wx h gt Hifndef LINKMENU Hdefine LINKMENU class CLinkedMenu public wxMenu i Start private wxPanel m_pParentFrame Finish public CLinkedMenu wxPanel CLinkedMenu void SetContainer wxPanel wxPanel GetContainer void 3 void PopupFunction CLinkedMenu amp wxCommandEvent amp endif 112 Bibliography Project Report Bibliography 8 13 CLinkedMenu cpp Par AES A A HE A HE AERA Tink menu cpp EEES 23 11 96 header for frame containing canvas and 1 menus for class and members Martin Bramley PR PR A ARR A aj aja ls leal al l
Download Pdf Manuals
Related Search
Related Contents
Mode d`emploi détecteur de mouvement caméra - My controle -1232011 SECTION - VI PARTICULAR TECHNICAL Manual del operador INSTRUCTIONS - Harley ー点灯切替の操作方法 壁スイ ッチコントロール機能 (ワンタッチスイ ッチ Kompaktmanometer Serie PPA KMS 100 - Jungheinrich Copyright © All rights reserved.
Failed to retrieve file