+
+bool wxRichTextPlainText::DrawTabbedString(wxDC& dc,const wxRect& rect,wxString& str, wxCoord& x, wxCoord& y, bool selected)
+{
+ wxArrayInt tab_array = GetAttributes().GetTabs();
+ if(tab_array.IsEmpty()){// create a default tab list at 10 mm each.
+ for( int i = 0; i < 20; ++i){
+ tab_array.Add(i*100);
+ }
+ }
+ int map_mode = dc.GetMapMode();
+ dc.SetMapMode(wxMM_LOMETRIC );
+ int num_tabs = tab_array.GetCount();
+ for( int i = 0; i < num_tabs; ++i){
+ tab_array[i] = dc.LogicalToDeviceXRel(tab_array[i]);
+ }
+ dc.SetMapMode(map_mode );
+ int next_tab_pos = -1;
+ int tab_pos = -1;
+ wxCoord w, h;
+ if(selected){
+ dc.SetBrush(*wxBLACK_BRUSH);
+ dc.SetPen(*wxBLACK_PEN);
+ dc.SetTextForeground(*wxWHITE);
+ dc.SetBackgroundMode(wxTRANSPARENT);
+ }
+ else{
+ dc.SetTextForeground(GetAttributes().GetTextColour());
+ dc.SetBackgroundMode(wxTRANSPARENT);
+ }
+ while(str.Find(wxT('\t')) >= 0){// the string has a tab
+ // break up the string at the Tab
+ wxString stringChunk = str.BeforeFirst(wxT('\t'));
+ str = str.AfterFirst(wxT('\t'));
+ dc.GetTextExtent(stringChunk, & w, & h);
+ tab_pos = x + w;
+ bool not_found = true;
+ for( int i = 0; i < num_tabs && not_found; ++i){
+ next_tab_pos = tab_array.Item(i);
+ if( next_tab_pos > tab_pos){
+ not_found = false;
+ if(selected){
+ w = next_tab_pos - x;
+ wxRect selRect(x, rect.y, w, rect.GetHeight());
+ dc.DrawRectangle(selRect);
+ }
+ dc.DrawText(stringChunk, x, y);
+ x = next_tab_pos;
+ }
+ }
+ }
+
+ dc.GetTextExtent(str, & w, & h);
+ if(selected){
+ wxRect selRect(x, rect.y, w, rect.GetHeight());
+ dc.DrawRectangle(selRect);
+ }
+ dc.DrawText(str, x, y);
+ x += w;
+ return true;