コード例 #1
0
ファイル: OmnisTools.cpp プロジェクト: artsman/Omnisical
// Get an EXTfldval for a defined constant
void OmnisTools::getEXTFldValFromConstant(EXTfldval& fVal, qlong constID, qlong prefixID) {
    
	// Check for prefix
	str80 prefixRead;
	str255 constantValue;
	if (prefixID > 0) {
		// Read string from resource, and assign it to return parameter
		RESloadString(gInstLib,prefixID,prefixRead);
		constantValue.concat(prefixRead);
	}
    
	// Read complete resource string
	str255 resourceValue;
	RESloadString(gInstLib,constID,resourceValue);
	
	// Translate into std::wstring for easy substring
	EXTfldval convVar;
	convVar.setChar(resourceValue, dpDefault);
	std::wstring resourceString = getWStringFromEXTFldVal(convVar);
	
	// Get substring between tilde (sometimes used for categories) and first colon.
	int tildePos = resourceString.find(L"~") + 1;
	int colonPos = resourceString.find(L":");
	
	std::wstring constantString = resourceString.substr(tildePos,colonPos-tildePos);
	getEXTFldValFromWString(convVar, constantString);
	
	// Add constant to EXTfldval
	constantValue.concat(convVar.getChar());
	fVal.setConstant(constantValue);
}
コード例 #2
0
ファイル: OmnisTools.cpp プロジェクト: ddelpero/Omnis-jsoncpp
// Get a std::string from an EXTfldval object
std::string OmnisTools::getStringFromEXTFldVal(EXTfldval& fVal) {
	std::string retString;
	
	// Get a qchar* string
	qlong maxLength = fVal.getBinLen()+1; // Use binary length as approximation of maximum size
	qlong length = 0, stringLength = 0;
	qchar* omnisString = new qchar[maxLength];
	fVal.getChar(maxLength, omnisString, length);
	
#ifdef UNICODE
	// Translate qchar* string into UTF8 binary
	qbyte* utf8data = reinterpret_cast<qbyte*>(omnisString);
	stringLength = CHRunicode::charToUtf8(omnisString, length, utf8data);
	char* cString = reinterpret_cast<char*> (utf8data);
#else
	stringLength = length;
	retString = std::string((char*)omnisString,stringLength);
#endif	
	
	// Clean-up
	if (omnisString != NULL){
		delete [] omnisString;
	}
	
	return retString;
}
コード例 #3
0
// Do our list line drawing here (for cObjType_List or cObjType_DropList)
bool	oFontDropDown::drawListLine(EXTListLineInfo *pInfo, EXTCompInfo* pECI) {
	// draw our text
	qstring *	text = newStringFromParam(1, pECI); // first parameter contains our calculated text :)
	if (text!=NULL) {
        GDItextSpecStruct   textSpec = mCanvas->textSpec();
        str255              fontName;
        qpoint              leftTop(pInfo->mLineRect.left+20, pInfo->mLineRect.top);

#ifndef iswin32
        leftTop.h += 2;
#endif
        
        // get our font name
        EXTfldval fontNameFld;
        str255  fontNameStr;
        pInfo->mListPtr->getColVal(pInfo->mLine, mFontColumn, fftCharacter, 0, fontNameFld);
        fontNameFld.getChar(fontNameStr);
        GDIsetFontName(&textSpec.mFnt, fontNameStr.cString(), fontNameStr.length());

        // and draw our text
		mCanvas->drawText(text->cString(), leftTop, textSpec);

		delete text;
	};
	
	return true; // we have drawn this...
};
コード例 #4
0
ファイル: OmnisTools.cpp プロジェクト: artsman/Omnisical
// Get a std::wstring from an EXTfldval object
std::wstring OmnisTools::getWStringFromEXTFldVal(EXTfldval& fVal) {
	std::wstring retString;
	
	// Get a qchar* string
	qlong maxLength = fVal.getBinLen()+1; // Use binary length as approximation of maximum size
	qlong length = 0, stringLength = 0;
	qchar* omnisString = new qchar[maxLength];
	fVal.getChar(maxLength, omnisString, length);
	
	wchar_t* cString;
#if MARKUP_SIZEOFWCHAR == 2
	// For 2-Byte UTF16 wchar_t* (Typically Windows)
	// Convert from UTF8 to UTF16 and set new stringLength
	
	// Translate qchar* string into UTF8 binary
	qbyte* utf8data = reinterpret_cast<qbyte*>(omnisString);
	stringLength = CHRunicode::charToUtf8(omnisString, length, utf8data);
	
	// Translate UTF8 to UTF16
	CHRconvToUtf16 utf16conv(utf8data, stringLength);
	UChar* utf16data = utf16conv.dataPtr();
	stringLength = utf16conv.len();
	
	// Translate UTF16 binary into char* string
	cString = reinterpret_cast<wchar_t*>(utf16data);
#else
	// For 4-Byte UTF32 wchar_t* (Typically Mac and Linux)
	// Convert from UTF8 to UTF32 and set new stringLength
	stringLength = length;
	CHRconvToUtf32FromChar utf32conv(omnisString, stringLength, qfalse);
	U32Char* utf32data = utf32conv.dataPtr();
	stringLength = utf32conv.len();
	
	// Translate UTF16 binary into char* string
	cString = reinterpret_cast<wchar_t*>(utf32data);
#endif
	
	// Create standard string
	retString = std::wstring(cString,stringLength);
	
	// Clean-up
	delete [] omnisString;
	
	return retString;
}
コード例 #5
0
ファイル: OmnisTools.cpp プロジェクト: artsman/Omnisical
qbool OmnisTools::ensurePosixPath(EXTfldval& pathVal) {
#ifdef ismac
	str255 posixCheck, posixPath;
	qshort def = dpFcharacter;
	posixCheck = pathVal.getChar().cString();
	qlong err;
	std::wstring path = getWStringFromEXTFldVal(pathVal);
	
	if (path[0] != L'/') {
		err = ECOconvertHFSToPosix(posixCheck, posixPath);
		if (err != 0) {
			return qfalse;
		}
		pathVal.setChar(posixPath, def);
	}
#endif
	
	return qtrue;
}
コード例 #6
0
// Do our list content drawing here (what we see when the list is collapsed, for cObjType_DropList only)
bool	oFontDropDown::drawListContents(EXTListLineInfo *pInfo, EXTCompInfo* pECI) {
	// Draw our text
    if (pInfo->mLine > 0) {
        EXTfldval *	calcFld;
        EXTfldval fval;
			
        ECOgetProperty(mHWnd,anumListCalc,fval);
        qstring	calculation(fval);
			
        calcFld = newCalculation(calculation, pECI);
		
        if (calcFld != NULL) {
            EXTfldval	result;
            calcFld->evalCalculation(result, pECI->mLocLocp, NULL, qfalse);
            qstring		text(result);
				
            GDItextSpecStruct   textSpec = mCanvas->textSpec();
            str255              fontName;
            qpoint              leftTop(pInfo->mLineRect.left+10, pInfo->mLineRect.top);
            
#ifndef iswin32
            leftTop.h += 2;
#endif
        
            // get our font name
            EXTfldval fontNameFld;
            str255  fontNameStr;
            pInfo->mListPtr->getColVal(pInfo->mLine, mFontColumn, fftCharacter, 0, fontNameFld);
            fontNameFld.getChar(fontNameStr);
            GDIsetFontName(&textSpec.mFnt, fontNameStr.cString(), fontNameStr.length());

            // and draw our text
            mCanvas->drawText(text.cString(), leftTop, textSpec);
		
            delete calcFld;
        };
    };

	return true;
};
コード例 #7
0
ファイル: OmnisTools.cpp プロジェクト: artsman/Omnisical
// Get a std::string from an EXTfldval object
std::string OmnisTools::getStringFromEXTFldVal(EXTfldval& fVal) {
	std::string retString;
	
	// Get a qchar* string
	qlong maxLength = fVal.getBinLen()+1; // Use binary length as approximation of maximum size
	qlong length = 0, stringLength = 0;
	qchar* omnisString = new qchar[maxLength];
	fVal.getChar(maxLength, omnisString, length);
	
	// Translate qchar* string into UTF8 binary
	qbyte* utf8data = reinterpret_cast<qbyte*>(omnisString);
	stringLength = CHRunicode::charToUtf8(omnisString, length, utf8data);
	
	// Translate UTF8 binary into char* string
	char* cString = reinterpret_cast<char*> (utf8data);
	
	// Create standard string
	retString = std::string(cString,stringLength);
	
	// Clean-up
	delete [] omnisString;
	
	return retString;
}