- Removed the terrain_pic and terrain_blockage arrays, which were redundant (though shorter). - Cleaned out some of the commented code in boe.graphics.cpp and boe.graphutil.cpp - Added a templated get function to cOutdoors::cWandering. In the dialog engine: - Important fields are now initialized to default values, as they should be. - The absence of required attributes is now recognized as an error - Added stack element to the DTD; no code support yet - Added fore attribute to the dialog element to specify default text colour; DTD updated and code support added. - Likewise with the def-key attribute on other clickable items besides buttons (which already had it) - Updated stylesheet to fall back on the fore attribute when colour is unspecified - When drawing default monster graphics, it uses m_start_pic instead of num as the index. This should be right, though it's untested. Unfortunately, the dialog engine is still unstable. git-svn-id: http://openexile.googlecode.com/svn/trunk@100 4ebdad44-0ea0-11de-aab3-ff745001d230
82 lines
1.9 KiB
C++
82 lines
1.9 KiB
C++
/*
|
|
* field.cpp
|
|
* BoE
|
|
*
|
|
* Created by Celtic Minstrel on 11/05/09.
|
|
*
|
|
*/
|
|
|
|
#include <Carbon/Carbon.h>
|
|
#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);
|
|
}
|
|
|
|
bool cTextField::isClickable(){
|
|
return false;
|
|
}
|
|
|
|
cTextField::cTextField(cDialog* parent) :
|
|
cControl(parent,CTRL_FIELD),
|
|
isNumericField(false) {
|
|
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(){
|
|
GrafPtr cur_port;
|
|
GetPort(&cur_port);
|
|
SetPortWindowPort(parent->win);
|
|
Draw1Control(theField);
|
|
SetPort(cur_port);
|
|
}
|