Exemple #1
0
void VSliderControl::BlitTrough(int iPos)
{
    if (!m_bHasTroughBitmap)
        return;

    Canvas *pCanvas;
    Rect    oFrameRect, oDestRect;

    oDestRect = m_oRect;
    
    int iTotFrames = m_iTroughFrames;
    if (m_bTroughMiddle)
        iTotFrames *= 2;

    int iFrameNumber = iTotFrames * (1 - iPos / m_iRange);
    iFrameNumber = min(iTotFrames - 1, iFrameNumber);

    if (m_bTroughMiddle) {
        if (iFrameNumber >= m_iTroughFrames)
            iFrameNumber = iFrameNumber - m_iTroughFrames;
        else
            iFrameNumber = (m_iTroughFrames - 1) - iFrameNumber;
    }
            
    m_iCurrentTroughFrame = iFrameNumber;

    if (m_bHorizontalTroughBitmap) {
        int iFrameWidth = (m_oBitmapRect.Width() + 1 - 
                           (m_iTroughDelta * (m_iTroughFrames - 1))) /
                           m_iTroughFrames;
        oFrameRect = m_oTroughBitmapRect;
        oFrameRect.x1 += (iFrameWidth + m_iTroughDelta) * iFrameNumber;
        oFrameRect.x2 = oFrameRect.x1 + iFrameWidth;
    }
    else {
        int iFrameHeight = (m_oBitmapRect.Height() + 1 -
                            (m_iTroughDelta * (m_iTroughFrames - 1))) / 
                            m_iTroughFrames;

        oFrameRect = m_oTroughBitmapRect;
        oFrameRect.y1 += (iFrameHeight + m_iTroughDelta) * iFrameNumber;
        oFrameRect.y2 = oFrameRect.y2 + iFrameHeight;
    }

    oFrameRect.y2++;
    oFrameRect.x2++;

    oDestRect.y2++;
    oDestRect.x2++;

    pCanvas = m_pParent->GetCanvas();
    pCanvas->MaskBlitRect(m_pTroughBitmap, oFrameRect, oDestRect);

    pCanvas->Invalidate(oDestRect);
    pCanvas->Update();
}
void MultiStateControl::Transition(ControlTransitionEnum  eTrans,
                                   Pos                   *pMousePos)
{
    Canvas *pCanvas;
    
    switch(eTrans)
    {
       case CT_MouseEnter:
          m_pParent->SendControlMessage(this, CM_MouseEnter);
          break;
       case CT_MouseLeave:
          m_pParent->SendControlMessage(this, CM_MouseLeave);
          break;
       case CT_SetValue:
       	  m_iState = min(max(m_iValue, 0), m_iNumStates - 1);
          break;
       case CT_Hide:
       {
       	  Rect oRect = m_oRect;

           if (m_pPanel->IsHidden())
               return;

           pCanvas = m_pParent->GetCanvas();
           pCanvas->Erase(oRect);
           pCanvas->Invalidate(oRect);
       	  break;
       }   

       default:
          break;
    }

    if (m_pPanel->IsHidden())
        return;

    if (m_eCurrentState == CS_MouseOver && 
        eTrans == CT_MouseLButtonUp)
        m_pParent->SendControlMessage(this, CM_Pressed);

    BlitFrame(m_eCurrentState, m_iState);
}
Exemple #3
0
void TextControl::TextChanged(void)
{
    Canvas *pCanvas;
    int    iRet;

    if (m_pPanel->IsHidden())
        return;

    m_oMutex.Acquire();
    
    m_iMarqueePos = 0;
    pCanvas = m_pParent->GetCanvas();
    m_oMutex.Release();

    pCanvas->SetNoScreenUpdate(true);
    pCanvas->Erase(m_oRect);
    iRet = pCanvas->RenderText(m_oRect.Height(), m_oRect, 
                               m_oValue, m_eAlign, 
                               m_pFont, m_oColor, m_bBold, 
                               m_bItalic, m_bUnderline); 

    // If this is the time display, don't marquee it
    if (iRet > 0 && m_oName == string("Time") || 
                    m_oName == string("TimeRemaining"))
    {
       pCanvas->Erase(m_oRect);
       pCanvas->RenderText(m_oRect.Height(), m_oRect, 
                           m_oValue, eRight, 
                           m_pFont, m_oColor, m_bBold, 
                           m_bItalic, m_bUnderline); 
       iRet = 0;
    }
    pCanvas->SetNoScreenUpdate(false);
    pCanvas->Invalidate(m_oRect);
    pCanvas->Update();

    m_oMutex.Acquire();
    m_bWantsTimingMessages = (iRet > 0);
    m_oMutex.Release();
}
Exemple #4
0
void VSliderControl::MoveThumb(int iNewPos)
{
    Canvas *pCanvas;
    Rect    oRect;

    pCanvas = m_pParent->GetCanvas();
    pCanvas->Erase(m_oRect);

    oRect.y1 = m_oRect.y1 + iNewPos;
    oRect.y2 = oRect.y1 + m_iThumbHeight;
    oRect.x1 = m_oRect.x1;
    oRect.x2 = m_oRect.x2;
    
    int iThumbNumber = m_iNumThumbStates * (1 - iNewPos / m_iRange);
    iThumbNumber = min(m_iNumThumbStates - 1, iThumbNumber);

    BlitTrough(iNewPos);

    switch(m_eCurrentState)
    {
       case CS_Normal:
          BlitFrame(CS_Normal, iThumbNumber, &oRect, false);
          break;

       case CS_Dragging:
       case CS_MouseOver:
          BlitFrame(CS_MouseOver, iThumbNumber, &oRect, false);
          break;

       case CS_Disabled:
       case CS_DisabledMO:
          BlitFrame(CS_Disabled, iThumbNumber, &oRect, false);
          break;

       default:
          break;
    }
    pCanvas->Invalidate(m_oRect);
}
void PixSliderControl::DrawReveal(int reveal)
{
   int x, y, testreveal;
   Canvas *pCanvas;
   Color trans, color;
   Pos point;
   Rect blit;
   Bitmap *copy;
   int type = 0;

   if (reveal == m_iOldRevealPos)
       return;

   if (reveal == 0) {
       m_iOldRevealPos = 0;
       return;
   }

   m_pActivationBitmap->GetTransColor(trans);
   pCanvas = m_pParent->GetCanvas();

   for (y = m_oRect.y1; y < m_oRect.y2; y++) 
   {
       point.y = y;
       blit.y1 = blit.y2 = y;
       blit.y2++;
       blit.x1 = blit.x2 = m_oRect.x1;
       for (x = m_oRect.x1; x < m_oRect.x2; x++) 
       {
           point.x = x; 
           
           m_pActivationBitmap->GetColor(point, color);
           if (!color.IsEqual(trans)) {
               testreveal = (color.red + color.green + color.blue) / 3;
               if (testreveal <= reveal) {
                   if (type != 1) {
                       if (type == 2) {
                           copy = m_oStateBitmaps[0][CS_Normal];
                           pCanvas->MaskBlitRect(copy, blit, blit);
                       }
                       blit.x1 = blit.x2 = x;
                       blit.y1 = blit.y2 = y;
                       blit.y2++;
                       type = 1;
                   }
                   else 
                       blit.x2++;
               }
               else {
                   if (type != 2) {
                       if (type == 1) {
                           copy = m_oStateBitmaps[0][CS_Pressed];
                           pCanvas->MaskBlitRect(copy, blit, blit);
                       }
                       blit.x1 = blit.x2 = x;
                       blit.y1 = blit.y2 = y;
                       blit.y2++;
                       type = 2;
                   }
                   else 
                       blit.x2++;
               }
           }
           else {
               if (type != 0) {
                   if (type == 2)
                       copy = m_oStateBitmaps[0][CS_Normal]; 
                   else
                       copy = m_oStateBitmaps[0][CS_Pressed];
                   pCanvas->MaskBlitRect(copy, blit, blit);
                   blit.x1 = blit.x2 = x;
                   blit.y1 = blit.y2 = y;
                   blit.y2++;
                   type = 0;
               } 
           }   
       }
       if (type != 0) {
           if (type == 2)
               copy = m_oStateBitmaps[0][CS_Normal];
           else
               copy = m_oStateBitmaps[0][CS_Pressed];
           pCanvas->MaskBlitRect(copy, blit, blit);
           type = 0;
       } 
    }

    m_iOldRevealPos = reveal;

    pCanvas->Invalidate(m_oRect);
    pCanvas->Update();    
}
void PixSliderControl::Transition(ControlTransitionEnum  eTrans,
                                  Pos                   *pMousePos)
{
    Canvas *pCanvas;
    
    if (m_eCurrentState == CS_Pressed && eTrans == CT_SetValue)
        return;

    switch(eTrans)
    {
       case CT_MouseEnter:
          m_pParent->SendControlMessage(this, CM_MouseEnter);
          return;
       case CT_MouseLeave:
          m_pParent->SendControlMessage(this, CM_MouseLeave);
          return;
       case CT_SetValue: {
          if (m_iValue < 0 || m_iValue > 100)
              return;
         
          int temp = m_iValue * m_iNumStates / 100; 
          m_iState = min(temp, m_iNumStates - 1);

         if (!m_bActivationReveal) 
             BlitFrame(CS_Normal, m_iState);
         else
             DrawReveal((float)m_iValue * 2.55);

         return; }
       case CT_Hide:
       {
       	  Rect oRect = m_oRect;

           if (m_pPanel->IsHidden())
               return;

           pCanvas = m_pParent->GetCanvas();
           pCanvas->Erase(oRect);
           pCanvas->Invalidate(oRect);
       	   return;
       }   

       default:
          break;
    }

    if (m_pPanel->IsHidden())
        return;
    
    if (m_bHasActivationBitmap && pMousePos)
        m_iState = GetStateNum(*pMousePos);

    if (m_eCurrentState == CS_MouseOver && 
        eTrans == CT_MouseLButtonUp)
        m_pParent->SendControlMessage(this, CM_Pressed);

    if (m_eCurrentState == CS_MouseOver &&
        eTrans == CT_MouseLButtonUp) {
        if (!m_bActivationReveal)
            m_iValue = (int)((float)(m_iState * 100) / m_iNumStates);
        else
            m_iValue = (int)((float)(m_iState * 100) / 255); 
        m_pParent->SendControlMessage(this, CM_ValueChanged);
    }

    if (!m_bActivationReveal)
        BlitFrame(CS_Normal, m_iState);
    else if (pMousePos)
        DrawReveal(*pMousePos);
    else
        DrawReveal((float)m_iValue * 2.55);
}
Exemple #7
0
void ButtonControl::Transition(ControlTransitionEnum  eTrans,
                               Pos                   *pMousePos)
{
    Canvas *pCanvas;

    if (m_pPanel->IsHidden())
       return;

    switch(eTrans)
    {
       case CT_MouseEnter:
          m_pParent->SendControlMessage(this, CM_MouseEnter);
          break;
       case CT_MouseLeave:
          m_pParent->SendControlMessage(this, CM_MouseLeave);
          break;
       case CT_Hide:
       {
          Rect oRect = m_oRect;
          pCanvas = m_pParent->GetCanvas();
          pCanvas->Erase(oRect);
          pCanvas->Invalidate(oRect);
          break;
       }   

       default:
          break;
    }

    if (m_eCurrentState == CS_MouseOver && 
        eTrans == CT_MouseLButtonUp)
    {    
       if (m_oTargetWindow.length() > 0)
       {   
           m_oMutex.Acquire();
           m_oValue = m_oTargetWindow;
           m_oMutex.Release();
           
           m_pParent->SendControlMessage(this, CM_ChangeWindow);
           return;
       }
       if (m_pPanelToToggle)
       {
           m_pPanelToToggle->TogglePanelPos();
           m_pParent->SendControlMessage(this, CM_TogglePanel);
           m_eCurrentState = CS_MouseOver;
           BlitFrame(m_eCurrentState);
           return;
       }
       if (m_oName == string("ReloadTheme"))
       {
          m_pParent->SendControlMessage(this, CM_Pressed);
          return;
       }   
       m_pParent->SendControlMessage(this, CM_Pressed);
    }       

    pCanvas = m_pParent->GetCanvas();
    pCanvas->Erase(m_oRect);
    pCanvas->Invalidate(m_oRect);

    BlitFrame(m_eCurrentState);
}