bool wxReportImageItem::RetrieveFromXmlNode(const wxXmlNode* node) { long type = -1, ppi = 72; double x = -1, y = -1; node->GetAttribute(wxT("Type"), wxT("")).ToLong(&type); if(type != wxRP_IMAGE) return false; if(!this->m_style.RetrieveFromXmlNode(node)); this->m_sName = node->GetAttribute(wxT("Name"), wxT("")); wxString path = node->GetAttribute(wxT("Path"), wxT("")); wxImage image; if(image.LoadFile(path)) { this->m_sValue = path; } else return false; wxSscanf(node->GetAttribute(wxT("X"), wxT("")), wxT("%lf"), &x); wxSscanf(node->GetAttribute(wxT("Y"), wxT("")), wxT("%lf"), &y); if(x >= 0 && y >= 0) this->m_position = wxRealPoint(x, y); else return false; wxSscanf(node->GetAttribute(wxT("PPI"), wxT("")), wxT("%d"), &ppi); this->m_iPPI = ppi; this->m_iWidth = image.GetWidth(); this->m_iHeight = image.GetHeight(); return true; }
/***************************************************** ** ** Formatter --- getDateIntsFromString ** ******************************************************/ bool Formatter::getDateIntsFromString( const wxChar *value, int &day, int &month, int &year, int format ) { const int l = LanguageConfig::get()->getLocale()->GetLanguage(); if ( ! value ) { wxLogError( wxT( "Error: date value is NULL" )); return false; } wxChar *c = (wxChar*)value; int sepTokenCount = 0; const wxChar septoken = ( l == wxLANGUAGE_GERMAN ? '.' : '-' ); while ( *c ) { if ( *c == septoken ) sepTokenCount++; if ( ! ( isdigit( *c ) || *c == '.' || *c == '-' )) return false; c++; } if ( sepTokenCount > 2 ) return false; int ret; if ( l == wxLANGUAGE_GERMAN ) // German ret = wxSscanf( value, wxT( "%d.%d.%d" ), &day, &month, &year ); else ret = wxSscanf( value, wxT( "%d-%d-%d" ), &year, &month, &day ); if ( ret != 3 ) return false; if (( day < 1 ) || ( day > 31 )) return false; if (( month < 1 ) || ( month > 12 )) return false; if (( year < -3000 ) || ( year > 6000 )) return false; return true; }
wxOperatingSystemId wxGetOsVersion(int *verMaj, int *verMin, int *verMicro) { // get OS version int major = -1, minor = -1, micro = -1; wxString release = wxGetCommandOutput(wxT("uname -r")); if ( !release.empty() ) { if ( wxSscanf(release.c_str(), wxT("%d.%d.%d"), &major, &minor, µ ) != 3 ) { micro = 0; if ( wxSscanf(release.c_str(), wxT("%d.%d"), &major, &minor ) != 2 ) { // failed to get version string or unrecognized format major = minor = micro = -1; } } } if ( verMaj ) *verMaj = major; if ( verMin ) *verMin = minor; if ( verMicro ) *verMicro = micro; // try to understand which OS are we running wxString kernel = wxGetCommandOutput(wxT("uname -s")); if ( kernel.empty() ) kernel = wxGetCommandOutput(wxT("uname -o")); if ( kernel.empty() ) return wxOS_UNKNOWN; return wxPlatformInfo::GetOperatingSystemId(kernel); }
/***************************************************** ** ** Formatter --- getDegreeIntsFromString ** ******************************************************/ bool Formatter::getDegreeIntsFromString( const wxChar *value, int °, int &minute, int &second, int format ) { if ( ! value ) { wxLogError( wxT( "Error: degree value is NULL" )); return false; } wxChar *c = (wxChar*)value; int sepTokenCount = 0; // TODO while ( *c ) { if ( *c == ':' ) sepTokenCount++; if ( ! ( isdigit( *c ) || *c == ':' )) return false; c++; } if ( sepTokenCount > 2 ) return false; deg = 0; minute = 0; second = 0; int ret = wxSscanf( value, wxT( "%d:%d:%d" ), °, &minute, &second ); if ( ret < 1 ) return false; if (( deg < -180 ) || ( deg > 180 )) return false; if (( minute < 0 ) || ( minute > 59 )) return false; if (( second < 0 ) || ( second > 59 )) return false; return true; }
long wxTimeSpinCtrl::GetTextTime() { int t1, t2, t3, t4; int scanned = wxSscanf(m_txt->GetValue(), wxT("%d:%d:%d:%d"), &t1, &t2, &t3, &t4); switch (scanned) { case 1: if (t1 >= 0) return t1; break; case 2: if (t1 >= 0 && t2 >= 0 && t2 < 60) return t1 * 60 + t2; break; case 3: if (t1 >= 0 && t2 >= 0 && t2 < 60 && t3 >= 0 && t3 < 60) return (t1 * 60 + t2) * 60 + t3; break; case 4: if (t1 >= 0 && t2 >= 0 && t2 < 24 && t3 >= 0 && t3 < 60 && t4 >= 0 && t4 < 60) return ((t1 * 24 + t2) * 60 + t3) * 60 + t4; break; default: break; } return -1; }
bool wxNativeEncodingInfo::FromString( const wxString& rsStr ) { wxStringTokenizer vTokenizer(rsStr, wxT(";")); wxString sEncid = vTokenizer.GetNextToken(); long lEnc; if (!sEncid.ToLong(&lEnc)) return FALSE; encoding = (wxFontEncoding)lEnc; facename = vTokenizer.GetNextToken(); if (!facename) return FALSE; wxString sTmp = vTokenizer.GetNextToken(); if (!sTmp) { charset = 850; } else { if ( wxSscanf(sTmp, wxT("%u"), &charset) != 1 ) { // should be a number! return FALSE; } } return true; } // end of wxNativeEncodingInfo::FromString
bool wxNativeEncodingInfo::FromString(const wxString& s) { wxStringTokenizer tokenizer(s, _T(";")); facename = tokenizer.GetNextToken(); if ( !facename ) return FALSE; wxString tmp = tokenizer.GetNextToken(); if ( !tmp ) { // default charset (don't use DEFAULT_CHARSET though because of subtle // Windows 9x/NT differences in handling it) charset = 0; } else { if ( wxSscanf(tmp, _T("%u"), &charset) != 1 ) { // should be a number! return FALSE; } } return TRUE; }
int wxHtmlTag::ScanParam(const wxString& par, const wchar_t *format, void *param) const { wxString parval = GetParam(par); return wxSscanf(parval, format, param); }
float FloatConfigControl::GetFloatValue() { float f_value; if( (wxSscanf(textctrl->GetValue(), wxT("%f"), &f_value) == 1) ) return f_value; else return 0.0; }
void VarArgTestCase::Sscanf() { int i = 0; char str[20]; wchar_t wstr[20]; wxString input("42 test"); wxSscanf(input, "%d %s", &i, &str); CPPUNIT_ASSERT( i == 42 ); CPPUNIT_ASSERT( wxStrcmp(str, "test") == 0 ); i = 0; wxSscanf(input, L"%d %s", &i, &wstr); CPPUNIT_ASSERT( i == 42 ); CPPUNIT_ASSERT( wxStrcmp(wstr, "test") == 0 ); }
String strutil_decrypt(const String &original) { if(original.Length() == 0) return wxEmptyString; if(! strutil_encrypt_initialised) strutil_encrypt_initialise(); if(original[0] == '-') return strutil_decrypt_tf(original); // the encrypted string always has a length divisible by 4 if ( original.length() % 4 ) { wxLogWarning(_("Decrypt function called with illegal string.")); return wxEmptyString; } String tmpstr, newstr; const wxChar *cptr = original.c_str(); unsigned char pair[2]; unsigned int i; while(*cptr) { tmpstr = wxEmptyString; tmpstr << *cptr << *(cptr+1); cptr += 2; wxSscanf(tmpstr.c_str(), _T("%02x"), &i); pair[0] = (unsigned char) i; tmpstr = wxEmptyString; tmpstr << *cptr << *(cptr+1); cptr += 2; wxSscanf(tmpstr.c_str(), _T("%02x"), &i); pair[1] = (unsigned char) i; strutil_encrypt_pair(pair); newstr << (char) pair[0] << (char) pair[1]; } return newstr; }
bool wxRichTextFormattingDialog::ConvertFromString(const wxString& str, int& ret, int unit) { if (unit == wxTEXT_ATTR_UNITS_PIXELS) { ret = wxAtoi(str); return true; } else if (unit == wxTEXT_ATTR_UNITS_TENTHS_MM) { float value = 0.0; wxSscanf(str.c_str(), wxT("%f"), &value); // Convert from cm // Do this in two steps, since using one step causes strange rounding error for VS 2010 at least. float v = (value * 100.0); ret = (int) (v); return true; } else if (unit == wxTEXT_ATTR_UNITS_PERCENTAGE) { ret = wxAtoi(str); return true; } else if (unit == wxTEXT_ATTR_UNITS_HUNDREDTHS_POINT) { float value = 0.0; wxSscanf(str.c_str(), wxT("%f"), &value); float v = (value * 100.0); ret = (int) (v); } else if (unit == wxTEXT_ATTR_UNITS_POINTS) { ret = wxAtoi(str); return true; } else { ret = 0; return false; } return true; }
int wxOptionValue::GetOption(const wxString& name, const wxChar *format, ...) const { wxString n = GetOption(name); if (n.IsEmpty()) return 0; va_list argptr; va_start(argptr, format); // int i = wxVsscanf(n.c_str(), format, argptr); // VisualStudio doesn't have this int i = wxSscanf(n.c_str(), format, argptr); va_end(argptr); return i; }
void wxHtmlContainerCell::SetWidthFloat(const wxHtmlTag& tag, double pixel_scale) { if (tag.HasParam(wxT("WIDTH"))) { int wdi; wxString wd = tag.GetParam(wxT("WIDTH")); if (wd[wd.Length()-1] == wxT('%')) { wxSscanf(wd.c_str(), wxT("%i%%"), &wdi); SetWidthFloat(wdi, wxHTML_UNITS_PERCENT); } else { wxSscanf(wd.c_str(), wxT("%i"), &wdi); SetWidthFloat((int)(pixel_scale * (double)wdi), wxHTML_UNITS_PIXELS); } m_LastLayout = -1; } }
wxVideoMode wxGetDefaultDisplayMode() { wxString mode; unsigned w, h, bpp; if ( !wxGetEnv(wxT("WXMODE"), &mode) || (wxSscanf(mode.c_str(), _T("%ux%u-%u"), &w, &h, &bpp) != 3) ) { w = 640, h = 480, bpp = 16; } return wxVideoMode(w, h, bpp); }
bool wxNativeEncodingInfo::FromString(const wxString& s) { wxStringTokenizer tokenizer(s, wxT(";")); wxString encid = tokenizer.GetNextToken(); // we support 2 formats: the old one (and still used if !wxUSE_FONTMAP) // used the raw encoding values but the new one uses the encoding names long enc; if ( encid.ToLong(&enc) ) { // old format, intepret as encoding -- but after minimal checks if ( enc < 0 || enc >= wxFONTENCODING_MAX ) return false; encoding = (wxFontEncoding)enc; } else // not a number, interpret as an encoding name { #if wxUSE_FONTMAP encoding = wxFontMapper::GetEncodingFromName(encid); if ( encoding == wxFONTENCODING_MAX ) #endif // wxUSE_FONTMAP { // failed to parse the name (or couldn't even try...) return false; } } facename = tokenizer.GetNextToken(); wxString tmp = tokenizer.GetNextToken(); if ( tmp.empty() ) { // default charset: but don't use DEFAULT_CHARSET here because it might // be different from the machine on which the file we had read this // encoding desc from was created charset = ANSI_CHARSET; } else { if ( wxSscanf(tmp, wxT("%u"), &charset) != 1 ) { // should be a number! return false; } } return true; }
int wxSpinCtrl::GetValue() const { wxString val = wxGetWindowText(m_hwndBuddy); long n; if ( (wxSscanf(val, wxT("%ld"), &n) != 1) ) n = INT_MIN; if ( n < m_min ) n = m_min; if ( n > m_max ) n = m_max; return n; }
void wxSpinCtrlGTKBase::SetValue( const wxString& value ) { wxCHECK_RET( (m_widget != NULL), wxT("invalid spin button") ); double n; if ( wxSscanf(value, "%lg", &n) == 1 ) { // a number - set it, let DoSetValue round for int value DoSetValue(n); return; } // invalid number - set text as is (wxMSW compatible) wxSpinCtrlEventDisabler disable(this); gtk_entry_set_text( GTK_ENTRY(m_widget), wxGTK_CONV( value ) ); }
void FromHex(const String &hexdata) { if(data) free(data); len = hexdata.Length() / 2; data = (BYTE *)malloc( len ); const wxChar *cptr = hexdata.c_str(); String tmp; int val, idx = 0; while(*cptr) { tmp = wxEmptyString; tmp << *cptr << *(cptr+1); cptr += 2; wxSscanf(tmp.c_str(), _T("%02x"), &val); data[idx++] = (BYTE)val; } }
void wxSpinCtrl::SetValue( const wxString& value ) { wxCHECK_RET( (m_widget != NULL), wxT("invalid spin button") ); int n; if ( (wxSscanf(value, wxT("%d"), &n) == 1) ) { // a number - set it SetValue(n); } else { // invalid number - set text as is (wxMSW compatible) GtkDisableEvents(); gtk_entry_set_text( GTK_ENTRY(m_widget), wxGTK_CONV( value ) ); GtkEnableEvents(); } }
void wxNumberEntryDialog::OnOK(wxCommandEvent& WXUNUSED(event)) { #if !wxUSE_SPINCTRL wxString tmp = m_spinctrl->GetValue(); if ( wxSscanf(tmp, wxT("%ld"), &m_value) != 1 ) EndModal(wxID_CANCEL); else #else m_value = m_spinctrl->GetValue(); #endif if ( m_value < m_min || m_value > m_max ) { // not a number or out of range m_value = -1; EndModal(wxID_CANCEL); } EndModal(wxID_OK); }
void wxXmlRcEditDocument::Upgrade() { int v1,v2,v3,v4; long version; wxXmlNode *node = GetRoot(); wxString verstr = wxT("0.0.0.0"); node->GetPropVal(wxT("version"),verstr); if (wxSscanf(verstr.c_str(), wxT("%i.%i.%i.%i"), &v1, &v2, &v3, &v4) == 4) version = v1*256*256*256+v2*256*256+v3*256+v4; else version = 0; if (!version) { UpgradeNode(node); } node->DeleteProperty(wxT("version")); node->AddProperty(wxT("version"), WX_XMLRES_CURRENT_VERSION_STRING); }
void MyFrame::OnTest2(wxCommandEvent& WXUNUSED(event)) { const wxString& title = _("Testing _N() (ngettext)"); wxTextEntryDialog d(this, _("Please enter range for plural forms of \"n files deleted\" phrase"), title, "0-10"); if (d.ShowModal() == wxID_OK) { int first, last; wxSscanf(d.GetValue(), "%d-%d", &first, &last); wxString s(title); s << "\n"; for (int n = first; n <= last; ++n) { s << n << " " << wxPLURAL("file deleted", "files deleted", n) << "\n"; } wxMessageBox(s); } }
bool wxAppBase::OnCmdLineParsed(wxCmdLineParser& parser) { #ifdef __WXUNIVERSAL__ wxString themeName; if ( parser.Found(OPTION_THEME, &themeName) ) { wxTheme *theme = wxTheme::Create(themeName); if ( !theme ) { wxLogError(_("Unsupported theme '%s'."), themeName.c_str()); return false; } // Delete the defaultly created theme and set the new theme. delete wxTheme::Get(); wxTheme::Set(theme); } #endif // __WXUNIVERSAL__ #if defined(__WXMGL__) wxString modeDesc; if ( parser.Found(OPTION_MODE, &modeDesc) ) { unsigned w, h, bpp; if ( wxSscanf(modeDesc.c_str(), wxT("%ux%u-%u"), &w, &h, &bpp) != 3 ) { wxLogError(_("Invalid display mode specification '%s'."), modeDesc.c_str()); return false; } if ( !SetDisplayMode(wxVideoMode(w, h, bpp)) ) return false; } #endif // __WXMGL__ return wxAppConsole::OnCmdLineParsed(parser); }
wxChar wx28HtmlEntitiesParser::GetEntityChar(const wxString& entity) { unsigned code = 0; if (entity[0] == wxT('#')) { const wxChar *ent_s = entity.c_str(); const wxChar *format; if (ent_s[1] == wxT('x') || ent_s[1] == wxT('X')) { format = wxT("%x"); ent_s++; } else format = wxT("%u"); ent_s++; if (wxSscanf(ent_s, format, &code) != 1) code = 0; } else { static wx28HtmlEntityInfo substitutions[] = { { wxT("AElig"),198 }, { wxT("Aacute"),193 }, { wxT("Acirc"),194 }, { wxT("Agrave"),192 }, { wxT("Alpha"),913 }, { wxT("Aring"),197 }, { wxT("Atilde"),195 }, { wxT("Auml"),196 }, { wxT("Beta"),914 }, { wxT("Ccedil"),199 }, { wxT("Chi"),935 }, { wxT("Dagger"),8225 }, { wxT("Delta"),916 }, { wxT("ETH"),208 }, { wxT("Eacute"),201 }, { wxT("Ecirc"),202 }, { wxT("Egrave"),200 }, { wxT("Epsilon"),917 }, { wxT("Eta"),919 }, { wxT("Euml"),203 }, { wxT("Gamma"),915 }, { wxT("Iacute"),205 }, { wxT("Icirc"),206 }, { wxT("Igrave"),204 }, { wxT("Iota"),921 }, { wxT("Iuml"),207 }, { wxT("Kappa"),922 }, { wxT("Lambda"),923 }, { wxT("Mu"),924 }, { wxT("Ntilde"),209 }, { wxT("Nu"),925 }, { wxT("OElig"),338 }, { wxT("Oacute"),211 }, { wxT("Ocirc"),212 }, { wxT("Ograve"),210 }, { wxT("Omega"),937 }, { wxT("Omicron"),927 }, { wxT("Oslash"),216 }, { wxT("Otilde"),213 }, { wxT("Ouml"),214 }, { wxT("Phi"),934 }, { wxT("Pi"),928 }, { wxT("Prime"),8243 }, { wxT("Psi"),936 }, { wxT("Rho"),929 }, { wxT("Scaron"),352 }, { wxT("Sigma"),931 }, { wxT("THORN"),222 }, { wxT("Tau"),932 }, { wxT("Theta"),920 }, { wxT("Uacute"),218 }, { wxT("Ucirc"),219 }, { wxT("Ugrave"),217 }, { wxT("Upsilon"),933 }, { wxT("Uuml"),220 }, { wxT("Xi"),926 }, { wxT("Yacute"),221 }, { wxT("Yuml"),376 }, { wxT("Zeta"),918 }, { wxT("aacute"),225 }, { wxT("acirc"),226 }, { wxT("acute"),180 }, { wxT("aelig"),230 }, { wxT("agrave"),224 }, { wxT("alefsym"),8501 }, { wxT("alpha"),945 }, { wxT("amp"),38 }, { wxT("and"),8743 }, { wxT("ang"),8736 }, { wxT("aring"),229 }, { wxT("asymp"),8776 }, { wxT("atilde"),227 }, { wxT("auml"),228 }, { wxT("bdquo"),8222 }, { wxT("beta"),946 }, { wxT("brvbar"),166 }, { wxT("bull"),8226 }, { wxT("cap"),8745 }, { wxT("ccedil"),231 }, { wxT("cedil"),184 }, { wxT("cent"),162 }, { wxT("chi"),967 }, { wxT("circ"),710 }, { wxT("clubs"),9827 }, { wxT("cong"),8773 }, { wxT("copy"),169 }, { wxT("crarr"),8629 }, { wxT("cup"),8746 }, { wxT("curren"),164 }, { wxT("dArr"),8659 }, { wxT("dagger"),8224 }, { wxT("darr"),8595 }, { wxT("deg"),176 }, { wxT("delta"),948 }, { wxT("diams"),9830 }, { wxT("divide"),247 }, { wxT("eacute"),233 }, { wxT("ecirc"),234 }, { wxT("egrave"),232 }, { wxT("empty"),8709 }, { wxT("emsp"),8195 }, { wxT("ensp"),8194 }, { wxT("epsilon"),949 }, { wxT("equiv"),8801 }, { wxT("eta"),951 }, { wxT("eth"),240 }, { wxT("euml"),235 }, { wxT("euro"),8364 }, { wxT("exist"),8707 }, { wxT("fnof"),402 }, { wxT("forall"),8704 }, { wxT("frac12"),189 }, { wxT("frac14"),188 }, { wxT("frac34"),190 }, { wxT("frasl"),8260 }, { wxT("gamma"),947 }, { wxT("ge"),8805 }, { wxT("gt"),62 }, { wxT("hArr"),8660 }, { wxT("harr"),8596 }, { wxT("hearts"),9829 }, { wxT("hellip"),8230 }, { wxT("iacute"),237 }, { wxT("icirc"),238 }, { wxT("iexcl"),161 }, { wxT("igrave"),236 }, { wxT("image"),8465 }, { wxT("infin"),8734 }, { wxT("int"),8747 }, { wxT("iota"),953 }, { wxT("iquest"),191 }, { wxT("isin"),8712 }, { wxT("iuml"),239 }, { wxT("kappa"),954 }, { wxT("lArr"),8656 }, { wxT("lambda"),955 }, { wxT("lang"),9001 }, { wxT("laquo"),171 }, { wxT("larr"),8592 }, { wxT("lceil"),8968 }, { wxT("ldquo"),8220 }, { wxT("le"),8804 }, { wxT("lfloor"),8970 }, { wxT("lowast"),8727 }, { wxT("loz"),9674 }, { wxT("lrm"),8206 }, { wxT("lsaquo"),8249 }, { wxT("lsquo"),8216 }, { wxT("lt"),60 }, { wxT("macr"),175 }, { wxT("mdash"),8212 }, { wxT("micro"),181 }, { wxT("middot"),183 }, { wxT("minus"),8722 }, { wxT("mu"),956 }, { wxT("nabla"),8711 }, { wxT("nbsp"),160 }, { wxT("ndash"),8211 }, { wxT("ne"),8800 }, { wxT("ni"),8715 }, { wxT("not"),172 }, { wxT("notin"),8713 }, { wxT("nsub"),8836 }, { wxT("ntilde"),241 }, { wxT("nu"),957 }, { wxT("oacute"),243 }, { wxT("ocirc"),244 }, { wxT("oelig"),339 }, { wxT("ograve"),242 }, { wxT("oline"),8254 }, { wxT("omega"),969 }, { wxT("omicron"),959 }, { wxT("oplus"),8853 }, { wxT("or"),8744 }, { wxT("ordf"),170 }, { wxT("ordm"),186 }, { wxT("oslash"),248 }, { wxT("otilde"),245 }, { wxT("otimes"),8855 }, { wxT("ouml"),246 }, { wxT("para"),182 }, { wxT("part"),8706 }, { wxT("permil"),8240 }, { wxT("perp"),8869 }, { wxT("phi"),966 }, { wxT("pi"),960 }, { wxT("piv"),982 }, { wxT("plusmn"),177 }, { wxT("pound"),163 }, { wxT("prime"),8242 }, { wxT("prod"),8719 }, { wxT("prop"),8733 }, { wxT("psi"),968 }, { wxT("quot"),34 }, { wxT("rArr"),8658 }, { wxT("radic"),8730 }, { wxT("rang"),9002 }, { wxT("raquo"),187 }, { wxT("rarr"),8594 }, { wxT("rceil"),8969 }, { wxT("rdquo"),8221 }, { wxT("real"),8476 }, { wxT("reg"),174 }, { wxT("rfloor"),8971 }, { wxT("rho"),961 }, { wxT("rlm"),8207 }, { wxT("rsaquo"),8250 }, { wxT("rsquo"),8217 }, { wxT("sbquo"),8218 }, { wxT("scaron"),353 }, { wxT("sdot"),8901 }, { wxT("sect"),167 }, { wxT("shy"),173 }, { wxT("sigma"),963 }, { wxT("sigmaf"),962 }, { wxT("sim"),8764 }, { wxT("spades"),9824 }, { wxT("sub"),8834 }, { wxT("sube"),8838 }, { wxT("sum"),8721 }, { wxT("sup"),8835 }, { wxT("sup1"),185 }, { wxT("sup2"),178 }, { wxT("sup3"),179 }, { wxT("supe"),8839 }, { wxT("szlig"),223 }, { wxT("tau"),964 }, { wxT("there4"),8756 }, { wxT("theta"),952 }, { wxT("thetasym"),977 }, { wxT("thinsp"),8201 }, { wxT("thorn"),254 }, { wxT("tilde"),732 }, { wxT("times"),215 }, { wxT("trade"),8482 }, { wxT("uArr"),8657 }, { wxT("uacute"),250 }, { wxT("uarr"),8593 }, { wxT("ucirc"),251 }, { wxT("ugrave"),249 }, { wxT("uml"),168 }, { wxT("upsih"),978 }, { wxT("upsilon"),965 }, { wxT("uuml"),252 }, { wxT("weierp"),8472 }, { wxT("xi"),958 }, { wxT("yacute"),253 }, { wxT("yen"),165 }, { wxT("yuml"),255 }, { wxT("zeta"),950 }, { wxT("zwj"),8205 }, { wxT("zwnj"),8204 }, {NULL, 0}}; static size_t substitutions_cnt = 0; if (substitutions_cnt == 0) while (substitutions[substitutions_cnt].code != 0) substitutions_cnt++; wx28HtmlEntityInfo *info = NULL; #ifdef __WXWINCE__ // bsearch crashes under WinCE for some reason size_t i; for (i = 0; i < substitutions_cnt; i++) { if (entity == substitutions[i].name) { info = & substitutions[i]; break; } } #else info = (wx28HtmlEntityInfo*) bsearch(entity.c_str(), substitutions, substitutions_cnt, sizeof(wx28HtmlEntityInfo), wx28HtmlEntityCompare); #endif if (info) code = info->code; } if (code == 0) return 0; else return GetCharForCode(code); }
void wxFontRefData::InitFromNative() { // get the font parameters from the XLFD // ------------------------------------- m_faceName = m_nativeFontInfo.GetXFontComponent(wxXLFD_FAMILY); m_weight = wxFONTWEIGHT_NORMAL; wxString w = m_nativeFontInfo.GetXFontComponent(wxXLFD_WEIGHT).Upper(); if ( !w.empty() && w != wxT('*') ) { // the test below catches all of BOLD, EXTRABOLD, DEMIBOLD, ULTRABOLD // and BLACK if ( ((w[0u] == wxT('B') && (!wxStrcmp(w.c_str() + 1, wxT("OLD")) || !wxStrcmp(w.c_str() + 1, wxT("LACK"))))) || wxStrstr(w.c_str() + 1, wxT("BOLD")) ) { m_weight = wxFONTWEIGHT_BOLD; } else if ( w == wxT("LIGHT") || w == wxT("THIN") ) { m_weight = wxFONTWEIGHT_LIGHT; } } switch ( wxToupper(m_nativeFontInfo. GetXFontComponent(wxXLFD_SLANT)[0u]).GetValue() ) { case wxT('I'): // italique m_style = wxFONTSTYLE_ITALIC; break; case wxT('O'): // oblique m_style = wxFONTSTYLE_SLANT; break; default: m_style = wxFONTSTYLE_NORMAL; } long ptSize; if ( m_nativeFontInfo.GetXFontComponent(wxXLFD_POINTSIZE).ToLong(&ptSize) ) { // size in XLFD is in 10 point units m_pointSize = (int)(ptSize / 10); } else { m_pointSize = wxDEFAULT_FONT_SIZE; } // examine the spacing: if the font is monospaced, assume wxTELETYPE // family for compatibility with the old code which used it instead of // IsFixedWidth() if ( m_nativeFontInfo.GetXFontComponent(wxXLFD_SPACING).Upper() == wxT('M') ) { m_family = wxFONTFAMILY_TELETYPE; } else // not monospaceed { // don't even try guessing it, it doesn't work for too many fonts // anyhow m_family = wxFONTFAMILY_UNKNOWN; } // X fonts are never underlined... m_underlined = false; // deal with font encoding wxString registry = m_nativeFontInfo.GetXFontComponent(wxXLFD_REGISTRY).Upper(), encoding = m_nativeFontInfo.GetXFontComponent(wxXLFD_ENCODING).Upper(); if ( registry == wxT("ISO8859") ) { int cp; if ( wxSscanf(encoding, wxT("%d"), &cp) == 1 ) { m_encoding = (wxFontEncoding)(wxFONTENCODING_ISO8859_1 + cp - 1); } } else if ( registry == wxT("MICROSOFT") ) { int cp; if ( wxSscanf(encoding, wxT("cp125%d"), &cp) == 1 ) { m_encoding = (wxFontEncoding)(wxFONTENCODING_CP1250 + cp); } } else if ( registry == wxT("KOI8") ) { m_encoding = wxFONTENCODING_KOI8; } else // unknown encoding { // may be give a warning here? or use wxFontMapper? m_encoding = wxFONTENCODING_SYSTEM; } }
static unsigned int GetSSAGDriverVersion() { // check to see if the SSAG driver is v2 ("1.2.0.0") or v4 ("3.0.0.0") Debug.AddLine("Checking SSAG driver version"); bool found = false; unsigned int driverVersion = 2; // assume v2 HDEVINFO h = SetupDiGetClassDevs(NULL, L"USB", NULL, DIGCF_ALLCLASSES | DIGCF_PRESENT); if (h != INVALID_HANDLE_VALUE) { DWORD idx = 0; SP_DEVINFO_DATA data; memset(&data, 0, sizeof(data)); data.cbSize = sizeof(data); while (SetupDiEnumDeviceInfo(h, idx, &data)) { #if DONE_SUPPORTING_XP WCHAR buf[4096]; if (GetDiPropStr(h, &data, DEVPKEY_Device_InstanceId, buf, sizeof(buf)) && (wcsncmp(buf, L"USB\\VID_1856&PID_0012\\", 22) == 0) || (wcsncmp(buf, L"USB\\VID_1856&PID_0011\\", 22) == 0)) { Debug.AddLine(wxString::Format("Found SSAG device %s", buf)); if (GetDiPropStr(h, &data, DEVPKEY_Device_DriverVersion, buf, sizeof(buf))) { Debug.AddLine(wxString::Format("SSAG driver version is %s", wxString(buf))); int v; if (swscanf(buf, L"%d", &v) == 1 && v >= 3) { driverVersion = 4; } } found = true; break; } #else WCHAR buf[4096]; DWORD size = sizeof(buf); DWORD proptype; if (SetupDiGetDeviceRegistryProperty(h, &data, SPDRP_HARDWAREID, &proptype, (PBYTE)&buf[0], size, &size) && (wcsncmp(buf, L"USB\\VID_1856&PID_0012", 21) == 0 || wcsncmp(buf, L"USB\\VID_1856&PID_0011", 21) == 0)) { Debug.AddLine(wxString::Format("Found SSAG device %s", buf)); wxString ver = GetDiPropStr(h, &data, "DriverVersion"); if (ver.Length()) { Debug.AddLine(wxString::Format("SSAG driver version is %s", ver)); int v; if (wxSscanf(ver, "%d", &v) == 1 && v >= 3) { driverVersion = 4; } } found = true; break; } #endif // XP ++idx; } SetupDiDestroyDeviceInfoList(h); } if (!found) Debug.AddLine("No SSAG device was found"); return driverVersion; }
bool wxFont::Create(const wxString& fontname, wxFontEncoding enc) { if( !fontname ) { *this = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT); return true; } m_refData = new wxFontRefData(); M_FONTDATA->m_nativeFontInfo.SetXFontName(fontname); // X font name wxString tmp; wxStringTokenizer tn( fontname, wxT("-") ); tn.GetNextToken(); // skip initial empty token tn.GetNextToken(); // foundry M_FONTDATA->m_faceName = tn.GetNextToken(); // family tmp = tn.GetNextToken().MakeUpper(); // weight if (tmp == wxT("BOLD")) M_FONTDATA->m_weight = wxFONTWEIGHT_BOLD; if (tmp == wxT("BLACK")) M_FONTDATA->m_weight = wxFONTWEIGHT_BOLD; if (tmp == wxT("EXTRABOLD")) M_FONTDATA->m_weight = wxFONTWEIGHT_BOLD; if (tmp == wxT("DEMIBOLD")) M_FONTDATA->m_weight = wxFONTWEIGHT_BOLD; if (tmp == wxT("ULTRABOLD")) M_FONTDATA->m_weight = wxFONTWEIGHT_BOLD; if (tmp == wxT("LIGHT")) M_FONTDATA->m_weight = wxFONTWEIGHT_LIGHT; if (tmp == wxT("THIN")) M_FONTDATA->m_weight = wxFONTWEIGHT_LIGHT; tmp = tn.GetNextToken().MakeUpper(); // slant if (tmp == wxT("I")) M_FONTDATA->m_style = wxFONTSTYLE_ITALIC; if (tmp == wxT("O")) M_FONTDATA->m_style = wxFONTSTYLE_ITALIC; tn.GetNextToken(); // set width tn.GetNextToken(); // add. style tn.GetNextToken(); // pixel size tmp = tn.GetNextToken(); // pointsize if (tmp != wxT("*")) { long num = wxStrtol (tmp.c_str(), (wxChar **) NULL, 10); M_FONTDATA->m_pointSize = (int)(num / 10); } tn.GetNextToken(); // x-res tn.GetNextToken(); // y-res tmp = tn.GetNextToken().MakeUpper(); // spacing if (tmp == wxT("M")) M_FONTDATA->m_family = wxFONTFAMILY_MODERN; else if (M_FONTDATA->m_faceName == wxT("TIMES")) M_FONTDATA->m_family = wxFONTFAMILY_ROMAN; else if (M_FONTDATA->m_faceName == wxT("HELVETICA")) M_FONTDATA->m_family = wxFONTFAMILY_SWISS; else if (M_FONTDATA->m_faceName == wxT("LUCIDATYPEWRITER")) M_FONTDATA->m_family = wxFONTFAMILY_TELETYPE; else if (M_FONTDATA->m_faceName == wxT("LUCIDA")) M_FONTDATA->m_family = wxFONTFAMILY_DECORATIVE; else if (M_FONTDATA->m_faceName == wxT("UTOPIA")) M_FONTDATA->m_family = wxFONTFAMILY_SCRIPT; tn.GetNextToken(); // avg width // deal with font encoding M_FONTDATA->m_encoding = enc; if ( M_FONTDATA->m_encoding == wxFONTENCODING_SYSTEM ) { wxString registry = tn.GetNextToken().MakeUpper(), encoding = tn.GetNextToken().MakeUpper(); if ( registry == wxT("ISO8859") ) { int cp; if ( wxSscanf(encoding, wxT("%d"), &cp) == 1 ) { M_FONTDATA->m_encoding = (wxFontEncoding)(wxFONTENCODING_ISO8859_1 + cp - 1); } } else if ( registry == wxT("MICROSOFT") ) { int cp; if ( wxSscanf(encoding, wxT("cp125%d"), &cp) == 1 ) { M_FONTDATA->m_encoding = (wxFontEncoding)(wxFONTENCODING_CP1250 + cp); } } else if ( registry == wxT("KOI8") ) { M_FONTDATA->m_encoding = wxFONTENCODING_KOI8; } //else: unknown encoding - may be give a warning here? else return false; } return true; }
void wxFontRefData::InitFromNative() { #if wxUSE_UNICODE // Get native info PangoFontDescription *desc = m_nativeFontInfo.description; // init fields m_faceName = wxGTK_CONV_BACK( pango_font_description_get_family( desc ) ); m_pointSize = pango_font_description_get_size( desc ) / PANGO_SCALE; switch (pango_font_description_get_style( desc )) { case PANGO_STYLE_NORMAL: m_style = wxFONTSTYLE_NORMAL; break; case PANGO_STYLE_ITALIC: m_style = wxFONTSTYLE_ITALIC; break; case PANGO_STYLE_OBLIQUE: m_style = wxFONTSTYLE_SLANT; break; } // Not defined in some Pango versions #define wxPANGO_WEIGHT_SEMIBOLD 600 switch (pango_font_description_get_weight( desc )) { case PANGO_WEIGHT_ULTRALIGHT: case PANGO_WEIGHT_LIGHT: m_weight = wxFONTWEIGHT_LIGHT; break; default: wxFAIL_MSG(wxT("unknown Pango font weight")); // fall through case PANGO_WEIGHT_NORMAL: m_weight = wxFONTWEIGHT_NORMAL; break; case wxPANGO_WEIGHT_SEMIBOLD: case PANGO_WEIGHT_BOLD: case PANGO_WEIGHT_ULTRABOLD: case PANGO_WEIGHT_HEAVY: m_weight = wxFONTWEIGHT_BOLD; break; } if (m_faceName == wxT("monospace")) { m_family = wxFONTFAMILY_TELETYPE; } else if (m_faceName == wxT("sans")) { m_family = wxFONTFAMILY_SWISS; } else { m_family = wxFONTFAMILY_UNKNOWN; } // Pango description are never underlined (?) m_underlined = false; // Cannot we choose that m_encoding = wxFONTENCODING_SYSTEM; #else // X11 // get the font parameters from the XLFD // ------------------------------------- m_faceName = m_nativeFontInfo.GetXFontComponent(wxXLFD_FAMILY); m_weight = wxFONTWEIGHT_NORMAL; wxString w = m_nativeFontInfo.GetXFontComponent(wxXLFD_WEIGHT).Upper(); if ( !w.empty() && w != wxT('*') ) { // the test below catches all of BOLD, EXTRABOLD, DEMIBOLD, ULTRABOLD // and BLACK if ( ((w[0u] == wxT('B') && (!wxStrcmp(w.c_str() + 1, wxT("OLD")) || !wxStrcmp(w.c_str() + 1, wxT("LACK"))))) || wxStrstr(w.c_str() + 1, wxT("BOLD")) ) { m_weight = wxFONTWEIGHT_BOLD; } else if ( w == wxT("LIGHT") || w == wxT("THIN") ) { m_weight = wxFONTWEIGHT_LIGHT; } } switch ( wxToupper( m_nativeFontInfo. GetXFontComponent(wxXLFD_SLANT)[0u]).GetValue() ) { case wxT('I'): // italique m_style = wxFONTSTYLE_ITALIC; break; case wxT('O'): // oblique m_style = wxFONTSTYLE_SLANT; break; default: m_style = wxFONTSTYLE_NORMAL; } long ptSize; if ( m_nativeFontInfo.GetXFontComponent(wxXLFD_POINTSIZE).ToLong(&ptSize) ) { // size in XLFD is in 10 point units m_pointSize = (int)(ptSize / 10); } else { m_pointSize = wxDEFAULT_FONT_SIZE; } // examine the spacing: if the font is monospaced, assume wxTELETYPE // family for compatibility with the old code which used it instead of // IsFixedWidth() if ( m_nativeFontInfo.GetXFontComponent(wxXLFD_SPACING).Upper() == wxT('M') ) { m_family = wxFONTFAMILY_TELETYPE; } else // not monospaceed { // don't even try guessing it, it doesn't work for too many fonts // anyhow m_family = wxFONTFAMILY_UNKNOWN; } // X fonts are never underlined... m_underlined = false; // deal with font encoding wxString registry = m_nativeFontInfo.GetXFontComponent(wxXLFD_REGISTRY).Upper(), encoding = m_nativeFontInfo.GetXFontComponent(wxXLFD_ENCODING).Upper(); if ( registry == wxT("ISO8859") ) { int cp; if ( wxSscanf(encoding, wxT("%d"), &cp) == 1 ) { m_encoding = (wxFontEncoding)(wxFONTENCODING_ISO8859_1 + cp - 1); } } else if ( registry == wxT("MICROSOFT") ) { int cp; if ( wxSscanf(encoding, wxT("cp125%d"), &cp) == 1 ) { m_encoding = (wxFontEncoding)(wxFONTENCODING_CP1250 + cp); } } else if ( registry == wxT("KOI8") ) { m_encoding = wxFONTENCODING_KOI8; } else // unknown encoding { // may be give a warning here? or use wxFontMapper? m_encoding = wxFONTENCODING_SYSTEM; } #endif // Pango/X11 }
bool wxApp::Initialize(int& argC, wxChar **argV) { #if !wxUSE_NANOX // install the X error handler gs_pfnXErrorHandler = XSetErrorHandler( wxXErrorHandler ); #endif wxString displayName; bool syncDisplay = false; int argCOrig = argC; for ( int i = 0; i < argCOrig; i++ ) { if (wxStrcmp( argV[i], wxT("-display") ) == 0) { if (i < (argCOrig - 1)) { argV[i++] = NULL; displayName = argV[i]; argV[i] = NULL; argC -= 2; } } else if (wxStrcmp( argV[i], wxT("-geometry") ) == 0) { if (i < (argCOrig - 1)) { argV[i++] = NULL; int w, h; if (wxSscanf(argV[i], wxT("%dx%d"), &w, &h) != 2) { wxLogError( _("Invalid geometry specification '%s'"), wxString(argV[i]).c_str() ); } else { g_initialSize = wxSize(w, h); } argV[i] = NULL; argC -= 2; } } else if (wxStrcmp( argV[i], wxT("-sync") ) == 0) { syncDisplay = true; argV[i] = NULL; argC--; } else if (wxStrcmp( argV[i], wxT("-iconic") ) == 0) { g_showIconic = true; argV[i] = NULL; argC--; } } if ( argC != argCOrig ) { // remove the arguments we consumed for ( int i = 0; i < argC; i++ ) { while ( !argV[i] ) { memmove(argV + i, argV + i + 1, (argCOrig - i)*sizeof(wxChar *)); } } } // open and set up the X11 display if ( !wxSetDisplay(displayName) ) { wxLogError(_("wxWidgets could not open display. Exiting.")); return false; } Display *dpy = wxGlobalDisplay(); if (syncDisplay) XSynchronize(dpy, True); XSelectInput(dpy, XDefaultRootWindow(dpy), PropertyChangeMask); wxSetDetectableAutoRepeat( true ); if ( !wxAppBase::Initialize(argC, argV) ) return false; #if wxUSE_UNICODE // Glib's type system required by Pango g_type_init(); #endif #if wxUSE_INTL wxFont::SetDefaultEncoding(wxLocale::GetSystemEncoding()); #endif wxWidgetHashTable = new wxWindowHash; wxClientWidgetHashTable = new wxWindowHash; return true; }