2000-11-02 16:54:27 +01:00
|
|
|
/*=========================================================================
|
|
|
|
|
2000-11-02 18:16:10 +01:00
|
|
|
gbutton.cpp
|
2000-11-02 16:54:27 +01:00
|
|
|
|
|
|
|
Author: PKG
|
|
|
|
Created:
|
|
|
|
Project: Spongebob
|
|
|
|
Purpose:
|
|
|
|
|
|
|
|
Copyright (c) 2000 Climax Development Ltd
|
|
|
|
|
|
|
|
===========================================================================*/
|
|
|
|
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------
|
|
|
|
Includes
|
|
|
|
-------- */
|
|
|
|
|
|
|
|
#include "gui\gframe.h"
|
|
|
|
|
|
|
|
#ifndef __PAD_PADS_H__
|
|
|
|
#include "pad\pads.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
/* Std Lib
|
|
|
|
------- */
|
|
|
|
|
|
|
|
/* Data
|
|
|
|
---- */
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------
|
|
|
|
Tyepdefs && Defines
|
|
|
|
------------------- */
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------
|
|
|
|
Structure defintions
|
|
|
|
-------------------- */
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------
|
|
|
|
Function Prototypes
|
|
|
|
------------------- */
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------
|
|
|
|
Vars
|
|
|
|
---- */
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------
|
|
|
|
Function:
|
|
|
|
Purpose:
|
|
|
|
Params:
|
|
|
|
Returns:
|
|
|
|
---------------------------------------------------------------------- */
|
|
|
|
void CGUIGroupFrame::setFlags(GUI_FLAGS _flags)
|
|
|
|
{
|
|
|
|
CGUIObject *pGUI;
|
|
|
|
|
2000-11-02 18:16:10 +01:00
|
|
|
CGUIObject::setFlags(_flags);
|
2000-11-02 16:54:27 +01:00
|
|
|
pGUI=getChild();
|
2000-11-02 18:16:10 +01:00
|
|
|
while(pGUI)
|
2000-11-02 16:54:27 +01:00
|
|
|
{
|
2000-11-02 18:16:10 +01:00
|
|
|
pGUI->setFlags(_flags);
|
2000-11-02 16:54:27 +01:00
|
|
|
pGUI=pGUI->getNext();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------
|
|
|
|
Function:
|
|
|
|
Purpose:
|
|
|
|
Params:
|
|
|
|
Returns:
|
|
|
|
---------------------------------------------------------------------- */
|
2000-11-02 18:16:10 +01:00
|
|
|
void CGUIGroupFrame::clearFlags(GUI_FLAGS _flags)
|
2000-11-02 16:54:27 +01:00
|
|
|
{
|
|
|
|
CGUIObject *pGUI;
|
2000-11-02 18:16:10 +01:00
|
|
|
|
|
|
|
CGUIObject::clearFlags(_flags);
|
2000-11-02 16:54:27 +01:00
|
|
|
pGUI=getChild();
|
2000-11-02 18:16:10 +01:00
|
|
|
while(pGUI)
|
2000-11-02 16:54:27 +01:00
|
|
|
{
|
2000-11-02 18:16:10 +01:00
|
|
|
pGUI->clearFlags(_flags);
|
2000-11-02 16:54:27 +01:00
|
|
|
pGUI=pGUI->getNext();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-11-02 18:35:44 +01:00
|
|
|
/*----------------------------------------------------------------------
|
|
|
|
Function:
|
|
|
|
Purpose:
|
|
|
|
Params:
|
|
|
|
Returns:
|
|
|
|
---------------------------------------------------------------------- */
|
|
|
|
int CGUIGroupFrame::isSelectable()
|
|
|
|
{
|
|
|
|
CGUIObject *pGUI;
|
|
|
|
int selectable=false;
|
|
|
|
|
|
|
|
pGUI=getChild();
|
|
|
|
while(pGUI)
|
|
|
|
{
|
|
|
|
if(pGUI->isSelectable())
|
|
|
|
{
|
|
|
|
selectable=true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
pGUI=pGUI->getNext();
|
|
|
|
}
|
|
|
|
|
|
|
|
return selectable;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-11-07 23:05:42 +01:00
|
|
|
/*----------------------------------------------------------------------
|
|
|
|
Function:
|
|
|
|
Purpose:
|
|
|
|
Params:
|
|
|
|
Returns:
|
|
|
|
---------------------------------------------------------------------- */
|
|
|
|
int CGUIGroupFrame::isUnselectable()
|
|
|
|
{
|
|
|
|
CGUIObject *pGUI;
|
|
|
|
int unselectable=false;
|
|
|
|
|
|
|
|
pGUI=getChild();
|
|
|
|
while(pGUI)
|
|
|
|
{
|
|
|
|
if(pGUI->isUnselectable())
|
|
|
|
{
|
|
|
|
unselectable=true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
pGUI=pGUI->getNext();
|
|
|
|
}
|
|
|
|
|
|
|
|
return unselectable;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-11-02 16:54:27 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------
|
|
|
|
Function:
|
|
|
|
Purpose:
|
|
|
|
Params:
|
|
|
|
Returns:
|
|
|
|
---------------------------------------------------------------------- */
|
|
|
|
void CGUIControlFrame::think(int _frames)
|
|
|
|
{
|
|
|
|
int pad;
|
|
|
|
|
|
|
|
CGUIObject::think(_frames);
|
|
|
|
|
|
|
|
pad=PadGetRepeat(0);
|
|
|
|
if(pad&PAD_DOWN)
|
|
|
|
{
|
|
|
|
CGUIObject *pGUI;
|
|
|
|
|
|
|
|
pGUI=getChild();
|
|
|
|
if(pGUI)
|
|
|
|
{
|
|
|
|
// Get current selection and deselect it
|
|
|
|
while(!pGUI->isSelected())
|
|
|
|
{
|
|
|
|
ASSERT(pGUI);
|
|
|
|
pGUI=pGUI->getNext();
|
|
|
|
}
|
2000-11-07 23:05:42 +01:00
|
|
|
if(pGUI->isUnselectable())
|
2000-11-02 18:35:44 +01:00
|
|
|
{
|
2000-11-07 23:05:42 +01:00
|
|
|
pGUI->unselect();
|
|
|
|
|
|
|
|
// Find next selectable object and select it
|
|
|
|
do
|
|
|
|
{
|
|
|
|
pGUI=pGUI->getNext();
|
|
|
|
if(!pGUI)pGUI=getChild();
|
|
|
|
}
|
|
|
|
while(!pGUI->isSelectable());
|
|
|
|
pGUI->select();
|
2000-11-02 18:35:44 +01:00
|
|
|
}
|
2000-11-02 16:54:27 +01:00
|
|
|
}
|
|
|
|
}
|
2000-11-03 01:07:42 +01:00
|
|
|
else if(pad&PAD_UP)
|
|
|
|
{
|
|
|
|
CGUIObject *pGUI,*prevGUI;
|
|
|
|
|
|
|
|
pGUI=getChild();
|
|
|
|
prevGUI=0;
|
|
|
|
if(pGUI)
|
|
|
|
{
|
|
|
|
// Get current selection and deselect it
|
|
|
|
while(!pGUI->isSelected())
|
|
|
|
{
|
|
|
|
ASSERT(pGUI);
|
|
|
|
if(pGUI->isSelectable())
|
|
|
|
{
|
|
|
|
prevGUI=pGUI;
|
|
|
|
}
|
|
|
|
pGUI=pGUI->getNext();
|
|
|
|
}
|
2000-11-07 23:05:42 +01:00
|
|
|
if(pGUI->isUnselectable())
|
2000-11-03 01:07:42 +01:00
|
|
|
{
|
2000-11-07 23:05:42 +01:00
|
|
|
pGUI->unselect();
|
|
|
|
|
|
|
|
// Find previous selectable object and select it
|
|
|
|
if(!prevGUI)
|
2000-11-03 01:07:42 +01:00
|
|
|
{
|
2000-11-07 23:05:42 +01:00
|
|
|
do
|
2000-11-03 01:07:42 +01:00
|
|
|
{
|
2000-11-07 23:05:42 +01:00
|
|
|
if(pGUI->isSelectable())
|
|
|
|
{
|
|
|
|
prevGUI=pGUI;
|
|
|
|
}
|
|
|
|
pGUI=pGUI->getNext();
|
2000-11-03 01:07:42 +01:00
|
|
|
}
|
2000-11-07 23:05:42 +01:00
|
|
|
while(pGUI);
|
2000-11-03 01:07:42 +01:00
|
|
|
}
|
2000-11-07 23:05:42 +01:00
|
|
|
prevGUI->select();
|
2000-11-03 01:07:42 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2000-11-02 16:54:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------
|
|
|
|
Function:
|
|
|
|
Purpose:
|
|
|
|
Params:
|
|
|
|
Returns:
|
|
|
|
---------------------------------------------------------------------- */
|
|
|
|
void CGUIControlFrame::setFlags(GUI_FLAGS _flags)
|
|
|
|
{
|
|
|
|
GUI_FLAGS childFlags;
|
|
|
|
|
|
|
|
CGUIObject::setFlags(_flags);
|
|
|
|
childFlags=(GUI_FLAGS)(_flags&(-1^FLAG_SELECTED)); // Don't propogate the SELECTED flag
|
|
|
|
if(getChild())getChild()->setFlags(childFlags);
|
|
|
|
|
|
|
|
if(_flags&FLAG_SELECTED)
|
|
|
|
{
|
|
|
|
selectFrame();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------
|
|
|
|
Function:
|
|
|
|
Purpose:
|
|
|
|
Params:
|
|
|
|
Returns:
|
|
|
|
---------------------------------------------------------------------- */
|
|
|
|
void CGUIControlFrame::clearFlags(GUI_FLAGS _flags)
|
|
|
|
{
|
|
|
|
GUI_FLAGS childFlags;
|
|
|
|
|
|
|
|
CGUIObject::clearFlags(_flags);
|
|
|
|
childFlags=(GUI_FLAGS)(_flags&(-1^FLAG_SELECTED)); // Don't propogate the SELECTED flag
|
|
|
|
if(getChild())getChild()->clearFlags(childFlags);
|
|
|
|
|
|
|
|
if(_flags&FLAG_SELECTED)
|
|
|
|
{
|
|
|
|
unselectFrame();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------
|
|
|
|
Function:
|
|
|
|
Purpose:
|
|
|
|
Params:
|
|
|
|
Returns:
|
|
|
|
---------------------------------------------------------------------- */
|
|
|
|
void CGUIControlFrame::selectFrame()
|
|
|
|
{
|
|
|
|
CGUIObject *pGUI;
|
|
|
|
|
|
|
|
pGUI=getChild();
|
2000-11-02 18:35:44 +01:00
|
|
|
while(!pGUI->isSelectable())
|
2000-11-02 16:54:27 +01:00
|
|
|
{
|
2000-11-02 18:35:44 +01:00
|
|
|
ASSERT(pGUI);
|
|
|
|
pGUI=pGUI->getNext();
|
2000-11-02 16:54:27 +01:00
|
|
|
}
|
2000-11-02 18:35:44 +01:00
|
|
|
pGUI->select();
|
2000-11-02 16:54:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------
|
|
|
|
Function:
|
|
|
|
Purpose:
|
|
|
|
Params:
|
|
|
|
Returns:
|
|
|
|
---------------------------------------------------------------------- */
|
|
|
|
void CGUIControlFrame::unselectFrame()
|
|
|
|
{
|
|
|
|
CGUIObject *pGUI;
|
|
|
|
|
|
|
|
pGUI=getChild();
|
|
|
|
if(pGUI)
|
|
|
|
{
|
|
|
|
while(!pGUI->isSelected())
|
|
|
|
{
|
|
|
|
ASSERT(pGUI);
|
|
|
|
pGUI=pGUI->getNext();
|
|
|
|
}
|
|
|
|
pGUI->unselect();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*===========================================================================
|
|
|
|
end */
|