First version of the new dialog engine added to the repository. It compiles, and links with one error. Because of this, it is untested as yet.
git-svn-id: http://openexile.googlecode.com/svn/trunk@73 4ebdad44-0ea0-11de-aab3-ff745001d230
This commit is contained in:
87
osx/dialogxml/field.cpp
Normal file
87
osx/dialogxml/field.cpp
Normal file
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
* field.cpp
|
||||
* BoE
|
||||
*
|
||||
* Created by Celtic Minstrel on 11/05/09.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <sstream>
|
||||
#include "dialog.h"
|
||||
|
||||
void cTextField::attachClickHandler(click_callback_t f __attribute__((unused))) throw(xHandlerNotSupported){
|
||||
throw xHandlerNotSupported(false);
|
||||
}
|
||||
|
||||
void cTextField::attachFocusHandler(focus_callback_t f __attribute__((unused))) throw(){
|
||||
onFocus = f;
|
||||
}
|
||||
|
||||
bool cTextField::triggerFocusHandler(cDialog& me, std::string id, bool losingFocus){
|
||||
// TODO: If isNumericField, verify that the contents are in fact a number.
|
||||
if(onFocus != NULL) onFocus(me,id,losingFocus);
|
||||
return true;
|
||||
}
|
||||
|
||||
void cTextField::setFormat(eFormat prop, short val __attribute__((unused))) throw(xUnsupportedProp){
|
||||
throw xUnsupportedProp(prop);
|
||||
}
|
||||
|
||||
short cTextField::getFormat(eFormat prop) throw(xUnsupportedProp){
|
||||
throw xUnsupportedProp(prop);
|
||||
}
|
||||
|
||||
void cTextField::setText(std::string what){
|
||||
char message[1024];
|
||||
strcpy(message,what.c_str());
|
||||
c2pstr(message);
|
||||
OSErr err = SetControlData(theField,kControlEditTextPart,kControlEditTextTextTag,what.size() + 1,message);
|
||||
if(isVisible()) draw();
|
||||
}
|
||||
|
||||
std::string cTextField::getText(){
|
||||
unsigned char message[1024];
|
||||
OSErr err = GetControlData(theField,kControlEditTextPart,kControlEditTextTextTag,1024,message,NULL);
|
||||
p2cstr(message);
|
||||
return std::string((char*)message);
|
||||
}
|
||||
|
||||
void cTextField::setTextToNum(short what){
|
||||
std::ostringstream sout;
|
||||
sout << what;
|
||||
setText(sout.str());
|
||||
}
|
||||
|
||||
short cTextField::getTextAsNum(){
|
||||
std::istringstream sin(getText());
|
||||
short n;
|
||||
sin >> n;
|
||||
return n;
|
||||
}
|
||||
|
||||
bool cTextField::isClickable(){
|
||||
return false;
|
||||
}
|
||||
|
||||
cTextField::cTextField(cDialog* parent) : cControl(parent) {
|
||||
OSStatus err;
|
||||
err = CreateEditTextControl(parent->win,&frame,NULL,false,true/*useInlineInput*/,NULL,&theField);
|
||||
}
|
||||
|
||||
cTextField::~cTextField(){
|
||||
DisposeControl(theField);
|
||||
}
|
||||
|
||||
void cTextField::show(){
|
||||
ShowControl(theField);
|
||||
cControl::show();
|
||||
}
|
||||
|
||||
void cTextField::hide(){
|
||||
HideControl(theField);
|
||||
cControl::hide();
|
||||
}
|
||||
|
||||
void cTextField::draw(){
|
||||
Draw1Control(theField);
|
||||
}
|
||||
Reference in New Issue
Block a user