MSW compilation fixes - widgets sample runs!
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@10677 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
138
src/common/radiocmn.cpp
Normal file
138
src/common/radiocmn.cpp
Normal file
@@ -0,0 +1,138 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: src/common/radiocmn.cpp
|
||||
// Purpose: wxRadioBox methods common to all ports
|
||||
// Author: Vadim Zeitlin
|
||||
// Modified by:
|
||||
// Created: 03.06.01
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) 2001 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
|
||||
// License: wxWindows license
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// ============================================================================
|
||||
// declarations
|
||||
// ============================================================================
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// headers
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma implementation "radioboxbase.h"
|
||||
#endif
|
||||
|
||||
// For compilers that support precompilation, includes "wx.h".
|
||||
#include "wx/wxprec.h"
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
#if wxUSE_RADIOBOX
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/radiobox.h"
|
||||
#endif //WX_PRECOMP
|
||||
|
||||
// ============================================================================
|
||||
// implementation
|
||||
// ============================================================================
|
||||
|
||||
int wxRadioBoxBase::GetNextItem(int item, wxDirection dir, long style) const
|
||||
{
|
||||
int count = GetCount(),
|
||||
numCols = GetColumnCount(),
|
||||
numRows = GetRowCount();
|
||||
|
||||
bool horz = (style & wxRA_SPECIFY_COLS) != 0;
|
||||
|
||||
switch ( dir )
|
||||
{
|
||||
case wxUP:
|
||||
if ( horz )
|
||||
{
|
||||
item -= numCols;
|
||||
}
|
||||
else // vertical layout
|
||||
{
|
||||
if ( !item-- )
|
||||
item = count - 1;
|
||||
}
|
||||
break;
|
||||
|
||||
case wxLEFT:
|
||||
if ( horz )
|
||||
{
|
||||
if ( !item-- )
|
||||
item = count - 1;
|
||||
}
|
||||
else // vertical layout
|
||||
{
|
||||
item -= numRows;
|
||||
}
|
||||
break;
|
||||
|
||||
case wxDOWN:
|
||||
if ( horz )
|
||||
{
|
||||
item += numCols;
|
||||
}
|
||||
else // vertical layout
|
||||
{
|
||||
if ( ++item == count )
|
||||
item = 0;
|
||||
}
|
||||
break;
|
||||
|
||||
case wxRIGHT:
|
||||
if ( horz )
|
||||
{
|
||||
if ( ++item == count )
|
||||
item = 0;
|
||||
}
|
||||
else // vertical layout
|
||||
{
|
||||
item += numRows;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
wxFAIL_MSG( _T("unexpected wxDirection value") );
|
||||
return -1;
|
||||
}
|
||||
|
||||
// ensure that the item is in range [0..count)
|
||||
if ( item < 0 )
|
||||
{
|
||||
// first map the item to the one in the same column but in the last row
|
||||
item += count;
|
||||
|
||||
// now there are 2 cases: either it is the first item of the last row
|
||||
// in which case we need to wrap again and get to the last item or we
|
||||
// can just go to the previous item
|
||||
if ( item % (horz ? numCols : numRows) )
|
||||
item--;
|
||||
else
|
||||
item = count - 1;
|
||||
}
|
||||
else if ( item >= count )
|
||||
{
|
||||
// same logic as above
|
||||
item -= count;
|
||||
|
||||
// ... except that we need to check if this is not the last item, not
|
||||
// the first one
|
||||
if ( (item + 1) % (horz ? numCols : numRows) )
|
||||
item++;
|
||||
else
|
||||
item = 0;
|
||||
}
|
||||
|
||||
wxASSERT_MSG( item < count && item >= 0,
|
||||
_T("logic error in wxRadioBox::GetNextItem()") );
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
#endif // wxUSE_RADIOBOX
|
||||
|
Reference in New Issue
Block a user