void wxCodeCompletionBox::DoDrawTopScrollButton(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_scrollTopRect = wxRect(scrollRect.GetTopLeft(), wxSize(scrollRect.GetWidth(), scrollRect.GetHeight() / 2)); #if 0 wxPoint bottomRight; bottomRight = m_scrollTopRect.GetBottomRight(); bottomRight.x += 1; dc.SetPen(m_darkBorder); dc.DrawLine(m_scrollTopRect.GetBottomLeft(), bottomRight); #endif // Draw the up arrow wxCoord x, y; x = m_scrollTopRect.x + ((m_scrollTopRect.GetWidth() - m_bmpUp.GetWidth()) / 2); y = m_scrollTopRect.y + m_bmpUp.GetHeight(); wxBitmap bmp = CanScrollUp() ? m_bmpUpEnabled : m_bmpUp; dc.DrawBitmap(bmp, x, y); }
LTBOOL CListCtrl::ScrollUp () { if (!CanScrollUp()) return LTFALSE; m_nFirstDisplayedItem--; m_nLastDisplayedItem = CalculateLastDisplayedIndex(m_nFirstDisplayedItem); return LTTRUE; }
void wxCodeCompletionBox::DoScrollUp() { if(CanScrollUp()) { --m_index; DoDisplayTipWindow(); Refresh(); } }
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); } }