void KouhoView::HighlightPartial( int32 begin, int32 end ) { BRegion region; GetTextRegion( begin, end, ®ion ); highlightRect = region.RectAt( 0 ); Invalidate( highlightRect ); }
HyperTextAction* HyperTextView::_ActionAt(const BPoint& where) const { int32 offset = OffsetAt(where); ActionInfo pointer(offset, offset + 1, NULL); const ActionInfo* action = fActionInfos->BinarySearch(pointer, ActionInfo::CompareEqualIfIntersecting); if (action != NULL) { // verify that the text region was hit BRegion textRegion; GetTextRegion(action->startOffset, action->endOffset, &textRegion); if (textRegion.Contains(where)) return action->action; } return NULL; }
void KouhoView::HighlightLine( int32 line ) { //printf( "highlightLine set to :%d\n", line); int32 begin, end; BRegion region; if ( line != -1 ) { begin = OffsetAt( line ); if ( line == CountLines() - 1 ) end = TextLength() + 1; else end = OffsetAt( line + 1 ) - 1; //printf( "Highlight line:%d, offset %d-%d\n", line,begin,end); GetTextRegion( begin, end, ®ion ); //as hightlight is just one line, 0 is enough. highlightRect = region.RectAt( 0 ); //extend highlihght region to right end highlightRect.right = Bounds().right; Invalidate( highlightRect ); } }
AboutTextView(BRect rect) : BTextView(rect,NULL,rect.OffsetToCopy(B_ORIGIN),B_FOLLOW_NONE,B_WILL_DRAW) { int32 major = 0,middle = 0,minor = 0,variety = 0,internal = 1; // get version information for app app_info appInfo; if (be_app->GetAppInfo(&appInfo) == B_OK) { BFile file(&appInfo.ref,B_READ_ONLY); if (file.InitCheck() == B_OK) { BAppFileInfo info(&file); if (info.InitCheck() == B_OK) { version_info versionInfo; if (info.GetVersionInfo(&versionInfo,B_APP_VERSION_KIND) == B_OK) { major = versionInfo.major; middle = versionInfo.middle; minor = versionInfo.minor; variety = versionInfo.variety; internal = versionInfo.internal; } } } } // prepare version variety string const char *varietyStrings[] = {"Development","Alpha","Beta","Gamma","Golden master","Final"}; char varietyString[32]; strcpy(varietyString,varietyStrings[variety % 6]); if (variety < 5) sprintf(varietyString + strlen(varietyString),"/%li",internal); char s[512]; sprintf(s, "Mail Daemon Replacement\n\n" "by Dr. Zoidberg Enterprises. All rights reserved.\n\n" "Version %ld.%ld.%ld %s\n\n" "See LICENSE file included in the installation package for more information.\n\n\n\n" "You can contact us at:\n" "%s\n\n" "Please submit bug reports using the %s\n\n" "Project homepage at:\n%s", major,middle,minor,varietyString, kEMail,kBugsitePretty,kWebsite); SetText(s); MakeEditable(false); MakeSelectable(false); SetAlignment(B_ALIGN_CENTER); SetStylable(true); // aethetical changes BFont font; GetFont(&font); font.SetSize(24); SetFontAndColor(0,23,&font,B_FONT_SIZE); // center the view vertically rect = TextRect(); rect.OffsetTo(0,(Bounds().Height() - TextHeight(0,42)) / 2); SetTextRect(rect); // set the link regions int start = strstr(s,kEMail) - s; int finish = start + strlen(kEMail); GetTextRegion(start,finish,&fMail); SetFontAndColor(start,finish,NULL,0,&kLinkColor); start = strstr(s,kBugsitePretty) - s; finish = start + strlen(kBugsitePretty); GetTextRegion(start,finish,&fBugsite); SetFontAndColor(start,finish,NULL,0,&kLinkColor); start = strstr(s,kWebsite) - s; finish = start + strlen(kWebsite); GetTextRegion(start,finish,&fWebsite); SetFontAndColor(start,finish,NULL,0,&kLinkColor); }