Home || Architecture || Video Search || Visual Search || Scripts || Applications || Important Messages || OGL || Src

int OglGui::TextEdit::FindWidthAtIndex ( string str,
int  ind 
) [inline]

Definition at line 476 of file TextEdit.h.

References mLeftMargin, and OglGui::OglWindow::mOglWnd.

Referenced by ComputeCaretPosition(), ComputeMaxWidth(), DrawText(), FindIndexAtWidth(), FindInsertionIndexAtWidth(), and HandleInvertLineSelection().

00477     {
00478         char    buf[2048];
00479         int     w, h;
00480         void*   font;
00481 
00482         int     tPos, tInd = 0, tCnt = 0, tabW;
00483         int     totWidth = 0;
00484         string  tabStr;
00485 
00486         if (ind > str->length())
00487             ind = str->length();
00488         if (ind > 2047)
00489             ind = 2047;
00490 
00491         FindOglFont(mOglWnd, &font, NULL);
00492 
00493         if ((tPos = str->find_first_of("\t")) == string::npos)
00494         {
00495             buf[0] = '\0';
00496             strncpy(buf, str->c_str(), ind);
00497             buf[ind] = '\0';
00498             oglSys.AbstFontTextSize(mOglWnd, font, buf, &w, &h);
00499             return mLeftMargin + w;
00500         }
00501 
00502         oglSys.AbstFontTextSize(mOglWnd, font, "    ", &w, &h);
00503         tabW = w;
00504 
00505         bool done = false;
00506         while (!done && ((tPos = str->find_first_of("\t",tInd)) != string::npos))
00507         {
00508             tabStr = str->substr(tInd, tPos-tInd);
00509             if (ind > tInd + tabStr.length())
00510             {
00511                 oglSys.AbstFontTextSize(mOglWnd, font, tabStr.c_str(), &w, &h);
00512                 tCnt = (totWidth + w) / tabW + 1;
00513                 totWidth = tCnt * tabW;
00514             }
00515             else
00516             {
00517                 tabStr = tabStr.substr(0, ind - tInd);
00518                 oglSys.AbstFontTextSize(mOglWnd, font, tabStr.c_str(), &w, &h);
00519                 totWidth += w;
00520                 done = true;
00521             }
00522             tInd = tPos+1;
00523         }
00524         if (!done)
00525         {
00526             tabStr = str->substr(tInd, ind - tInd);
00527             oglSys.AbstFontTextSize(mOglWnd, font, tabStr.c_str(), &w, &h);
00528             totWidth += w;
00529         }
00530         return mLeftMargin + totWidth;
00531     }


Generated on Fri Mar 19 12:08:01 2010 for ImpalaSrc by  doxygen 1.5.1