Esempio n. 1
0
void CHistoryPane::Push(const CHistoryItem & a)
{
  CItem  item;
  BITMAP bitmap;
  _double f;

  a.image->GetBitmap(&bitmap);
  f = m_uWidth / (_double)bitmap.bmWidth;

  ((CHistoryItem&)item) = a;
  item.w  = bitmap.bmWidth;
  item.h  = bitmap.bmHeight;
  item.h0 = bitmap.bmHeight * f;
  item.sel0 = a.sel * f;
  item.image0 = new CBitmap;
  item.image0->Attach(BitmapCreate(m_uWidth, item.h0));

  {
    CDC dc;
    CRect r(0,0,m_uWidth, item.h0);

    dc.CreateCompatibleDC(0);
    dc.SelectObject(item.image0);

    BitmapBlt(&dc, &r, item.image, 0);
  }

  m_vItems.push_back(item);
  RedrawWindow();

  while (CanScrollDown())
    Down();
}
Esempio n. 2
0
void wxCodeCompletionBox::DoDrawBottomScrollButton(wxDC& dc)
{
    wxRect scrollRect = m_scrollArea;
    scrollRect.Deflate(0, 2);
    scrollRect.SetWidth(scrollRect.GetWidth() - 2);

    // Separate the scrollbar area into 2 big buttons: up and down
    m_scrollBottomRect =
        wxRect(wxPoint(scrollRect.GetTopLeft().x, scrollRect.GetTopLeft().y + scrollRect.GetHeight() / 2),
               wxSize(scrollRect.GetWidth(), scrollRect.GetHeight() / 2));
#if 0
    wxPoint topRight;
    topRight = m_scrollBottomRect.GetTopRight();
    topRight.x += 1;

    dc.SetPen(m_lightBorder);
    dc.DrawLine(m_scrollBottomRect.GetTopLeft(), topRight);
#endif

    // Draw the up arrow
    wxCoord x, y;
    x = m_scrollBottomRect.x + ((m_scrollBottomRect.GetWidth() - m_bmpDown.GetWidth()) / 2);
    y = m_scrollBottomRect.y + m_scrollBottomRect.GetHeight() - (2 * m_bmpDown.GetHeight());

    wxBitmap bmp = CanScrollDown() ? m_bmpDownEnabled : m_bmpDown;
    dc.DrawBitmap(bmp, x, y);
}
Esempio n. 3
0
void wxCodeCompletionBox::DoScrollDown()
{
    if(CanScrollDown()) {
        ++m_index;
        DoDisplayTipWindow();
        Refresh();
    }
}
LTBOOL CListCtrl::ScrollDown ()
{
	if (!CanScrollDown())
        return LTFALSE;
	m_nFirstDisplayedItem++;
	m_nLastDisplayedItem = CalculateLastDisplayedIndex(m_nFirstDisplayedItem);
    return LTTRUE;
}
Esempio n. 5
0
void cMyTextScroller::Scroll(bool Up, bool Page) {
  if (Up) {
     if (CanScrollUp()) {
        offset -= Page ? shown : 1;
        if (offset < 0)
           offset = 0;
        DrawText();
        }
     }
  else {
     if (CanScrollDown()) {
        offset += Page ? shown : 1;
        if (offset + shown > Total())
           offset = Total() - shown;
        DrawText();
        }
     }
}
// Handles the mouse move message
LTBOOL CListCtrl::OnMouseMove(int x, int y)
{
	x += g_pInterfaceResMgr->GetXOffset();
	y += g_pInterfaceResMgr->GetYOffset();
	int nControlUnderPoint=0;
	CLTGUICtrl *pCtrl = GetControlUnderPoint(x, y, &nControlUnderPoint);
	if (m_pUp && CanScrollUp()) 
		m_pUp->Select(pCtrl == m_pUp);
	if (m_pDown && CanScrollDown()) 
		m_pDown->Select(pCtrl == m_pDown);

	// If m_bEnableMouseMoveSelect is TRUE then select the item that the mouse is over
	if (m_bEnableMouseMoveSelect)
	{
		if(pCtrl && nControlUnderPoint >= 0)
		{
			// Make sure we're enabled
			if(!pCtrl->IsEnabled())
                return LTFALSE;

			if (GetSelectedItem() != nControlUnderPoint)
			{
				SelectItem(nControlUnderPoint);

                return LTTRUE;
			}
		}
		else
		{
/*
			//if not on anything select nothing
			if ( m_nCurrentIndex < (int)m_controlArray.GetSize() )
			{
				m_controlArray[m_nCurrentIndex]->Select(FALSE);
			}
			m_nCurrentIndex = kNoSelection;
*/
		}
	}

    return LTFALSE;

}
LTBOOL CListCtrl::OnLButtonDblClick(int x, int y)
{
	x += g_pInterfaceResMgr->GetXOffset();
	y += g_pInterfaceResMgr->GetYOffset();
	m_fNextScrollTime = -1.0f;
	// Get the control that the click was on
	int nControlIndex=0;
	CLTGUICtrl *pCtrl = GetControlUnderPoint(x, y, &nControlIndex);
	if(pCtrl)
	{
		// Make sure we're enabled
		if(!pCtrl->IsEnabled())
            return LTFALSE;


		// If the mouse is over the same control now as it was when the down message was called
		// then send the "enter" message to the control.
		if (nControlIndex == m_nMouseDownItemSel)
		{
			if (nControlIndex == kUpSel)
			{
				return (!CanScrollUp() || ScrollUp());
			}
			else if (nControlIndex == kDownSel)
			{
				return (!CanScrollDown() || ScrollDown());
			}
			else
			{
				return m_controlArray[nControlIndex]->OnLButtonDblClick( x,  y);
			}
		}
	}
	else
	{
		m_nMouseDownItemSel=kNoSelection;
	}
    return LTFALSE;
}
// Handles the left button down message
LTBOOL CListCtrl::OnLButtonDown(int x, int y)
{
	x += g_pInterfaceResMgr->GetXOffset();
	y += g_pInterfaceResMgr->GetYOffset();

	// Get the control that the click was on
	int nControlIndex=0;
	CLTGUICtrl *pCtrl = GetControlUnderPoint(x, y, &nControlIndex);
	if(pCtrl)
	{
		// Make sure we're enabled
		if(!pCtrl->IsEnabled())
            return LTFALSE;

		if (nControlIndex >= 0 && m_bEnableMouseClickSelect)
		{
			// Select the control
			SelectItem(nControlIndex);
		}

		if ((nControlIndex == kUpSel && CanScrollUp())|| (nControlIndex == kDownSel && CanScrollDown()))
            m_fNextScrollTime = g_pLTClient->GetTime()+m_fScrollFirstDelay;

		// Record this control as the one being selected from the mouse click.
		// If the mouse is still over it on the UP message, then the "enter" message will be sent.
		m_nMouseDownItemSel=nControlIndex;

        return LTTRUE;
	}
	else
	{
		// This clears the index for what item was selected from a mouse down message
		m_nMouseDownItemSel=kNoSelection;

        return LTFALSE;
	}
}
// Render the control
void CListCtrl::Render ( HSURFACE hDestSurf )
{
	if ((m_pUp && m_pUp->IsSelected()) || (m_pDown && m_pDown->IsSelected()))
	{
        LTIntPt cpos = g_pInterfaceMgr->GetCursorPos();
		cpos.x += g_pInterfaceResMgr->GetXOffset();
		cpos.y += g_pInterfaceResMgr->GetYOffset();
		int nLeft=m_pos.x;
		int nTop=m_pos.y;
		int nRight=nLeft+GetWidth();
		int nBottom=nTop+GetHeight();
		if ( cpos.x < nLeft || cpos.x > nRight || cpos.y < nTop || cpos.y > nBottom)
		{
            if (m_pUp && m_pUp->IsSelected()) 
				m_pUp->Select(LTFALSE);
            if (m_pDown && m_pDown->IsSelected()) 
				m_pDown->Select(LTFALSE);
		}

	}

    if (m_fNextScrollTime > 0.0f && m_fNextScrollTime < g_pLTClient->GetTime())
	{
		m_fNextScrollTime = -1.0f;
		if (m_nMouseDownItemSel == kUpSel && CanScrollUp())
		{
			ScrollUp();
			if (CanScrollUp() && IsKeyDown(VK_LBUTTON))
                m_fNextScrollTime = g_pLTClient->GetTime()+m_fScrollDelay;
		}
		if (m_nMouseDownItemSel == kDownSel && CanScrollDown())
		{
			ScrollDown();
			if (CanScrollDown() && IsKeyDown(VK_LBUTTON))
                m_fNextScrollTime = g_pLTClient->GetTime()+m_fScrollDelay;
		}
	}

	// Render the items unless they are off the control
    LTIntPt size;
	int y=m_pos.y;

	unsigned int i;
	for ( i = m_nFirstDisplayedItem; i < m_controlArray.GetSize(); i++ )
	{
		size.x = m_controlArray[i]->GetWidth();
		size.y = m_controlArray[i]->GetHeight();

		if ( y+size.y < m_pos.y+m_nHeight )
		{
			// The x position
			int x=m_pos.x;

			// Center the control if needed
			switch (m_nAlign)
			{
			case LTF_JUSTIFY_CENTER:
				x-=(size.x)/2;
				break;
			case LTF_JUSTIFY_RIGHT:
				x-=size.x;
				break;
			}

			x += m_controlArray[i]->GetBoxDrawAdjustX();

			// Set the position for the control
			m_controlArray[i]->SetPos(x, y);
			m_controlArray[i]->Render ( hDestSurf );

			y+=size.y+m_nItemSpacing;
			m_nLastDisplayedItem = i;
		}
		else
		{
			break;
		}
	}

	if (m_bArrows)
	{
		if (m_pUp) m_pUp->SetPos(m_pos.x+m_nArrowOffset,m_pos.y);
		if (m_pDown) m_pDown->SetPos(m_pos.x+m_nArrowOffset,(m_pos.y+m_nHeight)-m_pDown->GetHeight());
		if (CanScrollUp())
			m_pUp->Render(hDestSurf);
		if (CanScrollDown())
			m_pDown->Render(hDestSurf);
	}
}