⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 i_combo.cpp

📁 zinc60t22.tar.gz:zinc在tornado2.2.x下的补丁
💻 CPP
📖 第 1 页 / 共 2 页
字号:
	case L_FIRST:	case L_LAST:	case L_LEFT:	case L_RIGHT:		// These are mapped by combo box, but not needed.  If there is a 		// comboString, it will map these differently, so give it a chance.		if (comboString)			ccode = comboString->Event(event);		break;    case N_SIZE:        {            ZafWindowObject *object;            // Adjust the non-support object sizes.            for (object = ComboFirst(); object; object = object->Next())                object->Event(S_COMPUTE_SIZE);            // Finalize the sizing operation.            for (object = ComboFirst(); object; object = object->Next())                object->OSSize();        }        break;    case S_REGISTER_OBJECT:        {        ccode = ZafWindow::Event(event);        for(ZafWindowObject *child = ComboFirst(); child; child = child->Next())            child->Event(event);        }        break;	// ----- Unknown or error messages -----	default:		ccode = ZafWindow::Event(event);		break;	}	// Return the control code.	return (ccode);}ZafWindowObject *ZafComboBox::FindMouseObject(const ZafEventStruct &event){	return (ZafWindowObject::FindMouseObject(event));}////////////////////////////////////////////////////////////////////////////////// ZafComboBox::MatchInput - matches object text to entered text.//// RETURNS: object if closes match is found, otherwise null is returned.//// INTERNAL: This fuctionma matches searches the text of the objects added to // the combobox to find the text that matches.  When text is matched that // object is made current and scrolled into view.//ZafWindowObject *ZafComboBox::MatchInput(ZafIChar matchValue){	if (!list->first)		return (ZAF_NULLP(ZafWindowObject));	ZafWindowObject *object = ZAF_NULLP(ZafWindowObject);	if (!viewOnly && OSDraw() && comboString)	{		const ZafIChar *comboText = comboString->Text();		if (!comboText || !First())			return (ZAF_NULLP(ZafWindowObject));		if (!*comboText && !First()->Selected())			object = First();		else			for (object = First(); object; object = object->Next())				if (*comboText && !strnicmp(comboText, object->Text(), strlen(comboText)))					break;		if (!object)			return (ZAF_NULLP(ZafWindowObject));		else		{			// Select the object if the list is open.  Otherwise, only make the			// matching item current so it will be selected (and the comboString			// updated) when the list is opened.			object->SetFocus(true);			if (WindowManager()->First() == list)				list->Event(S_VSCROLL_CHECK);		}	}	// Try to do first character recognition.	else if (IsPrint(matchValue) && list->current)	{		ZafIChar buffer[2];		buffer[0] = matchValue;		buffer[1] = 0;		object = list->Current()->Next() ? list->Current()->Next() : list->First();		while (object != list->current)		{			const ZafIChar *text = object->Text();			if (text && !strnicmp(buffer, text, 1))				break;			object = object->Next() ? object->Next() : list->First();		}		if (object != list->current)		{			// Give the object focus and select it.			object->SetFocus(true);			NotifySelection(object, true);			list->Event(S_VSCROLL_CHECK);		}	}	return (object);}////////////////////////////////////////////////////////////////////////////////// ZafComboBox::NotifFocus - notifies parent object that focus of child is // changing.//// This is an advanced function that is used to notify a parent object, or // set of hierarchical objects, that the focus of a child is in the process // of being changed. Under normal conditions, you will not need to explicitly // call this function. Subsequent discussion of this function is intended for // advanced ZAF programmers and is not itended for the "faint of heart."//// The consequences of changing focus are fairly dramatic for most windows and// window objects. For instance, changing the focus from one window to // another, requires all of the ancestors of the old focus object to be // notified of a focus change (their Focus() attribute changes to false), and // all the ancestors of the new focus object to be notified of their focus // change (their Focus() attribute changes to true). A fairly complicated // endeavor when you consider all the ways in which an object may gain focus! // NotifyFocus() provides a consistent method of notification for these // affected objects. //// RETURNS: the object gaining focus or null if the object cannot gain focus.//ZafWindowObject *ZafComboBox::NotifyFocus(ZafWindowObject *focusObject, bool setFocus){	if (focusObject && list->Index(focusObject) != -1)		return (list->NotifyFocus(focusObject, setFocus));	else		return (ZafWindow::NotifyFocus(focusObject, setFocus));}////////////////////////////////////////////////////////////////////////////////// ZafComboBox::NotifSelection -  notifies parent selection state of child is// changing.//// This is an advanced function that is used to notify a parent object, or // set of hierarchical objects, that the selection state of a child is in the // process of being changed. Under normal conditions, you should not call this // function directly. A description of this function follows as "useful // information" in your programming endeavors.// // For simple objects, a call to SetSelected() simply changes the state of the // object and reflects the change on the display. It does not, however, take // into account the consequences of such an action on other siblings, or as it // may affect the state of an application. In addition, since some simple // objects (list and tree items) do not know what consequence the change of // its state will have, it does not update its visual representation if its // SystemObject() status is "false." This aspect of selection is deferred to // the parent's NotifySelection() function.//// RETURNS: a pointer to the selected object//ZafWindowObject *ZafComboBox::NotifySelection(ZafWindowObject *newObject,	bool){	if (!newObject)		return (ZAF_NULLP(ZafWindowObject));	if (!newObject->Selected())		newObject->SetSelected(true);	// Place new data in combo-box.	if (screenID)	{		if (OSDraw() && !viewOnly)		{			comboString->SetText(newObject->Text());			comboString->Redisplay();		}		else		{			ZafWindowObject *oldObj = (ZafWindowObject *)ZafList::First();			if (oldObj != newObject)			{				if (oldObj)				{					ZafWindow::Subtract(oldObj);					delete oldObj;				}				ZafWindowObject *obj = newObject->Duplicate();				obj->SetBordered(false);				obj->SetSelected(false);				if (DynamicPtrCast(obj, ZafString))					DynamicPtrCast(obj, ZafString)->SetViewOnly(true);				obj->SetRegionType(ZAF_AVAILABLE_REGION);				ZafWindow::Add(obj);			}		}	}	return (newObject);}////////////////////////////////////////////////////////////////////////////////// ZafComboBox::SetListRegion - Sets the width and height of list.//// ListRegion() returns the region of the drop down list in which the width // and height can be accessed. The top and left of this region are irrelevant // as the combo box controls these. SetListRegion may be used to set the width // and height.// void ZafComboBox::SetListRegion(const ZafRegionStruct &region){	if (!screenID)	{		list->zafRegion = region;		maxListHeight = region.Height();		listWidth = region.Width();		if (maxListHeight != -1)			listHeight = maxListHeight;	}}////////////////////////////////////////////////////////////////////////////////// ZafComboBox::SetMaximumListHeight - Sets the max height of the list.//// The height of the drop down list on a ZafComboBox is not fixed. It is the// minimum of the space required to display all list items and the// MaximumListHeight. MaximumListHeight is returned in the coordinate// system of the ZafComboBox. SetMaximumListHeight can be used to change the // maximum.// int ZafComboBox::SetMaximumListHeight(int tMaxListHeight){	if (!screenID)		maxListHeight = tMaxListHeight;	return (maxListHeight);}////////////////////////////////////////////////////////////////////////////////// ZafComboBox::SetRegion - sets the combobox's region.//// SetRegion has slightly different semantics in ZafComboBox than in other// classes. For this class, height refers to the maximum list height of the // combo box if MaximumListHeight() is -1 (the default), otherwise height is // used normally.//void ZafComboBox::SetRegion(const ZafRegionStruct &region){	if (region != zafRegion && zafRegion.coordinateType != region.coordinateType)	{		if (maxListHeight != -1)		{			maxListHeight = (int)display->ConvertYValue(maxListHeight,				zafRegion.coordinateType, region.coordinateType);			listHeight = maxListHeight;		}		else			listHeight = (int)display->ConvertYValue(listHeight,				zafRegion.coordinateType, region.coordinateType);	}	if (listWidth == -1)		list->SetRegion(region);	ZafWindow::SetRegion(region);}////////////////////////////////////////////////////////////////////////////////// ZafComboBox::Subtract - subracts objets from the combo box's list.//// This function has functionality to handle advanced subtraction operations // typical of derived ZafWindow classes. // For objects subtracted from ZafWindow, these three operations are // performed:// - they are subtracted from the list of support or non-support children //   (either the support member or the base ZafList part of the class, //   respectively)// - their parent pointer is cleared// - they are removed from the screen if the parent window is already visible //   to the user// // RETURNS: a typesafe ZafWindowObject pointer. This is generally the object // that was passed to the Subtract() function, but can be null if the object // isn't a child of the window.// ZafWindowObject *ZafComboBox::Subtract(ZafWindowObject *object){	ZafWindowObject *retValue = list->Subtract(object);	if (object->Selected())	{		if (!list->Count())        {			if (ViewOnly() && ZafList::First())            {                ZafWindowObject *oldObj = (ZafWindowObject *)ZafList::First();                ZafWindow::Subtract(oldObj);                delete oldObj;            }            Redisplay();        }		if (ComboFirst())			SetText(ZafLanguageManager::blankString);		if (!list->Current())			list->SetCurrent(list->First());	}	return (retValue);}////////////////////////////////////////////////////////////////////////////////// ZafComboBox::Text - returns the text of the selected object.//// This function returns the text of the selected item in the combobox.//// RETURNS: a const pointer, which indicates the current textual information // associated with the object. Under normal circumstances, this value will be // the same as the value passed to SetText().//const ZafIChar *ZafComboBox::Text(void){	// Return the current object contents.	ZafWindowObject *object;	if (comboString)		object = comboString;	else		object = list->Current();	return (object ? object->Text() : ZAF_NULLP(ZafIChar));}////////////////////////////////////////////////////////////////////////////////// ZafComboBox::SetAutoSortData - sets the autosort attribute.//// If AutoSortData() is true, the list will automatically sort its children as // they are added to the list. The function returned by CompareFunction() is // used to sort the children. By default, sorting is done in alphabetical // order, but SetCompareFunction() may be called to provide a custom sorting // function. See ZafList::CompareFunction() for more information about sorting // list children. The default value of this attribute is false, but the user // may call SetAutoSortData() to change it.// // RETRUNS: value of the autosort attribute.//bool ZafComboBox::SetAutoSortData(bool autoSortData){	// Set the list attribute.	return (list->SetAutoSortData(autoSortData));}////////////////////////////////////////////////////////////////////////////////// ZafComboBox::SetText - sets the text on the combostring.//// This fuction sets the text on a combo string.//// RETURNS: ZAF_ERROR_NONE or ZAF_ERROR_INVALID if the combo does not have // a string.// ZafError ZafComboBox::SetText(const ZafIChar *text){	// Return the current object contents.	if (ViewOnly() || !OSDraw())		return (ZAF_ERROR_INVALID);	return (comboString ? comboString->SetText(text) : ZAF_ERROR_INVALID);}// ----- OS Specific Functions ----------------------------------------------////////////////////////////////////////////////////////////////////////////////// ZafComboBox::OSDestroy - destroys the OS side of an objet.//// INTERNAL: This function clears the text from the combo string.//void ZafComboBox::OSDestroy(void){	if (comboString)	{		bool tAuto = automaticUpdate;		automaticUpdate = false;		comboString->SetText(ZafLanguageManager::blankString);		automaticUpdate = tAuto;	}}void ZafComboBox::OSDrawChildren(){    OSDrawChildList(ComboFirst());}ZafError ZafComboBox::OSGetText(void){	return (ZAF_ERROR_NONE);}void ZafComboBox::OSRegisterObject(void){	ZafWindow::OSRegisterObject();}OSWindowID ZafComboBox::OSScreenID(ZafScreenIDType type) const{	return (ZafWindow::OSScreenID(type));}ZafError ZafComboBox::OSSetText(void){	return (ZAF_ERROR_NONE);}void ZafComboBox::OSSort(void){}// ----- ZafComboButton ---------------------------------------------------#define ZAF_COMBO_BUTTON_INFO#include <zinc/data/img_def.hpp>#if defined(ZAF_REENTRANT)#	include <zinc/z_system.hpp>#endifZafBitmapData *ZafComboButton::comboDownArrowBitmap = ZAF_NULLP(ZafBitmapData);#if defined(ZAF_REENTRANT)ZafSemaphore *ZafComboButton::classSem = 0;#endif////////////////////////////////////////////////////////////////////////////////// ZafComboButton::ZafComboButton - constuctor.//// INTERNAL: This function creates a ZafComboButton.//ZafComboButton::ZafComboButton(void) :	ZafButton(0, 0, 0, 0, ZAF_NULLP(ZafIChar)){	SetBordered(false);	SetHzJustify(ZAF_HZ_CENTER);	SetSupportObject(true);	SetAllowToggling(false);	SetAutoSize(false);	SetRegionType(ZAF_AVAILABLE_REGION);	SetNoncurrent(true);	Initialize();	bitmapData = comboDownArrowBitmap;}////////////////////////////////////////////////////////////////////////////////// ZafComboButton::~ZafComboButton - destuctor.//// INTERNAL: This function deletes a ZafComboButton.//ZafComboButton::~ZafComboButton(void){	// Check the image information.	ImageFree();}////////////////////////////////////////////////////////////////////////////////// ZafComboButton::DrawShadow - differs the button's border drawn by // DrawBorder.//// DrawShadow() differs from DrawBorder() because you specify the pixel depth// size of the shadow to be drawn, and also because the function always draws // a 3-dimensional shadow, not just the type of shadow specified by the native// operating environment. The range of depth can be positive or negative. A// negative value represents an indented shadow, generally associated with an// object that has been 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -