Font& FontManager::createFreeTypeFont(const String& font_name, const float point_size, const bool anti_aliased, const String& font_filename, const String& resource_group, const AutoScaledMode auto_scaled, const Sizef& native_res, XMLResourceExistsAction action) { #ifdef CEGUI_HAS_FREETYPE CEGUI_LOGINSANE("Attempting to create FreeType font '" + font_name + "' using font file '" + font_filename + "'."); // create new object ahead of time Font* object = CEGUI_NEW_AO FreeTypeFont(font_name, point_size, anti_aliased, font_filename, resource_group, auto_scaled, native_res); // return appropriate object instance (deleting any not required) return doExistingObjectAction(font_name, object, action); #else CEGUI_THROW(InvalidRequestException( "CEGUI was compiled without freetype support.")); #endif }
/************************************************************************* Call operator *************************************************************************/ bool LuaFunctor::operator()(const EventArgs& args) const { // named error handler needs binding? if ((d_errFuncIndex == LUA_NOREF) && !d_errFuncName.empty()) { pushNamedFunction(L, d_errFuncName); d_errFuncIndex = luaL_ref(L, LUA_REGISTRYINDEX); d_ourErrFuncIndex = true; } // is this a late binding? if (needs_lookup) { pushNamedFunction(L, function_name); // reference function index = luaL_ref(L, LUA_REGISTRYINDEX); needs_lookup = false; CEGUI_LOGINSANE("Late binding of callback '"+function_name+"' performed"); function_name.clear(); } // put error handler on stack if we're using such a thing int err_idx = 0; if (d_errFuncIndex != LUA_NOREF) { lua_rawgeti(L, LUA_REGISTRYINDEX, d_errFuncIndex); err_idx = lua_gettop(L); } // retrieve function lua_rawgeti(L, LUA_REGISTRYINDEX, index); // possibly self as well? int nargs = 1; if (self != LUA_NOREF) { lua_rawgeti(L, LUA_REGISTRYINDEX, self); ++nargs; } // push EventArgs parameter tolua_pushusertype(L, (void*)&args, "const CEGUI::EventArgs"); // call it int error = lua_pcall(L, nargs, 1, err_idx); // handle errors if (error) { String errStr(lua_tostring(L, -1)); lua_pop(L, 1); CEGUI_THROW(ScriptException("Unable to call Lua event handler:\n\n"+errStr+"\n")); } // retrieve result bool ret = lua_isboolean(L, -1) ? lua_toboolean(L, -1 ) : true; lua_pop(L, 1); return ret; }
//----------------------------------------------------------------------------// void Samples_xmlHandler::elementEndLocal(const String& element) { if (element == ElementName) { CEGUI_LOGINSANE("===== End Animations parsing ====="); } else Logger::getSingleton().logEvent("Animation_xmlHandler::elementEnd: " "</" + element + "> is invalid at this location.", Errors); }
//----------------------------------------------------------------------------// void Samples_xmlHandler::elementStartLocal(const String& element, const XMLAttributes& attributes) { if (element == ElementName) { CEGUI_LOGINSANE("===== Begin Animations parsing ====="); } else if (element == SampleDataHandler::ElementName) { d_chainedHandler = new SampleDataHandler(attributes, "", d_samplesFramework); } else Logger::getSingleton().logEvent("Animation_xmlHandler::elementStart: " "<" + element + "> is invalid at this location.", Errors); }
//----------------------------------------------------------------------------// Font& FontManager::createPixmapFont(const String& font_name, const String& imageset_filename, const String& resource_group, const AutoScaledMode auto_scaled, const Sizef& native_res, XMLResourceExistsAction action) { CEGUI_LOGINSANE("Attempting to create Pixmap font '" + font_name + "' using imageset file '" + imageset_filename + "'."); // create new object ahead of time Font* object = CEGUI_NEW_AO PixmapFont(font_name, imageset_filename, resource_group, auto_scaled, native_res); // return appropriate object instance (deleting any not required) return doExistingObjectAction(font_name, object, action);; }
void WindowManager::cleanDeadPool(void) { WindowVector::reverse_iterator curr = d_deathrow.rbegin(); for (; curr != d_deathrow.rend(); ++curr) { // in debug mode, log what gets cleaned from the dead pool (insane level) #if defined(DEBUG) || defined (_DEBUG) CEGUI_LOGINSANE("Window '" + (*curr)->getName() + "' about to be finally destroyed from dead pool."); #endif WindowFactory* factory = WindowFactoryManager::getSingleton().getFactory((*curr)->getType()); factory->destroyWindow(*curr); } // all done here, so clear all pointers from dead pool d_deathrow.clear(); }
//----------------------------------------------------------------------------// //----------------------------------------------------------------------------// SampleDataHandler::SampleDataHandler( const XMLAttributes& attributes, const String& name_prefix, SamplesFramework* samplesFramework) : d_samplesFramework(samplesFramework) { const String sampleName(attributes.getValueAsString(NameAttribute)); const String summary(attributes.getValueAsString(SummaryAttribute)); const String description(attributes.getValueAsString(DescriptionAttribute)); const String sampleType(attributes.getValueAsString(SampleTypeAttribute)); const String credits(attributes.getValueAsString(CreditsAttribute)); CEGUI_LOGINSANE( "Defining sample named: " + sampleName + " Summary: " + summary + " Description: " + description + " Sample Type: " + sampleType + " Credits: " + credits ); SampleType sampleTypeEnum; if (sampleType == SampleTypeCppModule) sampleTypeEnum = ST_Module; else if(sampleType == SampleTypePython) sampleTypeEnum = ST_Python; else sampleTypeEnum = ST_Lua; d_samplesFramework->addSampleDataCppModule(sampleName, summary, description, sampleTypeEnum, credits); }
//----------------------------------------------------------------------------// Sizef Element::calculatePixelSize(bool skipAllPixelAlignment) const { // calculate pixel sizes for everything, so we have a common format for // comparisons. Sizef absMin(CoordConverter::asAbsolute(d_minSize, getRootContainerSize(), false)); Sizef absMax(CoordConverter::asAbsolute(d_maxSize, getRootContainerSize(), false)); Sizef base_size; if (skipAllPixelAlignment) { base_size = Sizef((d_parent && !d_nonClient) ? d_parent->getUnclippedInnerRect().getFresh(true).getSize() : getParentPixelSize(true)); } else { base_size = Sizef((d_parent && !d_nonClient) ? d_parent->getUnclippedInnerRect().get().getSize() : getParentPixelSize()); } Sizef ret = CoordConverter::asAbsolute(d_area.getSize(), base_size, false); // in case absMin components are larger than absMax ones, // max size takes precedence if (absMax.d_width != 0.0f && absMin.d_width > absMax.d_width) { absMin.d_width = absMax.d_width; CEGUI_LOGINSANE("MinSize resulted in an absolute pixel size with " "width larger than what MaxSize resulted in"); } if (absMax.d_height != 0.0f && absMin.d_height > absMax.d_height) { absMin.d_height = absMax.d_height; CEGUI_LOGINSANE("MinSize resulted in an absolute pixel size with " "height larger than what MaxSize resulted in"); } // limit new pixel size to: minSize <= newSize <= maxSize if (ret.d_width < absMin.d_width) ret.d_width = absMin.d_width; else if (absMax.d_width != 0.0f && ret.d_width > absMax.d_width) ret.d_width = absMax.d_width; if (ret.d_height < absMin.d_height) ret.d_height = absMin.d_height; else if (absMax.d_height != 0.0f && ret.d_height > absMax.d_height) ret.d_height = absMax.d_height; if (d_aspectMode != AM_IGNORE) { // make sure we respect current aspect mode and ratio ret.scaleToAspect(d_aspectMode, d_aspectRatio); // make sure we haven't blown any of the hard limits // still maintain the aspect when we do this if (d_aspectMode == AM_SHRINK) { float ratio = 1.0f; // check that we haven't blown the min size if (ret.d_width < absMin.d_width) { ratio = absMin.d_width / ret.d_width; } if (ret.d_height < absMin.d_height) { const float newRatio = absMin.d_height / ret.d_height; if (newRatio > ratio) ratio = newRatio; } ret.d_width *= ratio; ret.d_height *= ratio; } else if (d_aspectMode == AM_EXPAND) { float ratio = 1.0f; // check that we haven't blown the min size if (absMax.d_width != 0.0f && ret.d_width > absMax.d_width) { ratio = absMax.d_width / ret.d_width; } if (absMax.d_height != 0.0f && ret.d_height > absMax.d_height) { const float newRatio = absMax.d_height / ret.d_height; if (newRatio > ratio) ratio = newRatio; } ret.d_width *= ratio; ret.d_height *= ratio; } // NOTE: When the hard min max limits are unsatisfiable with the aspect lock mode, // the result won't be limited by both limits! } if (d_pixelAligned) { ret.d_width = CoordConverter::alignToPixels(ret.d_width); ret.d_height = CoordConverter::alignToPixels(ret.d_height); } return ret; }