libyui-ncurses
2.44.1
|
00001 /* 00002 Copyright (C) 2000-2012 Novell, Inc 00003 This library is free software; you can redistribute it and/or modify 00004 it under the terms of the GNU Lesser General Public License as 00005 published by the Free Software Foundation; either version 2.1 of the 00006 License, or (at your option) version 3.0 of the License. This library 00007 is distributed in the hope that it will be useful, but WITHOUT ANY 00008 WARRANTY; without even the implied warranty of MERCHANTABILITY or 00009 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 00010 License for more details. You should have received a copy of the GNU 00011 Lesser General Public License along with this library; if not, write 00012 to the Free Software Foundation, Inc., 51 Franklin Street, Fifth 00013 Floor, Boston, MA 02110-1301 USA 00014 */ 00015 00016 00017 /*-/ 00018 00019 File: NCPopupTable.cc 00020 00021 Author: Michael Andres <ma@suse.de> 00022 00023 /-*/ 00024 00025 #define YUILogComponent "ncurses" 00026 #include <yui/YUILog.h> 00027 #include "NCPopupTable.h" 00028 00029 #include "NCTable.h" 00030 #include <yui/YMenuButton.h> 00031 00032 00033 NCPopupTable::NCPopupTable( const wpos at ) 00034 : NCPopup( at, false ) 00035 , sellist( 0 ) 00036 { 00037 } 00038 00039 00040 NCPopupTable::~NCPopupTable() 00041 { 00042 } 00043 00044 00045 void NCPopupTable::createList( std::vector<std::string> & row ) 00046 { 00047 if ( sellist ) 00048 return ; 00049 00050 YTableHeader * tableHeader = new YTableHeader(); 00051 00052 // sellist = new NCTable( this, row.size() ); 00053 sellist = new NCTable( this, tableHeader ); 00054 00055 YUI_CHECK_NEW( sellist ); 00056 00057 sellist->setBigList( true ); 00058 sellist->SetSepChar( ' ' ); 00059 sellist->SetSepWidth( 0 ); 00060 sellist->SetHotCol( 0 ); 00061 sellist->setNotify( true ); 00062 } 00063 00064 00065 void NCPopupTable::addItem( YItem *yitem ) 00066 { 00067 if ( !yitem ) 00068 return; 00069 00070 sellist->addItem( yitem ); 00071 00072 // Calling sellist->addItem() resets the hotcol because 00073 // NCTableStyle's constructor sets hotcol to -1. 00074 // Set hot coll again: 00075 sellist->SetHotCol( 0 ); 00076 } 00077 00078 00079 void NCPopupTable::setCurrentItem( int index ) 00080 { 00081 if ( !sellist ) 00082 return; 00083 00084 sellist->setCurrentItem( index ); 00085 } 00086 00087 00088 int NCPopupTable::getCurrentItem() const 00089 { 00090 if ( !sellist ) 00091 return -1; 00092 00093 return sellist->getCurrentItem(); 00094 } 00095 00096 00097 YItem * NCPopupTable::getCurrentItemPointer( ) const 00098 { 00099 if ( !sellist ) 00100 return 0; 00101 00102 return sellist->getCurrentItemPointer( ); 00103 } 00104 00105 00106 NCursesEvent NCPopupTable::wHandleHotkey( wint_t key ) 00107 { 00108 if ( key >= 0 && sellist->setItemByKey( key ) ) 00109 return wHandleInput( KEY_RETURN ); 00110 00111 return NCursesEvent::none; 00112 } 00113 00114 00115 bool NCPopupTable::postAgain() 00116 { 00117 if ( sellist ) 00118 { 00119 postevent.detail = ( postevent == NCursesEvent::button ) ? 00120 sellist->getCurrentItem() : NCursesEvent::NODETAIL; 00121 } 00122 00123 return false; 00124 } 00125 00126 00127 void NCPopupTable::stripHotkeys() 00128 { 00129 if ( sellist ) 00130 { 00131 sellist->stripHotkeys(); 00132 } 00133 }