Mailinglist Archive: yast-commit (870 mails)
| < Previous | Next > |
[yast-commit] r48949 - in /trunk/ncurses/src: NCDumbTab.cc NCDumbTab.h NCWidget.cc NCWidget.h
- From: gs@xxxxxxxxxxxxxxxx
- Date: Thu, 10 Jul 2008 10:32:24 -0000
- Message-id: <20080710103224.524642F19A@xxxxxxxxxxxxxxxx>
Author: gs
Date: Thu Jul 10 12:32:23 2008
New Revision: 48949
URL: http://svn.opensuse.org/viewcvs/yast?rev=48949&view=rev
Log:
first step to support short cuts in DumbTab widget
Modified:
trunk/ncurses/src/NCDumbTab.cc
trunk/ncurses/src/NCDumbTab.h
trunk/ncurses/src/NCWidget.cc
trunk/ncurses/src/NCWidget.h
Modified: trunk/ncurses/src/NCDumbTab.cc
URL:
http://svn.opensuse.org/viewcvs/yast/trunk/ncurses/src/NCDumbTab.cc?rev=48949&r1=48948&r2=48949&view=diff
==============================================================================
--- trunk/ncurses/src/NCDumbTab.cc (original)
+++ trunk/ncurses/src/NCDumbTab.cc Thu Jul 10 12:32:23 2008
@@ -22,6 +22,7 @@
#include "NCDialog.h"
#include "NCurses.h"
#include "NCDumbTab.h"
+#include "NCPopupList.h"
NCDumbTab::NCDumbTab( YWidget * parent )
@@ -44,12 +45,15 @@
{
defsze.W = firstChild()->preferredWidth();
- vector<NClabel>::iterator listIt = tabList.begin();
+ YItemIterator listIt = itemsBegin();
+
unsigned int tabBarWidth = 0;
+ NClabel tabLabel;
- while ( listIt != tabList.end() )
+ while ( listIt != itemsEnd() )
{
- tabBarWidth += (*listIt).width() + 1;
+ tabLabel = NClabel( (*listIt)->label() );
+ tabBarWidth += tabLabel.width() + 1;
++listIt;
}
++tabBarWidth;
@@ -59,6 +63,9 @@
defsze.W += framedim.Sze.W;
+ if ( defsze.W > NCurses::cols() )
+ defsze.W = NCurses::cols();
+
return defsze.W;
}
@@ -96,7 +103,8 @@
switch ( key )
{
case KEY_LEFT:
- if ( currentIndex > 0 && currentIndex <= tabList.size() -1 )
+ if ( currentIndex > 0 &&
+ currentIndex <= (unsigned)itemsCount() -1 )
{
currentIndex--;
wRedraw();
@@ -106,7 +114,8 @@
break;
case KEY_RIGHT:
- if ( currentIndex < tabList.size()-1 && currentIndex >= 0 )
+ if ( currentIndex < (unsigned)itemsCount()-1 &&
+ currentIndex >= 0 )
{
currentIndex++;
wRedraw();
@@ -115,6 +124,8 @@
}
break;
+ case KEY_HOTKEY:
+ yuiMilestone() << "HOT key" << endl;
case KEY_RETURN:
ret = createMenuEvent( currentIndex );
break;
@@ -143,9 +154,8 @@
{
YDumbTab::addItem( item );
- NClabel tabLabel = NClabel( item->label() );
+ NClabel tabLabel = NCstring( item->label() );
yuiDebug() << "Add item: " << item->label() << endl;
- tabList.push_back( tabLabel );
if ( item->selected() )
currentIndex = item->index();
@@ -164,28 +174,43 @@
wRedraw();
}
+void NCDumbTab::shortcutChanged()
+{
+ // Any of the items might have its keyboard shortcut changed, but we don't
+ // know which one. So let's simply set all tab labels again.
+
+ wRedraw();
+}
+
void NCDumbTab::wRedraw()
{
if ( !win )
return;
-
+
const NCstyle::StWidget & style( widgetStyle(true) );
win->bkgd( style.plain );
win->box();
- vector<NClabel>::iterator listIt = tabList.begin();
+ YItemIterator listIt = itemsBegin();
+
int winWidth = win->width() - 2;
- int labelPos = 1;
+ unsigned int labelPos = 1;
unsigned int i = 0;
bool nonActive = false;
+ NClabel tablabel;
- while ( listIt != tabList.end() )
+ while ( listIt != itemsEnd() )
{
+ tablabel = NCstring( (*listIt)->label() );
+ tablabel.stripHotkey();
+ hotlabel = &tablabel;
+
nonActive = (i == currentIndex)?false:true;
+
if ( GetState() == NC::WSactive )
{
- (*listIt).drawAt( *win,
+ tablabel.drawAt( *win,
NCstyle::StWidget( widgetStyle( nonActive) ),
wpos( 0, labelPos ),
wsze( 1, winWidth ),
@@ -195,7 +220,7 @@
{
if ( !nonActive )
{
- (*listIt).drawAt( *win,
+ tablabel.drawAt( *win,
widgetStyle( ).data,
widgetStyle( ).data,
wpos( 0, labelPos ),
@@ -204,7 +229,7 @@
}
else
{
- (*listIt).drawAt( *win,
+ tablabel.drawAt( *win,
NCstyle::StWidget( frameStyle() ),
wpos( 0, labelPos ),
wsze( 1, winWidth ),
@@ -212,14 +237,14 @@
}
}
- labelPos += (*listIt).width() + 2;
+ labelPos += tablabel.width() + 2;
++listIt;
++i;
- if ( listIt != tabList.end() )
+ if ( listIt != itemsEnd() )
{
- winWidth -= (*listIt).width() -1;
+ winWidth -= tablabel.width() -1;
}
};
@@ -231,7 +256,28 @@
redrawChilds( firstChild() );
}
- }
+}
+
+bool NCDumbTab::HasHotkey( int key )
+{
+ bool ret = false;
+
+ YItemIterator listIt = itemsBegin();
+ NClabel tablabel;
+
+ while ( listIt != itemsEnd() )
+ {
+ tablabel = NCstring( (*listIt)->label() );
+ tablabel.stripHotkey();
+ if ( tablabel.hasHotkey() )
+ ret = true;
+ ++listIt;
+ }
+
+ yuiMilestone() << "Has hot key: " << key << " " << (ret?"yes":"no") <<
endl;
+
+ return ret;
+}
void NCDumbTab::redrawChilds( YWidget *widget )
{
Modified: trunk/ncurses/src/NCDumbTab.h
URL:
http://svn.opensuse.org/viewcvs/yast/trunk/ncurses/src/NCDumbTab.h?rev=48949&r1=48948&r2=48949&view=diff
==============================================================================
--- trunk/ncurses/src/NCDumbTab.h (original)
+++ trunk/ncurses/src/NCDumbTab.h Thu Jul 10 12:32:23 2008
@@ -34,9 +34,8 @@
NCDumbTab & operator=( const NCDumbTab & );
NCDumbTab( const NCDumbTab & );
- vector <NClabel> tabList;
unsigned int currentIndex;
-
+
protected:
virtual const char * location() const { return "NCDumbTab"; }
@@ -61,6 +60,10 @@
virtual void setEnabled( bool do_bv );
+ virtual void shortcutChanged();
+
+ virtual bool HasHotkey( int key );
+
virtual bool setKeyboardFocus()
{
if ( !grabFocus() )
@@ -70,6 +73,7 @@
}
NCursesEvent createMenuEvent( unsigned int index);
+
};
Modified: trunk/ncurses/src/NCWidget.cc
URL:
http://svn.opensuse.org/viewcvs/yast/trunk/ncurses/src/NCWidget.cc?rev=48949&r1=48948&r2=48949&view=diff
==============================================================================
--- trunk/ncurses/src/NCWidget.cc (original)
+++ trunk/ncurses/src/NCWidget.cc Thu Jul 10 12:32:23 2008
@@ -495,7 +495,7 @@
-bool NCWidget::HasHotkey( int key ) const
+bool NCWidget::HasHotkey( int key )
{
if ( key < 0 || UCHAR_MAX < key )
return false;
Modified: trunk/ncurses/src/NCWidget.h
URL:
http://svn.opensuse.org/viewcvs/yast/trunk/ncurses/src/NCWidget.h?rev=48949&r1=48948&r2=48949&view=diff
==============================================================================
--- trunk/ncurses/src/NCWidget.h (original)
+++ trunk/ncurses/src/NCWidget.h Thu Jul 10 12:32:23 2008
@@ -166,7 +166,7 @@
**/
virtual void setEnabled( bool do_bv ) = 0;
- virtual bool HasHotkey( int key ) const;
+ virtual bool HasHotkey( int key );
virtual bool HasFunctionHotkey( int key ) const;
virtual NCursesEvent wHandleHotkey( wint_t key );
--
To unsubscribe, e-mail: yast-commit+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: yast-commit+help@xxxxxxxxxxxx
Date: Thu Jul 10 12:32:23 2008
New Revision: 48949
URL: http://svn.opensuse.org/viewcvs/yast?rev=48949&view=rev
Log:
first step to support short cuts in DumbTab widget
Modified:
trunk/ncurses/src/NCDumbTab.cc
trunk/ncurses/src/NCDumbTab.h
trunk/ncurses/src/NCWidget.cc
trunk/ncurses/src/NCWidget.h
Modified: trunk/ncurses/src/NCDumbTab.cc
URL:
http://svn.opensuse.org/viewcvs/yast/trunk/ncurses/src/NCDumbTab.cc?rev=48949&r1=48948&r2=48949&view=diff
==============================================================================
--- trunk/ncurses/src/NCDumbTab.cc (original)
+++ trunk/ncurses/src/NCDumbTab.cc Thu Jul 10 12:32:23 2008
@@ -22,6 +22,7 @@
#include "NCDialog.h"
#include "NCurses.h"
#include "NCDumbTab.h"
+#include "NCPopupList.h"
NCDumbTab::NCDumbTab( YWidget * parent )
@@ -44,12 +45,15 @@
{
defsze.W = firstChild()->preferredWidth();
- vector<NClabel>::iterator listIt = tabList.begin();
+ YItemIterator listIt = itemsBegin();
+
unsigned int tabBarWidth = 0;
+ NClabel tabLabel;
- while ( listIt != tabList.end() )
+ while ( listIt != itemsEnd() )
{
- tabBarWidth += (*listIt).width() + 1;
+ tabLabel = NClabel( (*listIt)->label() );
+ tabBarWidth += tabLabel.width() + 1;
++listIt;
}
++tabBarWidth;
@@ -59,6 +63,9 @@
defsze.W += framedim.Sze.W;
+ if ( defsze.W > NCurses::cols() )
+ defsze.W = NCurses::cols();
+
return defsze.W;
}
@@ -96,7 +103,8 @@
switch ( key )
{
case KEY_LEFT:
- if ( currentIndex > 0 && currentIndex <= tabList.size() -1 )
+ if ( currentIndex > 0 &&
+ currentIndex <= (unsigned)itemsCount() -1 )
{
currentIndex--;
wRedraw();
@@ -106,7 +114,8 @@
break;
case KEY_RIGHT:
- if ( currentIndex < tabList.size()-1 && currentIndex >= 0 )
+ if ( currentIndex < (unsigned)itemsCount()-1 &&
+ currentIndex >= 0 )
{
currentIndex++;
wRedraw();
@@ -115,6 +124,8 @@
}
break;
+ case KEY_HOTKEY:
+ yuiMilestone() << "HOT key" << endl;
case KEY_RETURN:
ret = createMenuEvent( currentIndex );
break;
@@ -143,9 +154,8 @@
{
YDumbTab::addItem( item );
- NClabel tabLabel = NClabel( item->label() );
+ NClabel tabLabel = NCstring( item->label() );
yuiDebug() << "Add item: " << item->label() << endl;
- tabList.push_back( tabLabel );
if ( item->selected() )
currentIndex = item->index();
@@ -164,28 +174,43 @@
wRedraw();
}
+void NCDumbTab::shortcutChanged()
+{
+ // Any of the items might have its keyboard shortcut changed, but we don't
+ // know which one. So let's simply set all tab labels again.
+
+ wRedraw();
+}
+
void NCDumbTab::wRedraw()
{
if ( !win )
return;
-
+
const NCstyle::StWidget & style( widgetStyle(true) );
win->bkgd( style.plain );
win->box();
- vector<NClabel>::iterator listIt = tabList.begin();
+ YItemIterator listIt = itemsBegin();
+
int winWidth = win->width() - 2;
- int labelPos = 1;
+ unsigned int labelPos = 1;
unsigned int i = 0;
bool nonActive = false;
+ NClabel tablabel;
- while ( listIt != tabList.end() )
+ while ( listIt != itemsEnd() )
{
+ tablabel = NCstring( (*listIt)->label() );
+ tablabel.stripHotkey();
+ hotlabel = &tablabel;
+
nonActive = (i == currentIndex)?false:true;
+
if ( GetState() == NC::WSactive )
{
- (*listIt).drawAt( *win,
+ tablabel.drawAt( *win,
NCstyle::StWidget( widgetStyle( nonActive) ),
wpos( 0, labelPos ),
wsze( 1, winWidth ),
@@ -195,7 +220,7 @@
{
if ( !nonActive )
{
- (*listIt).drawAt( *win,
+ tablabel.drawAt( *win,
widgetStyle( ).data,
widgetStyle( ).data,
wpos( 0, labelPos ),
@@ -204,7 +229,7 @@
}
else
{
- (*listIt).drawAt( *win,
+ tablabel.drawAt( *win,
NCstyle::StWidget( frameStyle() ),
wpos( 0, labelPos ),
wsze( 1, winWidth ),
@@ -212,14 +237,14 @@
}
}
- labelPos += (*listIt).width() + 2;
+ labelPos += tablabel.width() + 2;
++listIt;
++i;
- if ( listIt != tabList.end() )
+ if ( listIt != itemsEnd() )
{
- winWidth -= (*listIt).width() -1;
+ winWidth -= tablabel.width() -1;
}
};
@@ -231,7 +256,28 @@
redrawChilds( firstChild() );
}
- }
+}
+
+bool NCDumbTab::HasHotkey( int key )
+{
+ bool ret = false;
+
+ YItemIterator listIt = itemsBegin();
+ NClabel tablabel;
+
+ while ( listIt != itemsEnd() )
+ {
+ tablabel = NCstring( (*listIt)->label() );
+ tablabel.stripHotkey();
+ if ( tablabel.hasHotkey() )
+ ret = true;
+ ++listIt;
+ }
+
+ yuiMilestone() << "Has hot key: " << key << " " << (ret?"yes":"no") <<
endl;
+
+ return ret;
+}
void NCDumbTab::redrawChilds( YWidget *widget )
{
Modified: trunk/ncurses/src/NCDumbTab.h
URL:
http://svn.opensuse.org/viewcvs/yast/trunk/ncurses/src/NCDumbTab.h?rev=48949&r1=48948&r2=48949&view=diff
==============================================================================
--- trunk/ncurses/src/NCDumbTab.h (original)
+++ trunk/ncurses/src/NCDumbTab.h Thu Jul 10 12:32:23 2008
@@ -34,9 +34,8 @@
NCDumbTab & operator=( const NCDumbTab & );
NCDumbTab( const NCDumbTab & );
- vector <NClabel> tabList;
unsigned int currentIndex;
-
+
protected:
virtual const char * location() const { return "NCDumbTab"; }
@@ -61,6 +60,10 @@
virtual void setEnabled( bool do_bv );
+ virtual void shortcutChanged();
+
+ virtual bool HasHotkey( int key );
+
virtual bool setKeyboardFocus()
{
if ( !grabFocus() )
@@ -70,6 +73,7 @@
}
NCursesEvent createMenuEvent( unsigned int index);
+
};
Modified: trunk/ncurses/src/NCWidget.cc
URL:
http://svn.opensuse.org/viewcvs/yast/trunk/ncurses/src/NCWidget.cc?rev=48949&r1=48948&r2=48949&view=diff
==============================================================================
--- trunk/ncurses/src/NCWidget.cc (original)
+++ trunk/ncurses/src/NCWidget.cc Thu Jul 10 12:32:23 2008
@@ -495,7 +495,7 @@
-bool NCWidget::HasHotkey( int key ) const
+bool NCWidget::HasHotkey( int key )
{
if ( key < 0 || UCHAR_MAX < key )
return false;
Modified: trunk/ncurses/src/NCWidget.h
URL:
http://svn.opensuse.org/viewcvs/yast/trunk/ncurses/src/NCWidget.h?rev=48949&r1=48948&r2=48949&view=diff
==============================================================================
--- trunk/ncurses/src/NCWidget.h (original)
+++ trunk/ncurses/src/NCWidget.h Thu Jul 10 12:32:23 2008
@@ -166,7 +166,7 @@
**/
virtual void setEnabled( bool do_bv ) = 0;
- virtual bool HasHotkey( int key ) const;
+ virtual bool HasHotkey( int key );
virtual bool HasFunctionHotkey( int key ) const;
virtual NCursesEvent wHandleHotkey( wint_t key );
--
To unsubscribe, e-mail: yast-commit+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: yast-commit+help@xxxxxxxxxxxx
| < Previous | Next > |