Fixed bug where no key events were being sent to any Tab child widget

that had WIDGET_TAB_NAVIGATE set (which is exactly the opposite of
what we want).

Added a dashed line to FrameBuffer::frameRect().  This is currently
used to indicate which widget is selected in debugger mode.  IMO, it
looks much better than using a solid line.


git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@563 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2005-06-25 16:35:36 +00:00
parent a935b2bcaf
commit ed82864152
4 changed files with 53 additions and 26 deletions

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: FrameBuffer.cxx,v 1.47 2005-06-23 14:33:11 stephena Exp $
// $Id: FrameBuffer.cxx,v 1.48 2005-06-25 16:35:36 stephena Exp $
//============================================================================
#include <sstream>
@ -557,12 +557,38 @@ void FrameBuffer::box(uInt32 x, uInt32 y, uInt32 w, uInt32 h,
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FrameBuffer::frameRect(uInt32 x, uInt32 y, uInt32 w, uInt32 h,
OverlayColor color)
OverlayColor color, FrameStyle style)
{
hLine(x, y, x + w - 1, color);
hLine(x, y + h - 1, x + w - 1, color);
vLine(x, y, y + h - 1, color);
vLine(x + w - 1, y, y + h - 1, color);
switch(style)
{
case kSolidLine:
hLine(x, y, x + w - 1, color);
hLine(x, y + h - 1, x + w - 1, color);
vLine(x, y, y + h - 1, color);
vLine(x + w - 1, y, y + h - 1, color);
break;
case kDashLine:
unsigned int i, skip, lwidth = 1;
for(i = x, skip = 1; i < x+w-1; i=i+lwidth+1, ++skip)
{
if(skip % 2)
{
hLine(i, y, i + lwidth, color);
hLine(i, y + h - 1, i + lwidth, color);
}
}
for(i = y, skip = 1; i < y+h-1; i=i+lwidth+1, ++skip)
{
if(skip % 2)
{
vLine(x, i, i + lwidth, color);
vLine(x + w - 1, i, i + lwidth, color);
}
}
break;
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: FrameBuffer.hxx,v 1.42 2005-06-23 14:33:11 stephena Exp $
// $Id: FrameBuffer.hxx,v 1.43 2005-06-25 16:35:36 stephena Exp $
//============================================================================
#ifndef FRAMEBUFFER_HXX
@ -33,9 +33,15 @@ class Console;
// Text alignment modes for drawString()
enum TextAlignment {
kTextAlignLeft,
kTextAlignCenter,
kTextAlignRight
kTextAlignLeft,
kTextAlignCenter,
kTextAlignRight
};
// Line types for drawing rectangular frames
enum FrameStyle {
kSolidLine,
kDashLine
};
/**
@ -46,7 +52,7 @@ enum TextAlignment {
All GUI elements (ala ScummVM) are drawn here as well.
@author Stephen Anthony
@version $Id: FrameBuffer.hxx,v 1.42 2005-06-23 14:33:11 stephena Exp $
@version $Id: FrameBuffer.hxx,v 1.43 2005-06-25 16:35:36 stephena Exp $
*/
class FrameBuffer
{
@ -233,7 +239,7 @@ class FrameBuffer
@param color The color of the surrounding frame
*/
void frameRect(uInt32 x, uInt32 y, uInt32 w, uInt32 h,
OverlayColor color);
OverlayColor color, FrameStyle style = kSolidLine);
/**
This method should be called to draw the specified string.

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: TabWidget.cxx,v 1.11 2005-06-24 12:01:27 stephena Exp $
// $Id: TabWidget.cxx,v 1.12 2005-06-25 16:35:36 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -204,12 +204,6 @@ void TabWidget::handleMouseDown(int x, int y, int button, int clickCount)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool TabWidget::handleKeyDown(int ascii, int keycode, int modifiers)
{
// Pass the tab key to the activeWidget if we know that widget
// navigation won't be needed
bool navigateWanted = false;
if(_activeWidget && (_activeWidget->getFlags() & WIDGET_TAB_NAVIGATE))
navigateWanted = true;
// Test for TAB character
// Ctrl-Tab selects next tab
// Shift-Ctrl-Tab selects previous tab
@ -223,20 +217,21 @@ bool TabWidget::handleKeyDown(int ascii, int keycode, int modifiers)
cycleTab(-1);
else
cycleTab(+1);
return true; // this key-combo is never passed to the child widget
}
else if(navigateWanted)
else if(_activeWidget && (_activeWidget->getFlags() & WIDGET_TAB_NAVIGATE))
{
if(_boss->instance()->eventHandler().kbdShift(modifiers))
cycleWidget(-1);
else
cycleWidget(+1);
}
if(navigateWanted)
return true;
return true; // swallow tab key if the current widget wants navigation
}
}
if (_activeWidget && !navigateWanted)
if (_activeWidget)
return _activeWidget->handleKeyDown(ascii, keycode, modifiers);
else
return Widget::handleKeyDown(ascii, keycode, modifiers);

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: Widget.cxx,v 1.19 2005-06-23 14:33:12 stephena Exp $
// $Id: Widget.cxx,v 1.20 2005-06-25 16:35:36 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -91,7 +91,7 @@ void Widget::draw()
// Indicate if this is the currently active widget
// by drawing a box around it.
if((_activeWidget == this) && (_flags & WIDGET_TAB_NAVIGATE))
fb.frameRect(_x-1, _y-1, _w+2, _h+2, kTextColorEm); // FIXME - maybe chose a better color
fb.frameRect(_x-1, _y-1, _w+2, _h+2, kTextColorEm, kDashLine);
// Restore x/y
if (_flags & WIDGET_BORDER) {