[saco] Implement CDXUTDialog::GetPrevControl(...)

This commit is contained in:
RD42 2024-05-24 23:12:04 +08:00
parent 92f47f526f
commit eb2876272f
2 changed files with 31 additions and 0 deletions

View File

@ -11,6 +11,10 @@
#undef min // use __min instead
#undef max // use __max instead
double CDXUTDialog::s_fTimeRefresh = 0.0f;
CDXUTControl* CDXUTDialog::s_pControlFocus = NULL; // The control which has focus
CDXUTControl* CDXUTDialog::s_pControlPressed = NULL; // The control currently pressed
//--------------------------------------------------------------------------------------
// CDXUTDialog class
//--------------------------------------------------------------------------------------
@ -391,6 +395,29 @@ CDXUTControl* CDXUTDialog::GetNextControl( CDXUTControl* pControl )
return pDialog->m_Controls.GetAt( index );
}
//--------------------------------------------------------------------------------------
CDXUTControl* CDXUTDialog::GetPrevControl( CDXUTControl* pControl )
{
int index = pControl->m_Index - 1;
CDXUTDialog* pDialog = pControl->m_pDialog;
// Cycle through dialogs in the loop to find the next control. Note
// that if only one control exists in all looped dialogs it will
// be the returned 'previous' control.
while( index < 0 )
{
pDialog = pDialog->m_pPrevDialog;
if( pDialog == NULL )
pDialog = pControl->m_pDialog;
index = pDialog->m_Controls.GetSize() - 1;
}
return pDialog->m_Controls.GetAt( index );
}
//--------------------------------------------------------------------------------------
// CDXUTControl class
//--------------------------------------------------------------------------------------

View File

@ -103,6 +103,8 @@ public:
static CDXUTControl* GetNextControl( CDXUTControl* pControl );
static CDXUTControl* GetPrevControl( CDXUTControl* pControl );
void RemoveAllControls();
// Sets the callback used to notify the app of control events
@ -128,6 +130,8 @@ private:
static double s_fTimeRefresh;
double m_fTimeLastRefresh;
static CDXUTControl* s_pControlFocus; // The control which has focus
static CDXUTControl* s_pControlPressed; // The control currently pressed
CDXUTControl* m_pControlMouseOver; // The control which is hovered over