Exemple #1
0
/*
 * PositionVerticalScrollThumb - draw the scroll thumb on the screen
 */
void PositionVerticalScrollThumb( window_id wn, linenum curr, linenum last )
{
    wind        *w;
    int         height;
    int         newpos;

    w = AccessWindow( wn );
    if( !w->has_gadgets || !w->has_border ) {
        ReleaseWindow( w );
        return;
    }
    height = w->y2 - w->y1 - THUMB_START * 2;
    if( height <= 0 ) {
        newpos = 0;
    } else if( curr == 1 ) {
        newpos = THUMB_START;
    } else {
        newpos = (int)(((long) (height - 1) * curr) / last) + THUMB_START + 1;
    }
    if( w->vert_scroll_pos != newpos ) {
        DrawVerticalThumb( w, EditVars.GadgetString[WB_RIGHTSIDE] );
    }
    w->vert_scroll_pos = newpos;
    DrawVerticalThumb( w, EditVars.GadgetString[WB_THUMB] );

    ReleaseWindow( w );

} /* PositionVerticalScrollThumb */
Exemple #2
0
void CmusikTrackCtrl::OnNMCustomdraw(NMHDR *pNMHDR, LRESULT *pResult)
{
	LPNMCUSTOMDRAW lpcd = (LPNMCUSTOMDRAW)pNMHDR;

	// CDDS_PREPAINT is at the beginning of the paint cycle. 
	// this will fire first, so we tell it we want
	// all item drawing information...
	if ( lpcd->dwDrawStage == CDDS_PREPAINT )
	{
		// Request prepaint notifications for each item.
		*pResult = CDRF_NOTIFYITEMDRAW;         
		return;
	}

	// CDDS_ITEMPREPAINT is sent when an item is about
	// to be drawn..
	if ( lpcd->dwDrawStage == CDDS_ITEMPREPAINT )
	{	
		CDC *pDC = CDC::FromHandle( lpcd->hdc );
		CRect rect( lpcd->rc );

		// we don't want to draw any ticks,
		// so just skip the default action
		// and return...
		if ( lpcd->dwItemSpec == TBCD_TICS )
		{
			ReleaseDC( pDC );

			*pResult = CDRF_SKIPDEFAULT;
			return;
		}

		// drawing the thumb
		else if ( lpcd->dwItemSpec == TBCD_THUMB )
		{
			CRect rcThumbDraw;
			if ( rect.Height() > rect.Width() )
				DrawHorizontalThumb( pDC, rect );
			else
				DrawVerticalThumb( pDC, rect );
		}

		// drawing the channel, the space
		// below the thumb
		else if ( lpcd->dwItemSpec == TBCD_CHANNEL )
		{
			CRect rcThumb;
			GetThumbRect(rcThumb);

			DrawChannel( pDC, rect, ( rcThumb.Height() > rcThumb.Width() ) );
		}

		*pResult = CDRF_SKIPDEFAULT;
		return;
	}

	*pResult = CDRF_SKIPDEFAULT;
}
Exemple #3
0
/*
 * DrawBorder - display border
 */
void DrawBorder( window_id wn )
{
    wind                *w;
    int                 i, j, k, stc, etc, ctc;
    int                 tl, bl, tr, br;
    int                 xtl, xbl, xtr, xbr;
    char                *over, c;
    unsigned short      clr;
    char_info           what, what2;
    char_info           _FAR *scr;
    char_info           *txt;
    int                 topscol, topecol, topccol;
    char                *wb;

    if( EditFlags.Quiet ) {
        return;
    }
    if( !Windows[wn]->has_border ) {
        return;
    }
    w = AccessWindow( wn );
    txt = (char_info *) w->text;
    over = w->overlap;
    scr = (char_info _FAR *) Scrn;

    if( w->has_gadgets ) {
        wb = GadgetString;
    } else {
        wb = WindowBordersNG;
    }

    /*
     * set up for border addendums (title and misc top data)
     */
    if( w->title != NULL ) {
        stc = (w->width - strlen( w->title )) / 2 - 1;
        if( stc < 1 ) {
            stc = 1;
        }
        etc = stc + strlen( w->title ) + 1;
        ctc = 0;
    }
    if( w->borderdata != NULL ) {
        topscol = w->bordercol;
        topecol = topscol + strlen( w->borderdata ) - 1;
        topccol = 0;
    }

    tl = (w->x1) + (w->y1) * WindMaxWidth;
    tr = (w->x2) + (w->y1) * WindMaxWidth;
    bl = (w->x1) + (w->y2) * WindMaxWidth;
    br = (w->x2) + (w->y2) * WindMaxWidth;
    xtl = 0;
    xtr = w->width - 1;
    xbl = (w->height - 1) * w->width;
    xbr = w->width - 1 + (w->height - 1) * w->width;
    clr = MAKE_ATTR( w, w->border_color1, w->border_color2 );
    what.attr = clr;
    what2.attr = clr;

    /*
     * do the corner pieces
     */
    what.ch = wb[WB_TOPLEFT];
    WRITE_SCREEN_DATA( txt[xtl], what );
    if( over[xtl] == NO_CHAR ) {
        WRITE_SCREEN( scr[tl], what );
    }
    what.ch = wb[WB_TOPRIGHT];
    WRITE_SCREEN_DATA( txt[xtr], what );
    if( over[xtr] == NO_CHAR ) {
        WRITE_SCREEN( scr[tr], what );
    }
    what.ch = wb[WB_BOTTOMLEFT];
    WRITE_SCREEN_DATA( txt[xbl], what );
    if( over[xbl] == NO_CHAR ) {
        WRITE_SCREEN( scr[bl], what );
    }
    what.ch = wb[WB_BOTTOMRIGHT];
    WRITE_SCREEN_DATA( txt[xbr], what );
    if( over[xbr] == NO_CHAR ) {
        WRITE_SCREEN( scr[br], what );
    }

    /*
     * do the left side
     */
    what.ch = wb[WB_LEFTSIDE];
    k = xtl + w->width;
    j = tl + WindMaxWidth;
    for( i = 1; i < w->height - 1; i++ ) {
        WRITE_SCREEN_DATA( txt[k], what );
        if( over[k] == NO_CHAR ) {
            WRITE_SCREEN( scr[j], what );
#ifdef __VIO__
            MyVioShowBuf( sizeof( char_info ) * j, 1 );
#endif
        }
        k += w->width;
        j += WindMaxWidth;
    }

    /*
     * do the right side
     */
    what.ch = wb[WB_RIGHTSIDE];
    k = xtr + w->width;
    j = tr + WindMaxWidth;
    for( i = 1; i < w->height - 1; i++ ) {
        WRITE_SCREEN_DATA( txt[k], what );
        if( over[k] == NO_CHAR ) {
            WRITE_SCREEN( scr[j], what );
#ifdef __VIO__
            MyVioShowBuf( sizeof( char_info ) * j, 1 );
#endif
        }
        k += w->width;
        j += WindMaxWidth;
    }

    /*
     * now do bottom and top
     */
    what2.ch = wb[WB_TOPBOTTOM];
    for( i = 1; i < w->width - 1; i++ ) {
        k = xtl + i;
        c = wb[5];
        if( w->title != NULL ) {
            if( i >= stc && i <= etc ) {
                if( i == stc ) {
                    c = wb[WB_RIGHTT];
                } else if( i == etc ) {
                    c = wb[WB_LEFTT];
                } else {
                    c = w->title[ctc++];
                }
            }
        }
        if( w->borderdata != NULL ) {
            if( i >= topscol && i <= topecol ) {
                c = w->borderdata[topccol++];
            }
        }
        what.ch = c;
        WRITE_SCREEN_DATA( txt[k], what );
        if( over[k] == NO_CHAR ) {
            WRITE_SCREEN( scr[tl + i] , what );
        }

        k = xbl + i;
        WRITE_SCREEN_DATA( txt[k], what2 );
        if( over[k] == NO_CHAR ) {
            WRITE_SCREEN( scr[bl + i] , what2 );
        }
    }

    /*
     * add side gadgets
     */
    if( w->has_gadgets || w->has_scroll_gadgets ) {
        what.ch = wb[WB_UPTRIANGLE];
        WRITE_SCREEN_DATA( txt[xtr + w->width], what );
        if( over[xtr + w->width] == NO_CHAR ) {
            WRITE_SCREEN( scr[tr + WindMaxWidth], what );
#ifdef __VIO__
            MyVioShowBuf( sizeof( char_info ) * (tr + WindMaxWidth), 1 );
#endif
        }
        what.ch = wb[WB_DOWNTRIANGLE];
        WRITE_SCREEN_DATA( txt[xbr - w->width], what );
        if( over[xbr - w->width] == NO_CHAR ) {
            WRITE_SCREEN( scr[br - WindMaxWidth], what );
#ifdef __VIO__
            MyVioShowBuf( sizeof( char_info ) * (br - WindMaxWidth), 1 );
#endif
        }
    }
#ifdef __VIO__
    MyVioShowBuf( sizeof( char_info ) * tl, w->width );
    MyVioShowBuf( sizeof( char_info ) * bl, w->width );
#endif
    if( w->has_gadgets ) {
        DrawVerticalThumb( w, GadgetString[WB_THUMB] );
    }
    ReleaseWindow( w );

} /* DrawBorder */