Changes

Jump to: navigation, search

Console UI Core Classes - OOP344 20113

2,283 bytes added, 06:31, 21 March 2012
CText Tester Crash
*[svn://zenit.senecac.on.ca/oop344/trunk/cioTesters/Test2DialogAndLabel.cpp Test2DialogAndLabel.cpp ]
*on matrix, with putty (Terminal/keyboard: Xterm R6)
*: on OSX, you can emulate XTerm keyboard settings using [http://iterm.sourceforge.net/ iTerm]/[http://www.iterm2.com/#/section/home ITerm 2]
*: ~fardad.soleimanloo/t2 runs the demo for the test
====Makefile for test 2 on matrix====
#:* void radio(bool isRadio);
#:* operator bool();
#:* operator char*();
#:* bool operator=(bool flag);
#:: (see [[#CCheckMark|CCheckMark]] description)
# Divide and assign tasks.
*[svn://zenit.senecac.on.ca/oop344/trunk/cioTesters/Test9CCheckList.cpp Test9CCheckList.cpp]
*[svn://zenit.senecac.on.ca/oop344/trunk/cioTesters/Test10Menu.cpp Test10Menu.cpp]
 
==Project makefiles==
*create a file in the root of cio call it '''"makefile"''' and copy the makefile of your test from "[svn://zenit.senecac.on.ca/oop344/trunk/cio_makefile cio makefiles]" into it.
*: make sure the lines starting with c++ are tabbed once.
*: then at command line issue the command '''"make"''' to complie;
*: the name of the executable will bt tX, where X is the number of the test.
* Again: here are the project [svn://zenit.senecac.on.ca/oop344/trunk/cio_makefile makefiles] for Linux
== POST YOUR PROBLEM HERE==
===The Text Helper Class===
[svn://zenit.senecac.on.ca/oop344/trunk/textClass Text class]
<!-- ===CText Tester Crash=== Incorrect, TD[0].data() allocates mem and copies the data into it using text::export string
<syntaxhighlight lang="cpp">
char* data = (char*)TD[0].data();
delete [] data;
</syntaxhighlight>
This fails because TD[0].data() refers to CField::data() and NOT CText::data() like it should.
Here are some possible fixes that I think Fardad meant to use:
<syntaxhighlight lang="cpp">
char* data = (char*)((CText&)(TD[0])).data();
OR
char* data = (char*)txt.data();
</syntaxhighlight>
Note, this does NOT crash on Matrix, only Windows and Visual Studio.
-->
==CCheckList==
Passes corresponding values to the Base class (CField) then
#sets the _data attribute to the address of _flags
#copies '''Format''' and '''radio''' into '''_Format_format''' and '''_radio''' respectively
#sets '''_cnt, _cur''' and '''_flags''' to zero
<big><syntaxhighlight lang="cpp">
===Methods===
<big><syntaxhighlight lang="cpp">
CCheckList& add(const char* Text, bool selected = false);
</syntaxhighlight></big>
* Only adds a new CCheckMark if '''_cnt''' does not exceed the maximum amount of '''_checkmarks''' (32)
* Creates a new CCheckMark with the row being '''_cnt'''+1, the height being 1 and the length being the length of '''Text'''+4
* Sets the newly created CCheckMarks' frame to '''this'''
* Automatically expands the width of the CCheckList if the width of the newly created CCheckMark is bigger than the current width of the CCheckList
* Sets the height of the CCheckList to '''_cnt'''+3
* Updates the bit pattern of '''_flags'''
* Increments '''_cnt'''
<big><syntaxhighlight lang="cpp">
CCheckList& operator<<(const char* Text);
</syntaxhighlight></big>
returns add(Text).
<big><syntaxhighlight lang="cpp">
void draw(int fn = C_FULL_FRAME);
int edit();
void set(const void* data);
int selectedIndex()const;
int selectedIndex(int index);
const char* selectedText();
\-------/
</pre></big>
''Note that if the number of menu items are more than the space provided by the CField's frame, then the menu items should scroll up and down to accommodate the selection''
====Attributes====
<big><syntaxhighlight lang = "cpp">
</syntaxhighlight></big>
CButton holding the Title of this menu
====ConstrucotrConstructor/Destructor====
<big><syntaxhighlight lang = "cpp">
CMenu(const char* Title, const char* Format, int Row, int Col,
</syntaxhighlight></big>
Standard Linked list destructor
 
====Methods====
<big><syntaxhighlight lang = "cpp">
int edit();
</syntaxhighlight></big>
Edits the menu the way it is explains in [[#CMenu |CMenu]] description.<br />
If it is too confusing, this [[CMenu pseudo code - OOP344 20113|pseudo code]] may help.
<big><syntaxhighlight lang = "cpp">
Sets the selected index to the integer pointed by data;
<big><syntaxhighlight lang = "cpp">
int selectedIndex()const;
</syntaxhighlight></big>
returns the selected index or -1 if nothing is selected

Navigation menu