|
From: <sl...@us...> - 2003-11-05 21:21:16
|
Update of /cvsroot/aedgui/aedGUI/src
In directory sc8-pr-cvs1:/tmp/cvs-serv14366/src
Modified Files:
aedApp.cpp aedButton.cpp aedListBox.cpp aedTextBox.cpp
aedWidget.cpp aedXmlFile.cpp
Log Message:
Added tab focus support
Added global buttons for okay and cancel actions
Index: aedApp.cpp
===================================================================
RCS file: /cvsroot/aedgui/aedGUI/src/aedApp.cpp,v
retrieving revision 1.27
retrieving revision 1.28
diff -C2 -d -r1.27 -r1.28
*** aedApp.cpp 25 Oct 2003 19:23:59 -0000 1.27
--- aedApp.cpp 5 Nov 2003 19:26:07 -0000 1.28
***************
*** 11,14 ****
--- 11,15 ----
#include "aedUpdateManager.h"
#include "aedWidget.h"
+ #include "aedButton.h"
#include "SDL_ttf.h"
***************
*** 39,42 ****
--- 40,45 ----
m_Root = NULL;
m_FocusWidget = NULL;
+ m_okayButton = NULL;
+ m_cancelButton = NULL;
m_UTF8 = false;
***************
*** 118,122 ****
void aedApp::setFocusWidget(aedWidget *win)
{
! if(m_FocusWidget != NULL && win != NULL && m_FocusWidget != m_Root)
{
// tell the old widget that it lost focus
--- 121,128 ----
void aedApp::setFocusWidget(aedWidget *win)
{
! if(win && !win->canFocus())
! win = NULL;
!
! if(m_FocusWidget != NULL && m_FocusWidget != m_Root)
{
// tell the old widget that it lost focus
***************
*** 128,139 ****
m_FocusWidget = win;
if(m_FocusWidget && m_FocusWidget != m_Root)
{
m_FocusWidget->setActiveBorder(true);
m_FocusWidget->setRenderState(true);
- m_FocusWidget->bringToTop();
m_FocusWidget->wm_gotfocus();
m_FocusWidget->triggerEvent(GOT_FOCUS, m_FocusWidget, NULL);
}
}
--- 134,159 ----
m_FocusWidget = win;
+
if(m_FocusWidget && m_FocusWidget != m_Root)
{
m_FocusWidget->setActiveBorder(true);
m_FocusWidget->setRenderState(true);
m_FocusWidget->wm_gotfocus();
m_FocusWidget->triggerEvent(GOT_FOCUS, m_FocusWidget, NULL);
}
+ }
+
+ void
+ aedApp::clickOkayButton()
+ {
+ if ( m_okayButton )
+ m_okayButton->click();
+ }
+
+ void
+ aedApp::clickCancelButton()
+ {
+ if ( m_cancelButton )
+ m_cancelButton->click();
}
Index: aedButton.cpp
===================================================================
RCS file: /cvsroot/aedgui/aedGUI/src/aedButton.cpp,v
retrieving revision 1.21
retrieving revision 1.22
diff -C2 -d -r1.21 -r1.22
*** aedButton.cpp 25 Oct 2003 00:05:18 -0000 1.21
--- aedButton.cpp 5 Nov 2003 19:26:07 -0000 1.22
***************
*** 14,17 ****
--- 14,25 ----
}
+ aedButton::~aedButton()
+ {
+ if(this == pApp->getOkayButton())
+ pApp->setOkayButton(NULL);
+ if(this == pApp->getCancelButton())
+ pApp->setCancelButton(NULL);
+ }
+
void
aedButton::setButtonState(bool s)
***************
*** 27,42 ****
}
int
aedButton::wm_keydown(aedKeyEvent & event)
{
- aedWidget::wm_keydown(event);
-
if(event.sym == SDLK_RETURN || event.sym == SDLK_SPACE)
{
! wm_lbuttondown(0, 0);
! wm_lbuttonup(0, 0);
}
!
! return 0;
}
--- 35,56 ----
}
+ void
+ aedButton::click()
+ {
+ wm_lbuttondown(0, 0);
+ triggerEvent(MOUSE_LBUTTON_DOWN, this, NULL);
+ wm_lbuttonup(0, 0);
+ triggerEvent(MOUSE_LBUTTON_UP, this, NULL);
+ }
+
int
aedButton::wm_keydown(aedKeyEvent & event)
{
if(event.sym == SDLK_RETURN || event.sym == SDLK_SPACE)
{
! click();
! return 0;
}
! return aedWidget::wm_keydown(event);
}
Index: aedListBox.cpp
===================================================================
RCS file: /cvsroot/aedgui/aedGUI/src/aedListBox.cpp,v
retrieving revision 1.17
retrieving revision 1.18
diff -C2 -d -r1.17 -r1.18
*** aedListBox.cpp 17 Sep 2003 18:50:55 -0000 1.17
--- aedListBox.cpp 5 Nov 2003 19:26:07 -0000 1.18
***************
*** 6,10 ****
{
m_IsWidget = true;
- m_CanFocus = true;
m_currentLine = 0;
setBorder(AED_BORDER_ROUND);
--- 6,9 ----
Index: aedTextBox.cpp
===================================================================
RCS file: /cvsroot/aedgui/aedGUI/src/aedTextBox.cpp,v
retrieving revision 1.29
retrieving revision 1.30
diff -C2 -d -r1.29 -r1.30
*** aedTextBox.cpp 25 Oct 2003 00:05:18 -0000 1.29
--- aedTextBox.cpp 5 Nov 2003 19:26:08 -0000 1.30
***************
*** 114,121 ****
}
- aedWidget::wm_keydown(event);
-
if(key == SDLK_TAB || key == SDLK_RETURN || key == SDLK_ESCAPE)
! return 0;
Uint32 SelectStart = m_SelectionStart;
--- 114,119 ----
}
if(key == SDLK_TAB || key == SDLK_RETURN || key == SDLK_ESCAPE)
! return aedWidget::wm_keydown(event);
Uint32 SelectStart = m_SelectionStart;
Index: aedWidget.cpp
===================================================================
RCS file: /cvsroot/aedgui/aedGUI/src/aedWidget.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** aedWidget.cpp 1 Nov 2003 02:22:31 -0000 1.5
--- aedWidget.cpp 5 Nov 2003 19:26:08 -0000 1.6
***************
*** 149,152 ****
--- 149,196 ----
}
+ bool
+ aedWidget::tabFocus()
+ {
+ if(!isEnabled()) {
+ return false;
+ }
+ if(m_CanFocus) {
+ pApp->setFocusWidget(this);
+ return true;
+ }
+ return tabFocusChildren();
+ }
+
+ bool
+ aedWidget::tabFocusChildren()
+ {
+ std::vector < aedWidget * >::iterator p = m_Children.begin();
+ while(p != m_Children.end()) {
+ if((*p)->tabFocus()) {
+ return true;
+ }
+ ++p;
+ }
+ return false;
+ }
+
+ void
+ aedWidget::tabFocusParent()
+ {
+ if(m_Parent) {
+ std::vector < aedWidget * >::iterator p = std::find(m_Parent->m_Children.begin(), m_Parent->m_Children.end(), this);
+ ++p;
+ while(p != m_Parent->m_Children.end()) {
+ if((*p)->tabFocus()) {
+ return;
+ }
+ ++p;
+ }
+ m_Parent->tabFocusParent();
+ return;
+ }
+ tabFocusChildren();
+ }
+
void
aedWidget::setSize(Sint16 w, Sint16 h)
***************
*** 547,578 ****
aedWidget::wm_keydown(aedKeyEvent & event)
{
! // The following code belongs to a Tab Event
! // and should be moved somewhere else
!
! // if(m_Parent==NULL)
! // return 0;
! // size_t nChildCount = m_Children.size();
! // if((event.sym == SDLK_TAB)&&())
! // {
! // for(i = 0; i < nChildCount; ++i)
! // {
! // if(!parent->m_Children[i])->m_IsWidget
! // && i < parent->m_Children.size() ||
! // parent->m_Children[i]->isActive()
! // || parent->m_Children[i]->isEnabled()
! // || parent->m_Children[i]->m_CanFocus)
! // {
! // continue;
! // }
! // break;
! // }
!
! // if(i >= parent->m_Children.size())
! // return 0;
! // parent->m_Children[i]->bringToTop();
! // return 0;
! // }
!
! return 0;
}
--- 591,606 ----
aedWidget::wm_keydown(aedKeyEvent & event)
{
! // Default processing of tab switches widget focus
! if(event.sym == SDLK_TAB) {
! if(!tabFocusChildren())
! tabFocusParent();
! }
! if(event.sym == SDLK_RETURN) {
! pApp->clickOkayButton();
! }
! if(event.sym == SDLK_ESCAPE) {
! pApp->clickCancelButton();
! }
! return 0;
}
***************
*** 678,688 ****
keyevent.sym = event->key.keysym.sym;
keyevent.unicode = event->key.keysym.unicode;
- // size_t ChildrenCount = m_Children.size();
- // if((keyevent.sym == SDLK_TAB)&&(ChildrenCount>1))
- // {
- // for(i = 0; i < nChildCount; ++i)
- // {
- // }
- // }
if(pFocused != NULL && pFocused->isEnabled())
{
--- 706,709 ----
***************
*** 736,745 ****
{
pFocused->wm_lbuttondown(event->button.x, event->button.y);
! pFocused->triggerEvent(MOUSE_LBUTTON_DOWN, child, NULL);
}
else if (event->button.button == SDL_BUTTON_RIGHT)
{
pFocused->wm_rbuttondown(event->button.x, event->button.y);
! pFocused->triggerEvent(MOUSE_RBUTTON_DOWN, child, NULL);
}
}
--- 757,766 ----
{
pFocused->wm_lbuttondown(event->button.x, event->button.y);
! pFocused->triggerEvent(MOUSE_LBUTTON_DOWN, pFocused, NULL);
}
else if (event->button.button == SDL_BUTTON_RIGHT)
{
pFocused->wm_rbuttondown(event->button.x, event->button.y);
! pFocused->triggerEvent(MOUSE_RBUTTON_DOWN, pFocused, NULL);
}
}
***************
*** 747,764 ****
case SDL_MOUSEBUTTONUP:
- child = findChildAtCoord(event->button.x, event->button.y,
- NO_STATIC);
! if(child && child != this && child->isEnabled())
{
if (event->button.button == SDL_BUTTON_LEFT)
{
pFocused->wm_lbuttonup(event->button.x, event->button.y);
! pFocused->triggerEvent(MOUSE_LBUTTON_UP, child, NULL);
}
else if (event->button.button == SDL_BUTTON_RIGHT)
{
pFocused->wm_rbuttonup(event->button.x, event->button.y);
! pFocused->triggerEvent(MOUSE_RBUTTON_UP, child, NULL);
}
}
--- 768,783 ----
case SDL_MOUSEBUTTONUP:
! if(pFocused != NULL && pFocused->isEnabled())
{
if (event->button.button == SDL_BUTTON_LEFT)
{
pFocused->wm_lbuttonup(event->button.x, event->button.y);
! pFocused->triggerEvent(MOUSE_LBUTTON_UP, pFocused, NULL);
}
else if (event->button.button == SDL_BUTTON_RIGHT)
{
pFocused->wm_rbuttonup(event->button.x, event->button.y);
! pFocused->triggerEvent(MOUSE_RBUTTON_UP, pFocused, NULL);
}
}
Index: aedXmlFile.cpp
===================================================================
RCS file: /cvsroot/aedgui/aedGUI/src/aedXmlFile.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** aedXmlFile.cpp 25 Oct 2003 00:05:18 -0000 1.4
--- aedXmlFile.cpp 5 Nov 2003 19:26:08 -0000 1.5
***************
*** 348,352 ****
radiobuttongroup->addButton(Text);
! std::cerr << "Added raido button: " << Name << " : " << Text << std::endl;
}
--- 348,352 ----
radiobuttongroup->addButton(Text);
! std::cerr << "Added radio button: " << Name << " : " << Text << std::endl;
}
|