1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
|
// fonction associé à l'évènement: EVT_SCROLLWIN( TCtrlGrid::OnScrollWin )
void TCtrlGrid::OnScrollWin( wxScrollWinEvent& ev )
{
wxEventType TypeEvent = ev.GetEventType();
int iPosition = ev.GetPosition();
int x;
// positionnement de la barre de scrolling vertical
if( ev.GetOrientation() == wxVERTICAL )
{
// gestion des boutons haut bas de la barre de scrolling
if( TypeEvent == wxEVT_SCROLLWIN_LINEUP || TypeEvent == wxEVT_SCROLLWIN_LINEDOWN )
{
// récupère la position de la vue visible, pour connaitre la position de la bar de scrolling
GetViewStart( &x, &iPosition );
// appuie sur les flèches de la scrollbar
if( TypeEvent == wxEVT_SCROLLWIN_LINEUP )
iPosition--;
if( TypeEvent == wxEVT_SCROLLWIN_LINEDOWN )
iPosition++;
}
// gestion du page up page down de la barre de scrolling
if( TypeEvent == wxEVT_SCROLLWIN_PAGEUP || TypeEvent == wxEVT_SCROLLWIN_PAGEDOWN )
{
// calcul le nombre de scroll pour un page up ou down
GetClientSize( &x, &iPosition );
iPosition -= wxGrid::GetColLabelSize();
iPosition = iPosition / GetScrollLineY();
// inverse le sens si page up
if( TypeEvent == wxEVT_SCROLLWIN_PAGEUP ) iPosition *= -1;
// calcul la position finale du scrollbar, par rapport à la position actuelle
int y;
GetViewStart( &x, &y );
iPosition = y + iPosition;
}
// positionnement de la barre de scrolling
wxGrid::Scroll( -1, iPosition );
((wxGrid*)pGrid)->Scroll( -1, iPosition );
} else {
// execution par défaut
ev.Skip();
}
} |
Partager