Exemple #1
0
/*-----------------------------------------------------------------------------
* FUNCTION:    SCRSVR_PicOnUsrMessage
* SCOPE:       Screen saver screen related function - local
* DESCRIPTION: User message handler function for picture object, to redraw the last picture position by background color
*
* PARAMETERS:  pMsg - pointer to D4D_MESSAGE structure
*              
* RETURNS:     return if this message discard or not
*-----------------------------------------------------------------------------*/
static Byte SCRSVR_PicOnUsrMessage(D4D_MESSAGE* pMsg)
{
  if(pMsg->nMsgId == D4D_MSG_DRAWDONE)
  {
    D4D_SIZE pictSize = D4D_GetBmpSize(((D4D_PICTURE*)scrsvr_picLogo.pParam)->pBmp);    
    D4D_SIZE rectSize;
    D4D_POINT rectPoint;
    
    // Draw the horizontal box
    rectSize.cy = D4D_Abs16(dy);
    rectSize.cx = pictSize.cx;
    
    rectPoint = oldPos;
    
    if(oldPos.y > scrsvr_picLogo.position.y)
      rectPoint.y += pictSize.cy;
    
    D4D_FillRect(&rectPoint, &rectSize, D4D_COLOR_BLACK);
    
    // Draw the vertical box
    rectSize.cx = D4D_Abs16(dx);
    rectSize.cy = pictSize.cy;
    
    rectPoint = oldPos;
    
    if(oldPos.x > scrsvr_picLogo.position.x)
      rectPoint.x += pictSize.cx;
    
    D4D_FillRect(&rectPoint, &rectSize, D4D_COLOR_BLACK);
  }
  
  return D4D_MSG_NOSKIP;
}
Exemple #2
0
static void D4D_ConsoleOnDraw(D4D_MESSAGE* pMsg)
{
    D4D_OBJECT* pThis = pMsg->pObject;
    D4D_CONSOLE* pCnsl = D4D_GET_CONSOLE(pThis);
    D4D_CNSL_DATA* pData = pCnsl->pData;
    D4D_OBJECT_DRAWFLAGS draw = pMsg->prm.draw;
    D4D_COLOR clrT, clrB;
    D4D_INDEX line_cnt, tmp_realLine;
    D4D_POINT tmp_point;
    D4D_SIZE tmp_size, tmp_winOff;
    D4D_STRING tmp_txtbuff;
    D4D_STR_PROPERTIES tmp_strPrties;
    D4D_BOOL tmp_font_proporcional = D4D_FALSE;


    D4D_CnslValue2Coor(pThis);

    clrT = D4D_ObjectGetForeFillColor(pThis);
    clrB = D4D_ObjectGetBckgFillColor(pThis);

    // draw the rectangle around the text
    if(draw & D4D_OBJECT_DRAWFLAGS_COMPLETE)
    {
        D4D_FillRRect(&_calc.position, &pThis->size, clrB, pThis->radius);

        pData->flags |= (D4D_CNSL_FLAGS_REDRAWALL | D4D_CNSL_FLAGS_REDRAWLINE | D4D_CNSL_FLAGS_REDRAWCURSOR);
    }

    // Draw the frame
    if(draw & (D4D_OBJECT_DRAWFLAGS_COMPLETE | D4D_OBJECT_DRAWFLAGS_STATE))
        D4D_DrawFrame(pThis, clrT, clrB);

    tmp_winOff.cx = (D4D_COOR)D4D_ScrlBrGetPosition(D4D_GET_LIST_BOX_SCROLL_BAR_HOR(pThis));
    tmp_winOff.cy = (D4D_COOR)D4D_ScrlBrGetPosition(D4D_GET_LIST_BOX_SCROLL_BAR_VER(pThis));
    tmp_strPrties.font_properties = 0;
    tmp_strPrties.text_properties = 0;
    tmp_txtbuff.fontId = pCnsl->textFontId;
    tmp_txtbuff.str_properties = &tmp_strPrties;
    tmp_txtbuff.printOff = 0;


    if(pData->flags & (D4D_CNSL_FLAGS_REDRAWALL | D4D_CNSL_FLAGS_REDRAWLINE))
    {
        // Draw all lines of console
        tmp_point = _calc.txtGeom.pnt;
        tmp_size.cx = _calc.txtGeom.sz.cx;
        tmp_size.cy = D4D_GetFontHeight(pCnsl->textFontId);


        if(D4D_GetFont(pCnsl->textFontId)->pFontDescriptor->flags & D4D_FONT_FLAGS_FNT_WIDTH_PROPORTIONAL)
            tmp_font_proporcional = D4D_TRUE;

        for(line_cnt = 0; line_cnt < _calc.charArrSize.cy; line_cnt++)
        {
            if(!(pData->flags & D4D_CNSL_FLAGS_REDRAWALL))
                if(line_cnt != pData->cursorPos.y)
                {
                    tmp_point.y += tmp_size.cy;
                    continue;
                }

            // Compute the real line in memory
            tmp_realLine = (D4D_INDEX)((pData->lastLineIx + line_cnt + tmp_winOff.cy) % pCnsl->txtArrSize.cy);

            // found the right pointer of the text to draw in the text array
            tmp_txtbuff.pText = (D4D_TCHAR*)(pCnsl->pTxtArr + tmp_realLine * (pCnsl->txtArrSize.cx + 1) + tmp_winOff.cx);

            if((tmp_winOff.cx + _calc.charArrSize.cx) <= pCnsl->txtArrSize.cx)
            {
                if(tmp_font_proporcional)
                    tmp_txtbuff.printLen = D4D_CnslFindMaxTextLenght(tmp_txtbuff.pText, pCnsl->textFontId, tmp_winOff.cx, pCnsl->txtArrSize.cx);
                else
                    tmp_txtbuff.printLen = _calc.charArrSize.cx;

                tmp_txtbuff.buffSize = 0;

            }
            D4D_DrawTextRect(&tmp_point, &tmp_size, &tmp_txtbuff, clrT, clrB);

            tmp_point.y += tmp_size.cy;
        }
    }

    // redraw cursor
    if(((D4D_INDEX_DELTA)(pData->cursorPos.y - tmp_winOff.cy) >= 0) && ((pData->cursorPos.y - tmp_winOff.cy) < _calc.charArrSize.cy) && (pData->cursorPos.x >= tmp_winOff.cx)) //cursor is on screen - check line and also and check the axis X
    {
        D4D_BOOL cursorVisible = D4D_FALSE;

        // Compute the real line in memory
        tmp_realLine = (D4D_INDEX)((pData->lastLineIx + pData->cursorPos.y) % pCnsl->txtArrSize.cy);

        // found the right pointer of the text to draw in the text array
        tmp_txtbuff.pText = (D4D_TCHAR*)(pCnsl->pTxtArr + tmp_realLine * (pCnsl->txtArrSize.cx + 1) + tmp_winOff.cx);

        // Check if the cursor is visible on the line

        tmp_txtbuff.printLen = D4D_CnslFindMaxTextLenght(tmp_txtbuff.pText, pCnsl->textFontId, tmp_winOff.cx, pData->cursorPos.x);

        if(*(tmp_txtbuff.pText + pData->cursorPos.x))
            tmp_size.cx = D4D_GetCharWidth(pCnsl->textFontId, *(tmp_txtbuff.pText + pData->cursorPos.x));
        else
            tmp_size.cx = D4D_GetCharWidth(pCnsl->textFontId, ' ');

        tmp_point.x = D4D_GetTextBuffWidthTab(&tmp_txtbuff, NULL);

        if(tmp_font_proporcional)
        {
            if(tmp_point.x < (D4D_COOR)( _calc.txtGeom.sz.cx - tmp_size.cx))
                cursorVisible = D4D_TRUE;
        }
        else
        {
            if(pData->cursorPos.x < (D4D_INDEX)(_calc.charArrSize.cx + tmp_winOff.cx))
                cursorVisible = D4D_TRUE;
        }

        if(cursorVisible)
        {
            tmp_point.y = (D4D_COOR)((pData->cursorPos.y - tmp_winOff.cy) * D4D_GetFontHeight(pCnsl->textFontId) + _calc.txtGeom.pnt.y);//??+1
            tmp_point.x += _calc.txtGeom.pnt.x;
            tmp_size.cy = (D4D_COOR)((D4D_CNSL_CURSOR_HEIGHT > D4D_GetFontHeight(pCnsl->textFontId))? D4D_CNSL_CURSOR_HEIGHT : D4D_GetFontHeight(pCnsl->textFontId));



            // check the state of cursor and selected right color
            if((!(pData->flags & D4D_CNSL_FLAGS_CURSORSTATE)) || (!tmp_txtbuff.pText[0]))
            {   // draw cursor
                D4D_COLOR clr;

                if(pData->flags & D4D_CNSL_FLAGS_CURSORSTATE)
                    clr = clrB;
                else
                    clr = clrT;

                tmp_point.y += (D4D_GetFontHeight(pCnsl->textFontId) - D4D_CNSL_CURSOR_HEIGHT - 1);
                tmp_size.cy = D4D_CNSL_CURSOR_HEIGHT;

                D4D_FillRect(&tmp_point, &tmp_size, clr);
            }
            else
            {
                // Draw the original char
                tmp_txtbuff.printOff = pData->cursorPos.x;
                tmp_txtbuff.printLen = 1;
                D4D_DrawTextRect(&tmp_point, &tmp_size, &tmp_txtbuff, clrT, clrB);
            }
        }
    }

    pData->flags &= ~(D4D_CNSL_FLAGS_REDRAWALL | D4D_CNSL_FLAGS_REDRAWLINE | D4D_CNSL_FLAGS_REDRAWCURSOR);
}
Exemple #3
0
static void D4D_ScrlBrOnDraw(D4D_MESSAGE* pMsg)
{
  D4D_OBJECT* pThis = pMsg->pObject;
  D4D_OBJECT_DRAWFLAGS draw = pMsg->prm.draw;
  D4D_COLOR clrT, clrB;
  D4D_POINT tmp_point;
  D4D_SIZE tmp_size;

  D4D_ScrlBrValue2Coor(pThis);

  clrT = D4D_ObjectGetForeColor(pThis, draw);
  clrB = D4D_ObjectGetBckgColor(pThis, draw);

  // draw the rectangle around the text
  if(draw & D4D_OBJECT_DRAWFLAGS_COMPLETE)
    D4D_FillRRect(&_calc.position, &pThis->size, clrB, pThis->radius);

  // Draw the frame & arrow buttons
    if(draw & (D4D_OBJECT_DRAWFLAGS_COMPLETE | D4D_OBJECT_DRAWFLAGS_STATE))
    {
      D4D_DrawFrame(pThis, clrT, clrB);

      tmp_point = _calc.contentGeom.pnt;

      if(pThis->size.cx > pThis->size.cy)
      {
        // horizontal scroll bar
        // draw first arrow button left

        tmp_size.cx = tmp_size.cy = _calc.contentGeom.sz.cy;

        D4D_RRect(&tmp_point, &tmp_size, D4D_LINE_THIN, clrT, _calc.scrollRadius);

        tmp_point.x += (D4D_COOR)(_calc.contentGeom.sz.cx - _calc.contentGeom.sz.cy);
        D4D_RRect(&tmp_point, &tmp_size, D4D_LINE_THIN, clrT, _calc.scrollRadius);

        tmp_point.x = (D4D_COOR)(_calc.contentGeom.pnt.x + _calc.contentGeom.sz.cy / 8);
        tmp_point.y += (D4D_COOR)(_calc.contentGeom.sz.cy / 2);
        D4D_ScrlBrDrawArrow( &tmp_point,(D4D_COOR)((_calc.contentGeom.sz.cy / 2) - 2),D4D_DIR_LEFT,clrT);

        // draw second arrow button right
        tmp_point.x = (D4D_COOR)(_calc.contentGeom.pnt.x + _calc.contentGeom.sz.cx - _calc.contentGeom.sz.cy / 8);
        D4D_ScrlBrDrawArrow( &tmp_point,(D4D_COOR)((_calc.contentGeom.sz.cy / 2) - 2),D4D_DIR_RIGHT,clrT);

      }else
      {
        // vertical scroll bar
        tmp_size.cx = tmp_size.cy = _calc.contentGeom.sz.cx;

        D4D_RRect(&tmp_point, &tmp_size, D4D_LINE_THIN, clrT, _calc.scrollRadius);

        tmp_point.y += (D4D_COOR)(_calc.contentGeom.sz.cy - _calc.contentGeom.sz.cx);
        D4D_RRect(&tmp_point, &tmp_size, D4D_LINE_THIN, clrT, _calc.scrollRadius);

        tmp_point.y = (D4D_COOR)(_calc.contentGeom.pnt.y + _calc.contentGeom.sz.cx / 8);
        tmp_point.x += (D4D_COOR)(_calc.contentGeom.sz.cx / 2);
        D4D_ScrlBrDrawArrow( &tmp_point,(D4D_COOR)((_calc.contentGeom.sz.cx / 2) - 2),D4D_DIR_UP,clrT);

        // draw second arrow button right
        tmp_point.y = (D4D_COOR)(_calc.contentGeom.pnt.y + _calc.contentGeom.sz.cy - _calc.contentGeom.sz.cx / 8);
        D4D_ScrlBrDrawArrow( &tmp_point,(D4D_COOR)((_calc.contentGeom.sz.cx / 2) - 2),D4D_DIR_DOWN,clrT);
      }
    }

  D4D_FillRect(&_calc.refreshPos, &_calc.refreshSize, clrB);
  D4D_FillRRect(&_calc.scrollPos, &_calc.scrollSize, clrT, _calc.scrollRadius);

}