/* ** Find the maximum index for the given token */ static void maxIndex(HtmlElement *p, int *pIndex){ if( p==0 ){ *pIndex = 0; TestPoint(0); }else{ switch( p->base.type ){ case Html_Text: *pIndex = p->base.count-1; TestPoint(0); break; case Html_Space: if( p->base.style.flags & STY_Preformatted ){ *pIndex = p->base.count-1; TestPoint(0); }else{ *pIndex = 0; TestPoint(0); } break; default: *pIndex = 0; TestPoint(0); break; } } }
// this function may produce false positives in degenerate cases bool LLRegion::Contains(float lat, float lon) const { if(lon == 180 && Contains(lat, -180)) return true; if(lon > 180) return Contains(lat, lon-360); int cnt = 0; for(std::list<poly_contour>::const_iterator i = contours.begin(); i != contours.end(); i++) { contour_pt l = *i->rbegin(); for(poly_contour::const_iterator j = i->begin(); j != i->end(); j++) { contour_pt p = *j, a, b; if(p.x < l.x) a = p, b = l; else a = l, b = p; if(lon > a.x && lon < b.x) { if(lat > a.y) { if(lat > b.y) cnt++; else cnt += TestPoint(a, b, lon, lat); } else if(lat > b.y) cnt += TestPoint(a, b, lon, lat); } if(lat == a.y || lat == b.y) return true; if(lon == a.x || lon == b.x) return true; l = p; } } return cnt&1; }
/* ** Return a pointer to the Nth HtmlElement in the list. If there ** is no Nth element, return 0 if flag==0 and return either the first ** or last element (whichever is closest) if flag!=0 */ HtmlElement *HtmlTokenByIndex(HtmlWidget *htmlPtr, int N, int flag){ HtmlElement *p; int n; if( N > htmlPtr->nToken/2 ){ /* Start at the end and work back toward the beginning */ for(p=htmlPtr->pLast, n=htmlPtr->nToken; p; p=p->base.pPrev){ if( p->base.type!=Html_Block ){ if( n==N ){ TestPoint(0); break; } n--; TestPoint(0); }else{ TestPoint(0); } } }else{ /* Start at the beginning and work forward */ for(p=htmlPtr->pFirst; p; p = p->base.pNext){ if( p->base.type!=Html_Block ){ N--; if( N<=0 ){ TestPoint(0); break; } }else{ TestPoint(0); } } } return p; }
/* ** Append a block to the block list and insert the block into the ** element list immediately prior to the element given. */ static void AppendBlock( HtmlWidget *htmlPtr, /* The HTML widget */ HtmlElement *pToken, /* The token that comes after pBlock */ HtmlBlock *pBlock /* The block to be appended */ ){ pBlock->base.pPrev = pToken->base.pPrev; pBlock->base.pNext = pToken; pBlock->pPrev = htmlPtr->lastBlock; pBlock->pNext = 0; if( htmlPtr->lastBlock ){ htmlPtr->lastBlock->pNext = pBlock; TestPoint(0); }else{ htmlPtr->firstBlock = pBlock; TestPoint(0); } htmlPtr->lastBlock = pBlock; if( pToken->base.pPrev ){ pToken->base.pPrev->base.pNext = (HtmlElement*)pBlock; TestPoint(0); }else{ htmlPtr->pFirst = (HtmlElement*)pBlock; TestPoint(0); } pToken->base.pPrev = (HtmlElement*)pBlock; }
/* ** Compute the current margins for layout. Three values are returned: ** ** *pY The top edge of the area in which we can put ink. This ** takes into account any requested headroom. ** ** *pX The left edge of the inkable area. The takes into account ** any margin requests active at vertical position specified ** in pLC->bottom. ** ** *pW The width of the inkable area. This takes into account ** an margin requests that are active at the vertical position ** pLC->bottom. ** */ void HtmlComputeMargins( HtmlLayoutContext *pLC, /* The current layout context */ int *pX, /* Put the left edge here */ int *pY, /* Put the top edge here */ int *pW /* Put the width here */ ){ int x, y, w; y = pLC->bottom + pLC->headRoom; PopExpiredMargins(&pLC->leftMargin, pLC->bottom); PopExpiredMargins(&pLC->rightMargin, pLC->bottom); w = pLC->pageWidth - pLC->right; if( pLC->leftMargin ){ x = pLC->leftMargin->indent + pLC->left; TestPoint(0); }else{ x = pLC->left; TestPoint(0); } w -= x; if( pLC->rightMargin ){ w -= pLC->rightMargin->indent; TestPoint(0); }else{ TestPoint(0); } *pX = x; *pY = y; *pW = w; }
/* ** Print an ordered list index into the given buffer. Use numbering ** like this: ** ** A B C ... Y Z AA BB CC ... ZZ ** ** Revert to decimal for indices greater than 52. */ static void GetLetterIndex(char *zBuf, int index, int isUpper){ int seed; if( index<1 || index>52 ){ sprintf(zBuf,"%d",index); TestPoint(0); return; } if( isUpper ){ seed = 'A'; TestPoint(0); }else{ seed = 'a'; TestPoint(0); } index--; if( index<26 ){ zBuf[0] = seed + index; zBuf[1] = 0; TestPoint(0); }else{ index -= 26; zBuf[0] = seed + index; zBuf[1] = seed + index; zBuf[2] = 0; TestPoint(0); } strcat(zBuf,"."); }
/* ** Increase the headroom to create a paragraph break at the current token */ static void Paragraph( HtmlLayoutContext *pLC, HtmlElement *p ){ int headroom; if( p==0 ){ TestPoint(0); return; } if( p->base.type==Html_Text ){ headroom = p->text.ascent + p->text.descent; TestPoint(0); }else if( p->pNext && p->pNext->base.type==Html_Text ){ headroom = p->pNext->text.ascent + p->pNext->text.descent; TestPoint(0); }else{ Tk_FontMetrics fontMetrics; Tk_Font font; font = HtmlGetFont(pLC->htmlPtr, p->base.style.font); if( font==0 ) return; Tk_GetFontMetrics(font, &fontMetrics); headroom = fontMetrics.descent + fontMetrics.ascent; TestPoint(0); } if( pLC->headRoom < headroom && pLC->bottom > pLC->top ){ pLC->headRoom = headroom; } }
bool Plane::Split(const vector<Vector3F>& vIn, vector<Vector3F>& vFront, vector<Vector3F>& vBack) const { if(vIn.empty()) { return false; } unsigned int NumOfInVectors = vIn.size(); if(NumOfInVectors <= 2) { return false; } vFront.clear(); vBack.clear(); int iThisIndex = NumOfInVectors - 1; int iNextIndex = 0; RelativeLocation plThis = TestPoint(vIn[iThisIndex]); RelativeLocation plNext; for(iNextIndex = 0; iNextIndex < NumOfInVectors; ++iNextIndex) { plNext = TestPoint(vIn[iNextIndex]); if(plThis == RL_FRONT) { vFront.push_back(vIn[iThisIndex]); } else if(plThis == RL_BACK) { vBack.push_back(vIn[iThisIndex]); } else { vFront.push_back(vIn[iThisIndex]); vBack.push_back(vIn[iThisIndex]); } if((plThis == RL_FRONT && plNext == RL_BACK) || (plThis == RL_BACK && plNext == RL_FRONT)) { Vector3F vSplit = SplitLine(vIn[iThisIndex], vIn[iNextIndex]); vFront.push_back(vSplit); vBack.push_back(vSplit); } iThisIndex = iNextIndex; plThis = plNext; } if(vFront.size() >= 3 && vBack.size() >= 3) { return true; } return false; }
/* ** Convert a type into a symbolic name */ const char *HtmlTypeToName(int type){ if( type>=Html_A && type<=Html_EndXMP ){ HtmlTokenMap *pMap = apMap[type - Html_A]; TestPoint(0); return pMap->zName; }else{ TestPoint(0); return "???"; } }
/* ** Print an ordered list index into the given buffer. Use roman ** numerals. For indices greater than a few thousand, revert to ** decimal. */ static void GetRomanIndex(char *zBuf, int index, int isUpper){ int i = 0; int j; static struct { int value; char *name; } values[] = { { 1000, "m" }, { 999, "im" }, { 990, "xm" }, { 900, "cm" }, { 500, "d" }, { 499, "id" }, { 490, "xd" }, { 400, "cd" }, { 100, "c" }, { 99, "ic" }, { 90, "xc" }, { 50, "l" }, { 49, "il" }, { 40, "xl" }, { 10, "x" }, { 9, "ix" }, { 5, "v" }, { 4, "iv" }, { 1, "i" }, }; if( index<1 || index>=5000 ){ sprintf(zBuf,"%d",index); TestPoint(0); return; } for(j=0; index>0 && j<sizeof(values)/sizeof(values[0]); j++){ int k; while( index >= values[j].value ){ for(k=0; values[j].name[k]; k++){ zBuf[i++] = values[j].name[k]; TestPoint(0); } index -= values[j].value; TestPoint(0); } } zBuf[i] = 0; if( isUpper ){ for(i=0; zBuf[i]; i++){ zBuf[i] += 'A' - 'a'; TestPoint(0); } }else{ TestPoint(0); } strcat(zBuf,"."); }
/* ** Return TRUE (non-zero) if we are currently wrapping text around ** one or more images. */ static int InWrapAround(HtmlLayoutContext *pLC){ if( pLC->leftMargin && pLC->leftMargin->bottom >= 0 ){ TestPoint(0); return 1; } if( pLC->rightMargin && pLC->rightMargin->bottom >= 0 ){ TestPoint(0); return 1; } TestPoint(0); return 0; }
bool Plane::Split(const Polygon<Vector3F>& mpIn, Polygon<Vector3F>* pmpFront, Polygon<Vector3F>* pmpBack) const { if(!pmpFront || !pmpBack || mpIn.m_iCurrentNumVectors <= 2) { return false; } pmpFront->m_iCurrentNumVectors = 0; pmpBack->m_iCurrentNumVectors = 0; int iThisIndex = mpIn.m_iCurrentNumVectors - 1; int iNextIndex = 0; RelativeLocation plThis = TestPoint(mpIn.m_vList[iThisIndex]); RelativeLocation plNext; for(; iNextIndex < mpIn.m_iCurrentNumVectors; ++iNextIndex) { plNext = TestPoint(mpIn.m_vList[iNextIndex]); if(plThis == RL_FRONT) { pmpFront->m_vList[pmpFront->m_iCurrentNumVectors++] = mpIn.m_vList[iThisIndex]; } else if(plThis == RL_BACK) { pmpBack->m_vList[pmpBack->m_iCurrentNumVectors++] = mpIn.m_vList[iThisIndex]; } else { pmpFront->m_vList[pmpFront->m_iCurrentNumVectors++] = mpIn.m_vList[iThisIndex]; pmpBack->m_vList[pmpBack->m_iCurrentNumVectors++] = mpIn.m_vList[iThisIndex]; } if((plThis == RL_FRONT && plNext == RL_BACK) || (plThis == RL_BACK && plNext == RL_FRONT)) { Vector3F mvSplit = SplitLine(mpIn.m_vList[iThisIndex], mpIn.m_vList[iNextIndex]); pmpFront->m_vList[pmpFront->m_iCurrentNumVectors++] = mvSplit; pmpBack->m_vList[pmpBack->m_iCurrentNumVectors++] = mvSplit; } iThisIndex = iNextIndex; plThis = plNext; } if(pmpFront->m_iCurrentNumVectors >= 3 && pmpBack->m_iCurrentNumVectors >= 3) { return true; } return false; }
/* ** Return the token number for the given HtmlElement */ int HtmlTokenNumber(HtmlElement *p){ int n = 0; while( p ){ if( p->base.type!=Html_Block ){ TestPoint(0); n++; }else{ TestPoint(0); } p = p->base.pPrev; } return n; }
BOOL CChildWnd::IsPartiallyVisible() { if ( IsWindowVisible() == FALSE || IsIconic() == TRUE ) return FALSE; CRect rc; GetClientRect( &rc ); ClientToScreen( &rc ); return TestPoint( rc.CenterPoint() ) || TestPoint( CPoint( rc.left + 1, rc.top + 1 ) ) || TestPoint( CPoint( rc.right - 1, rc.top + 1 ) ) || TestPoint( CPoint( rc.left + 1, rc.bottom - 2 ) ) || TestPoint( CPoint( rc.right - 2, rc.bottom - 2 ) ); }
/* Draw the selection background for the given block */ static void DrawSelectionBackground( HtmlWidget *htmlPtr, /* The HTML widget */ HtmlBlock *pBlock, /* The block whose background is drawn */ Drawable drawable, /* Draw the background on this drawable */ int x, int y /* Virtual coords of top-left of drawable */ ){ int xLeft, xRight; /* Left and right bounds of box to draw */ int yTop, yBottom; /* Top and bottom of box */ HtmlElement *p = 0; /* First element of the block */ Tk_Font font; /* Font */ GC gc; /* GC for drawing */ XRectangle xrec; /* Size of a filled rectangle to be drawn */ if( pBlock==0 || (pBlock->base.flags & HTML_Selected)==0 ){ TestPoint(0); return; } xLeft = pBlock->left - x; if( pBlock==htmlPtr->pSelStartBlock && htmlPtr->selStartIndex>0 ){ if( htmlPtr->selStartIndex >= pBlock->n ){ TestPoint(0); return; } p = pBlock->base.pNext; font = HtmlGetFont(htmlPtr, p->base.style.font); if( font==0 ) return; if( p->base.type==Html_Text ){ xLeft = p->text.x - x + Tk_TextWidth(font, pBlock->z, htmlPtr->selStartIndex); } } xRight = pBlock->right - x; if( pBlock==htmlPtr->pSelEndBlock && htmlPtr->selEndIndex<pBlock->n ){ if( p==0 ){ p = pBlock->base.pNext; font = HtmlGetFont(htmlPtr, p->base.style.font); if( font==0 ) return; } if( p->base.type==Html_Text ){ xRight = p->text.x - x + Tk_TextWidth(font, pBlock->z, htmlPtr->selEndIndex); } } yTop = pBlock->top - y; yBottom = pBlock->bottom - y; gc = HtmlGetGC(htmlPtr, COLOR_Selection, FONT_Any); xrec.x = xLeft; xrec.y = yTop; xrec.width = xRight - xLeft; xrec.height = yBottom - yTop; XFillRectangles(htmlPtr->display, drawable, gc, &xrec, 1); }
void CFindBestPoint::FindBestPoint(int x,int y, int *bestx, int *besty, const char *tiles) { //printf("col:%d row:%d\nx:%d y:%d",m_col, m_row,x,y); if( x < 0 || x >= m_col || y < 0 || y >= m_row ) {//此结点不合法 *bestx = -1;*besty = -1; return; } //初始化数组 for(int i = 0;i < m_row;i ++) { for(int j = 0;j < m_col;j ++) { m_visited[i][j]=false; } } if(tiles[INDEX(x,y)])//检查是否能通过 {//如果能通过 *bestx = x;*besty = y; return; } m_visited[y][x] = true; //标记已访问 long u; m_que.push(POS(x,y)); //初始结点v入队列 while(!m_que.empty()) //队列非空时 { u = m_que.front();m_que.pop(); //出队列 //右下 if(TestPoint(POS_X(u)+1, POS_Y(u)+1, bestx, besty, tiles))break; //下 if(TestPoint(POS_X(u), POS_Y(u)+1, bestx, besty, tiles))break; //左下 if(TestPoint(POS_X(u)-1, POS_Y(u)+1, bestx, besty, tiles))break; //左 if(TestPoint(POS_X(u)-1, POS_Y(u), bestx, besty, tiles))break; //左上 if(TestPoint(POS_X(u)-1, POS_Y(u)-1, bestx, besty, tiles))break; //上 if(TestPoint(POS_X(u), POS_Y(u)-1, bestx, besty, tiles))break; //右上 if(TestPoint(POS_X(u)+1, POS_Y(u)-1, bestx, besty, tiles))break; //右 if(TestPoint(POS_X(u)+1, POS_Y(u), bestx, besty, tiles))break; } m_que.c.clear(); }
/* ** This routine is called when an image changes. If the size of the ** images changes, then we need to completely redo the layout. If ** only the appearance changes, then this works like an expose event. */ static void ImageChangeProc( ClientData clientData, /* Pointer to an HtmlImage structure */ int x, /* Left edge of region that changed */ int y, /* Top edge of region that changed */ int w, /* Width of region that changes. Maybe 0 */ int h, /* Height of region that changed. Maybe 0 */ int newWidth, /* New width of the image */ int newHeight /* New height of the image */ ){ HtmlImage *pImage; HtmlWidget *htmlPtr; HtmlElement *pElem; pImage = (HtmlImage*)clientData; htmlPtr = pImage->htmlPtr; if( pImage->w!=newWidth || pImage->h!=newHeight ){ /* We have to completely redo the layout after adjusting the size ** of the images */ for(pElem = pImage->pList; pElem; pElem = pElem->image.pNext){ pElem->image.w = newWidth; pElem->image.h = newHeight; TestPoint(0); } htmlPtr->flags |= RELAYOUT; pImage->w = newWidth; pImage->h = newHeight; HtmlRedrawEverything(htmlPtr); }else{ for(pElem = pImage->pList; pElem; pElem = pElem->image.pNext){ pElem->image.redrawNeeded = 1; } htmlPtr->flags |= REDRAW_IMAGES; HtmlScheduleRedraw(htmlPtr); } }
vec_type Polyhedron<plane_itt>::SurfProject(const vector_t &p, vector_t *surfp, vector_t *surfn) const{ bool in=TestPoint(p); vec_type t = in ? numeric_limits<vec_type>::max() : -numeric_limits<vec_type>::max(); Vector_3 n; for(plane_it pi=b;pi!=e;++pi){ Vector_3 vnorm=(*pi).get_normal(); // dist>0 - я вхожу в плоскость изнутри, dist<0 - снаружи vec_type dist=(*pi).distance(p); // distance to the plane if(in && dist>=0){ // right bound, searching minimum if(t>dist){ t=dist; n=vnorm; } } else if(!in && dist<0){// left bound, searching maximum if(t<dist){ t=dist; n=vnorm; } } } if(surfp) *surfp=p+n*t; if(surfn) *surfn=-n; return t; }
/******************************************************** * Plane data type implementation * ********************************************************/ ePListLoc TSRPlane::TestPoints( TSRVector3 *_pPoints, unsigned int _uiPointsCount ) const { bool allfront = true, allback = true; ePointLoc res; for ( unsigned int i = 0; i < _uiPointsCount; i++ ) { res = TestPoint( _pPoints[ i ] ); if( res == ptBack ) { allfront = false; } else if( res == ptFront ) { allback = false; } } if ( allfront && !allback ) { // All the points were either in front or coplanar return plistFront; } else if ( !allfront && allback ) { // All the points were either in back or coplanar return plistBack; } else if ( !allfront && !allback ) { // Some were in front, some were in back return plistSplit; } // All were coplanar return plistCoplanar; }
bool DoEvent( EventBase* evt ) { switch( evt->GetType( ) ) { case EventType::INPUT_MOUSEUP: { MouseEvent* revt = (MouseEvent*)evt; if( TestPoint( revt->x, revt->y ) ) { OverlayEvent evt( EventType::OVERLAY_SETSELECTED, this ); RaiseEvent( &evt ); }; break; } case EventType::OVERLAY_SELECTED: { SetColor( 0xFF00FF00 ); break; }; case EventType::OVERLAY_UNSELECTED: { SetColor( 0xFFFFFFFF ); break; }; }; return false; };
bool DoEvent( EventBase* evt ) { switch( evt->GetType( ) ) { case EventType::OVERLAY_FOCUSED: { printf( "Focus event: %08x\n", this ); mCaretPos = mText.length( ); break; }; case EventType::OVERLAY_UNFOCUSED: { printf( "Unfocus event: %08x\n", this ); mCaretPos = -1; break; }; case EventType::INPUT_MOUSEUP: { MouseEvent* revt = (MouseEvent*)evt; if( TestPoint( revt->x, revt->y ) ) { OverlayEvent evt( EventType::OVERLAY_SETFOCUS, this ); RaiseEvent( &evt ); return true; } break; } case EventType::INPUT_KEYDOWN: { KeyEvent* revt = (KeyEvent*)evt; if( revt->key == KeyCode::BACK ) { if( ~revt->modifiers & 1 ) mText = mText.substr( 0, mText.length( ) - 1 ); else mText.clear( ); return true; } char c = 0; if( ~revt->modifiers & 1 ) c = KeyCode::TOCHARDN[ revt->key ]; else c = KeyCode::TOCHARUP[ revt->key ]; if( c != 0 ) { mText.push_back( c ); OverlayEvent evt( EventType::OVERLAY_TEXTCHANGED, this ); RaiseEvent( &evt ); } return true; break; } }; return false; };
/* Hash a escape sequence name. The value returned is an integer ** between 0 and ESC_HASH_SIZE-1, inclusive. */ static int EscHash(const char *zName){ int h = 0; /* The hash value to be returned */ char c; /* The next character in the name being hashed */ while( (c=*zName)!=0 ){ h = h<<5 ^ h ^ c; zName++; TestPoint(0); } if( h<0 ){ h = -h; TestPoint(0); }else{ TestPoint(0); } return h % ESC_HASH_SIZE; }
/* ** Destroy the given Block after first unlinking it from the ** element list. Note that this unlinks the block from the ** element list only -- not from the block list. */ static void UnlinkAndFreeBlock(HtmlWidget *htmlPtr, HtmlBlock *pBlock){ if( pBlock->base.pNext ){ pBlock->base.pNext->base.pPrev = pBlock->base.pPrev; TestPoint(0); }else{ htmlPtr->pLast = pBlock->base.pPrev; TestPoint(0); } if( pBlock->base.pPrev ){ pBlock->base.pPrev->base.pNext = pBlock->base.pNext; TestPoint(0); }else{ htmlPtr->pFirst = pBlock->base.pNext; TestPoint(0); } pBlock->base.pPrev = pBlock->base.pNext = 0; FreeBlock(pBlock); }
/* ** This routine decodes a complete index specification. A complete ** index consists of the base specification followed by modifiers. */ int HtmlGetIndex( HtmlWidget *htmlPtr, /* The widget */ const char *zIndex, /* Complete text of the index spec */ HtmlElement **ppToken, /* Write the pointer to the token here */ int *pIndex /* Write the character offset here */ ){ TestPoint(0); return DecodeBaseIndex(htmlPtr, zIndex, ppToken, pIndex); }
/* ** Convert a markup name into a type integer */ int HtmlNameToType(char *zType){ HtmlTokenMap *pMap; /* For searching the markup name hash table */ int h; /* The hash on zType */ if( !isInit ){ HtmlHashInit(); isInit = 1; TestPoint(0); }else{ TestPoint(0); } h = HtmlHash(zType); for(pMap = apMap[h]; pMap; pMap=pMap->pCollide){ if( stricmp(pMap->zName,zType)==0 ){ TestPoint(0); break; } TestPoint(0); } return pMap ? pMap->type : Html_Unknown; }
static void CheckCpp() { TestPoint(); TestView(); TestFrame(); TestPyramid(); }
/* ** Push a new margin onto the given margin stack. ** ** If the "bottom" parameter is non-negative, then this margin will ** automatically expire for all text that is placed below the y-coordinate ** given by "bottom". This feature is used for <IMG ALIGN=left> ** and <IMG ALIGN=right> kinds of markup. It allows text to flow around ** an image. ** ** If "bottom" is negative, then the margin stays in force until ** it is explicitly canceled by a call to HtmlPopMargin(). */ void HtmlPushMargin( HtmlMargin **ppMargin, /* The margin stack onto which to push */ int indent, /* The indentation for the new margin */ int bottom, /* The margin expires at this Y coordinate */ int tag /* Markup that will cancel this margin */ ){ HtmlMargin *pNew = HtmlAlloc( sizeof(HtmlMargin) ); pNew->pNext = *ppMargin; if( pNew->pNext ){ pNew->indent = indent + pNew->pNext->indent; TestPoint(0); }else{ pNew->indent = indent; TestPoint(0); } pNew->bottom = bottom; pNew->tag = tag; *ppMargin = pNew; }
/* ** Lookup an argument in the given markup with the name given. ** Return a pointer to its value, or the given default ** value if it doesn't appear. */ char *HtmlMarkupArg(HtmlElement *p, const char *tag, char *zDefault){ int i; if( !HtmlIsMarkup(p) ){ TestPoint(0); return 0; } for(i=0; i<p->base.count; i+=2){ if( strcmp(p->markup.argv[i],tag)==0 ){ return p->markup.argv[i+1]; } } return zDefault; }
/* ** Draw all or part of an image. */ void HtmlDrawImage( HtmlElement *pElem, /* The <IMG> to be drawn */ Drawable drawable, /* Draw it here */ int drawableLeft, /* left edge of the drawable */ int drawableTop, /* Virtual canvas coordinate for top of drawable */ int drawableRight, /* right edge of the drawable */ int drawableBottom /* bottom edge of the drawable */ ){ int imageTop; /* virtual canvas coordinate for top of image */ int x, y; /* where to place image on the drawable */ int imageX, imageY; /* \__ Subset of image that fits */ int imageW, imageH; /* / on the drawable */ imageTop = pElem->image.y - pElem->image.ascent; y = imageTop - drawableTop; if( imageTop + pElem->image.h > drawableBottom ){ imageH = drawableBottom - imageTop; TestPoint(0); }else{ imageH = pElem->image.h; TestPoint(0); } if( y<0 ){ imageY = -y; imageH += y; y = 0; TestPoint(0); }else{ imageY = 0; TestPoint(0); } x = pElem->image.x - drawableLeft; if( pElem->image.x + pElem->image.w > drawableRight ){ imageW = drawableRight - pElem->image.x; TestPoint(0); }else{ imageW = pElem->image.w; TestPoint(0); } if( x<0 ){ imageX = -x; imageW += x; x = 0; TestPoint(0); }else{ imageX = 0; TestPoint(0); } Tk_RedrawImage(pElem->image.pImage->image, imageX, imageY, imageW, imageH, drawable, x, y); pElem->image.redrawNeeded = 0; }
/* ** Append text to the tokenizer engine. ** ** This routine (actually the Tokenize() subroutine that is called ** by this routine) may invoke a callback procedure which could delete ** the HTML widget. */ void HtmlTokenizerAppend(HtmlWidget *htmlPtr, const char *zText){ int len = strlen(zText); if( htmlPtr->nText==0 ){ htmlPtr->nAlloc = len + 100; htmlPtr->zText = HtmlAlloc( htmlPtr->nAlloc ); TestPoint(0); }else if( htmlPtr->nText + len >= htmlPtr->nAlloc ){ htmlPtr->nAlloc += len + 100; htmlPtr->zText = HtmlRealloc( htmlPtr->zText, htmlPtr->nAlloc ); TestPoint(0); } if( htmlPtr->zText==0 ){ htmlPtr->nText = 0; UNTESTED; return; } strcpy(&htmlPtr->zText[htmlPtr->nText], zText); htmlPtr->nText += len; htmlPtr->nComplete = Tokenize(htmlPtr); }