//cWindowOutputCtrl::cWindowOutputCtrl(wxWindow *Parent, wxWindowID ID, const wxString& value, const wxPoint& pos, const wxSize& size, long style, const wxValidator& validator, const wxString& name) : wxRichTextCtrl(Parent,ID,value,pos,size,style,validator,name) { cWindowOutputCtrl::cWindowOutputCtrl(wxWindow *Parent, wxWindowID ID, const wxPoint& pos, const wxSize& size, long style, const wxString& name) : wxHtmlWindow(Parent,ID,pos,size,style,name) { EnableScrolling(false,true); int FontSizes[7] = {6,8,10,12,14,16,18}; SetFonts(GUI->m_Font->GetFaceName(),GUI->m_Font->GetFaceName(),FontSizes); AppendToPage("<font style='background-color: #333333'>ABC</font>"); }
void cWindowOutputCtrl::AppendFormattedText(const wxString &Str, int style, ChannelWindowColor color) { Freeze(); wxString& String = wxString(Str); HtmlEntities(String); bool Underline = false; bool Bold = false; int BgColor = (int)COLOR_WHITE; int Color = (int)color; wxString& ps = wxString(""); for (unsigned int i = 0; i < String.Len(); i++) { wxString& s = String.Mid(i,1); if (!s.Cmp(wxString::Format("%c",2))) { if (Bold) { Bold = false; } else { Bold = true; } } else if (!s.Cmp(wxString::Format("%c",3))) { wxString& Mid11 = String.Mid(i+1,1); wxString& Mid12 = String.Mid(i+1,2); wxString& Mid21 = String.Mid(i+2,1); wxString& Mid22 = String.Mid(i+2,2); wxString& Mid31 = String.Mid(i+3,1); wxString& Mid32 = String.Mid(i+3,2); wxString& Mid41 = String.Mid(i+4,1); wxString& Mid42 = String.Mid(i+4,2); if (Mid12.IsNumber() && atoi(Mid12) > 0 && atoi(Mid12) <= 15) { Color = atoi(Mid12); i += 2; if (Mid31 == ",") { if (Mid42.IsNumber() && atoi(Mid42) > 0 && atoi(Mid42) <= 15) { BgColor = atoi(Mid42); i += 3; } else if (Mid41.IsNumber() && (!Mid41.Cmp("0") || (atoi(Mid41) > 0 && atoi(Mid41) <= 9))) { BgColor = atoi(Mid41); i += 2; } } } else if (Mid11.IsNumber() && (!Mid11.Cmp("0") || (atoi(Mid11) > 0 && atoi(Mid11) <= 9))) { Color = atoi(Mid11); i += 1; if (Mid21 == ",") { if (Mid32.IsNumber() && atoi(Mid32) > 0 && atoi(Mid32) <= 15) { BgColor = atoi(Mid32); i += 3; } else if (Mid31.IsNumber() && (!Mid31.Cmp("0") || (atoi(Mid31) > 0 && atoi(Mid31) <= 9))) { BgColor = atoi(Mid31); i += 2; } } } else { Color = (int)color; BgColor = (int)COLOR_WHITE; } ps.Append(wxString::Format("</font><font color='#%s' bgcolor='#%s'>",GetWxColorStringFromInt(GetIntColorFromEnum(Color)).c_str(),GetWxColorStringFromInt(GetIntColorFromEnum(BgColor)).c_str())); } else if (!s.Cmp(wxString::Format("%c",15))) { Underline = false; Bold = false; int StyleToApply = style; if (StyleToApply >= STYLE_UNDERLINE) { StyleToApply -= STYLE_UNDERLINE; Underline = true; } if (StyleToApply >= STYLE_BOLD) { StyleToApply -= STYLE_BOLD; Bold = true; } Color = (int)color; } else if (!s.Cmp(wxString::Format("%c",31))) { if (Underline) { Underline = false; } else { Underline = true; } } else { if (Bold) { s.Prepend("<b>"); s.Append("</b>"); } if (Underline) { s.Prepend("<u>"); s.Append("</u>"); } ps.Append(s); } } AppendToPage(wxString::Format("<br /><font color='#%s' bgcolor='#%s'>%s</font>",GetWxColorStringFromInt(GetIntColorFromEnum((int)color)).c_str(),GetWxColorStringFromInt(GetIntColorFromEnum((int)COLOR_WHITE)).c_str(),ps.c_str())); Scroll(-1,INT_MAX); Thaw(); }
void SjHtmlWindow::AddPropToPage(SjProp& prop) { wxString temp, code, value; #define TABLE_START wxT("<table border=\"0\" cellpadding=\"1\" cellspacing=\"0\">") #define TABLE_END wxT("</table>") bool tableStarted = FALSE; prop.InitIterator(); while( prop.Next() ) { long flags = prop.GetFlags(); if( flags & SJ_PROP_HEADLINE ) { if( tableStarted ) { code += TABLE_END; tableStarted = FALSE; } code += wxT("<h1>") + SjTools::Htmlentities(prop.GetName()) + wxT("</h1>"); } else { if( !tableStarted ) { code += TABLE_START; tableStarted = TRUE; } code += wxT("<tr><td width=\"30%\" valign=\"top\">"); if( flags & SJ_PROP_BOLD ) { code += wxT("<b>"); } if( !prop.GetName().IsEmpty() ) { temp = SjTools::Htmlentities(prop.GetName()); temp.Replace(wxT(" "), wxT(" ")); code += temp; code += wxT(":"); } if( flags & SJ_PROP_BOLD ) { code += wxT("</b>"); } code += wxT("</td><td valign=\"top\" width=\"70%\">"); value = prop.GetValue().Trim(TRUE).Trim(FALSE); if( flags & SJ_PROP_EMPTYIFEMPTY && (value.IsEmpty() || value==_("n/a") || value==wxT("n/a")) ) { code += wxT("<font color=\"#808080\">"); code += _("n/a"); code += wxT("</font>"); } else if( flags & SJ_PROP_ID ) { code += wxString::Format(wxT("<a href=\"id:%i\">"), (int)(flags&0x0000FFFFL)); code += SjTools::Htmlentities(value); code += wxT("</a>"); } else if( flags & SJ_PROP_HTML ) { code += value; } else if( g_tools->IsUrlExplorable(value) ) { code += wxString::Format(wxT("<a href=\"ext:/") wxT("/%s\">"), SjTools::Htmlentities(value).c_str()); code += SjTools::Htmlentities(value); code += wxT("</a>"); } else { code += SjTools::Htmlentities(value); } code += wxT("</td></tr>"); } } if( tableStarted ) { code += TABLE_END; } AppendToPage(code); }