AP_UnixToolbar_StyleCombo::~AP_UnixToolbar_StyleCombo(void) { freeStyles(); pango_font_description_free(m_pDefaultDesc); }
/** * Main Application. Currently, drawing styles are hardcoded in this method. * Future work may entail reading the styles from a .properties file. */ int main( int argc, const char* argv[] ) { FILE *pfile; LWGEOM *lwgeom; char line [2048]; char *filename; int layerCount; int styleNumber; LAYERSTYLE *styles; getStyles(&styles); if ( argc != 2 ) { lwerror("You must specifiy a wkt filename to convert.\n"); return -1; } if ( (pfile = fopen(argv[1], "r")) == NULL) { perror ( argv[1] ); return -1; } filename = malloc( strlen(argv[1])+11 ); strncpy( filename, "../images/", 10 ); strncat( filename, argv[1], strlen(argv[1])-3 ); strncat( filename, "png", 3 ); printf( "generating %s\n", filename ); layerCount = 0; while ( fgets ( line, sizeof line, pfile ) != NULL && !isspace(*line) ) { char output[2048]; char *ptr = output; char *styleName; int useDefaultStyle; ptr += sprintf( ptr, "convert -size %s xc:none ", imageSize ); useDefaultStyle = getStyleName(&styleName, line); LWDEBUGF( 4, "%s", styleName ); if (useDefaultStyle) { printf(" Warning: using Default style for layer %d\n", layerCount); lwgeom = lwgeom_from_ewkt( line, PARSER_CHECK_NONE ); } else lwgeom = lwgeom_from_ewkt( line+strlen(styleName)+1, PARSER_CHECK_NONE ); LWDEBUGF( 4, "geom = %s", lwgeom_to_ewkt((LWGEOM*)lwgeom,0) ); styleNumber = layerCount % length(styles); ptr += drawGeometry( ptr, lwgeom, getStyle(styles, styleName) ); ptr += sprintf( ptr, "-flip tmp%d.png", layerCount ); lwfree( lwgeom ); LWDEBUGF( 4, "%s", output ); system(output); addHighlight( layerCount ); addDropShadow( layerCount ); layerCount++; free(styleName); } flattenLayers(filename); optimizeImage(filename); fclose(pfile); free(filename); freeStyles(&styles); return 0; }
bool AP_UnixToolbar_StyleCombo::repopulate(void) { // repopulate the vector from the current document // If ithere is one present AD_Document * pAD_Doc = m_pFrame->getCurrentDoc(); if(!pAD_Doc) { return false; } PD_Document *pDocument = static_cast<PD_Document *>(pAD_Doc); GR_GraphicsFactory * pGF = XAP_App::getApp()->getGraphicsFactory(); if(!pGF) { return false; } // clear anything that's already there m_vecContents.clear(); freeStyles(); // defaults for style combo if (m_pDefaultDesc == NULL) { // for now this is hardcoded m_pDefaultDesc = pango_font_description_new (); pango_font_description_set_family (m_pDefaultDesc, "Times"); pango_font_description_set_size (m_pDefaultDesc, 12 * PANGO_SCALE); } const char * szName; const PD_Style * pStyle; GSList *list = NULL; for (UT_uint32 k=0; (pDocument->enumStyles(k,&szName,&pStyle)); k++) { if (!pStyle) { UT_DEBUGMSG(("no style instance for '%s'\n", szName)); } if (!pStyle->isDisplayed() && !(dynamic_cast<const PD_BuiltinStyle *>(pStyle) && pStyle->isList() && pStyle->isUsed())) { continue; } list = g_slist_prepend (list, (char *)szName); /* wysiwyg styles are disabled for now PangoFontDescription *desc = pango_font_description_copy (m_pDefaultDesc); getPangoAttrs(pStyle, desc); m_mapStyles.insert(szName, desc); */ } // Ok, it's a bit hackish to put them in a list for sorting first // but somehow the vector's qsort totally failed for me if (list) { list = g_slist_sort(list, (GCompareFunc)sort_cb); do { m_vecContents.addItem((const char *)list->data); } while (NULL != (list = g_slist_next(list))); g_slist_free(list); } return true; }