Difference between revisions of "IO Edit TIP"

From CDOT Wiki
Jump to: navigation, search
 
Line 27: Line 27:
 
Note:    void(*_help)(messageStatus,IO_Form)
 
Note:    void(*_help)(messageStatus,IO_Form)
  
The above “_help” is a pointer to a function or logic that are passed the two arguments.
+
The above “_help” is a pointer to a function or logic that is passed the two arguments.
  
 
You use it like the following way:
 
You use it like the following way:
Line 37: Line 37:
 
Note:”ClearMessage” is a value withing the enum list which is declared in iodef.
 
Note:”ClearMessage” is a value withing the enum list which is declared in iodef.
  
Note: The function logic has to be defined so that it processes the information passed to it. In this case, it gives a help message or clears the printed message at a particular location on the form. Help message might be date must be between a particular time.
+
Note: The function logic has to be defined so that it processes the information passed to it. In this case, it gives a help message or clears the printed message at a particular location on the form. Help message might be "date must be between a particular time."
  
 
Bool (*_Validate)((char*)_data.(*_owner));
 
Bool (*_Validate)((char*)_data.(*_owner));

Latest revision as of 11:55, 5 January 2010

In my group Team Temporary, I am responsible for the IO_Edit class with some others and thought it might be helpful to share part of what I have done to get it to work. int IO_Edit::edit(void){

Once there is an owner which is the outer most frame, the editable fields must be positioned relative to that owner. Two was added to the editable field which took into consideration the frame and the starting of the field. For those persons who might be having difficulty, take a look at it and incorporate it with yourcode. Though simple, it might stimulate some ideas.

This belongs to IO_Edit::edit().

 if(_framed){
   val = io_edit(_str, _owner ? _owner->getTop() + _row + 2 : _row + 1,
     _owner ? _owner->getLeft()+ _col + 2 : _col + 1, _fieldlen, _maxdatalen, _insertmode, &_offset, &_curpos,0);
 }else{
   val = io_edit(_str, _owner ? _owner->getTop() + _row : _row,
     _owner ? _owner->getLeft() + _col : _col, _fieldlen, _maxdatalen, _insertmode, &_offset, &_curpos,0);
 }
 return val;

}

Information on vedit and frame will be added soon. Ausley Johnson

As promised, here are some additional information:

    Normal   0               false   false   false      EN-US   X-NONE   X-NONE

RESOPNSE TO QUESTIONS BY FELLOW STUDENTS

Note: void(*_help)(messageStatus,IO_Form)

The above “_help” is a pointer to a function or logic that is passed the two arguments.

You use it like the following way:

(_Help)(ClearMessage, (*_owner));

Note: “*_owner” is a pointer to a form which controls all the fields and the fact that everything is done on a particular form, you have to be able to refer to it.

Note:”ClearMessage” is a value withing the enum list which is declared in iodef.

Note: The function logic has to be defined so that it processes the information passed to it. In this case, it gives a help message or clears the printed message at a particular location on the form. Help message might be "date must be between a particular time."

Bool (*_Validate)((char*)_data.(*_owner));

Like help, this points to a logic that validates an entry. You also have to define the logic. What ever you want to validate that your form receives. The date etc.

You call it like above “_help” passing an address to the data entered and the form that is being used.


Question was: Do you initialize the pointer to the function logic? Yes

How:

bool (*Validate)(const char* , IO_Form&) = ((void(*)(MessageStatus, IO_Form&))(0))

Note: NO_FUNC is defined in iodef which initializes the “*Validate”

So you simply do within the class declaration

bool (*Validate)(const char* , IO_Form&) = NO_FUNC; REMEMBER to include iodef.h.

Qusetion: How to use IO_Vedit display?

Ans: Since vedit inherits edit, you simply call the display of edit which is the working class. Vedit is simply for validation and for help messages. Therefore the arguments passed to vedit constructor must be passed onto edit and when you are requested to edit you do the following: IO_Edit::edit();//The display code is within this function which makes editing possible.

Note: The pointer to data in iofield does not need dynamic memory allocation from within that class. It simply holds the address for location already allocated memory within ioedit. Therefor “IO_Field::_data = data.”

Ausley Johnson