|
From: <arn...@us...> - 2008-03-26 14:25:14
|
Revision: 1066
http://dcplusplus.svn.sourceforge.net/dcplusplus/?rev=1066&view=rev
Author: arnetheduck
Date: 2008-03-26 07:25:11 -0700 (Wed, 26 Mar 2008)
Log Message:
-----------
Generalize aspectselection
Modified Paths:
--------------
dcplusplus/trunk/smartwin/include/smartwin/aspects/AspectSelection.h
dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetComboBox.h
dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetCoolbar.h
dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetListView.h
dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetTabSheet.h
dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetTreeView.h
dcplusplus/trunk/smartwin/source/widgets/WidgetListView.cpp
dcplusplus/trunk/smartwin/source/widgets/WidgetTabView.cpp
dcplusplus/trunk/smartwin/source/widgets/WidgetTreeView.cpp
dcplusplus/trunk/win32/ADLSProperties.cpp
dcplusplus/trunk/win32/ADLSearchFrame.cpp
dcplusplus/trunk/win32/AppearancePage.cpp
dcplusplus/trunk/win32/DirectoryListingFrame.cpp
dcplusplus/trunk/win32/FavHubsFrame.cpp
dcplusplus/trunk/win32/FavoriteDirsPage.cpp
dcplusplus/trunk/win32/FinishedFrameBase.h
dcplusplus/trunk/win32/GeneralPage.cpp
dcplusplus/trunk/win32/HubFrame.cpp
dcplusplus/trunk/win32/HubListsDlg.cpp
dcplusplus/trunk/win32/LogPage.cpp
dcplusplus/trunk/win32/PublicHubsFrame.cpp
dcplusplus/trunk/win32/QueueFrame.cpp
dcplusplus/trunk/win32/SearchFrame.cpp
dcplusplus/trunk/win32/SpyFrame.cpp
dcplusplus/trunk/win32/TransferView.cpp
dcplusplus/trunk/win32/TypedListView.h
dcplusplus/trunk/win32/TypedTreeView.h
dcplusplus/trunk/win32/UCPage.cpp
dcplusplus/trunk/win32/UploadPage.cpp
dcplusplus/trunk/win32/UsersFrame.cpp
dcplusplus/trunk/win32/WaitingUsersFrame.cpp
Property Changed:
----------------
dcplusplus/trunk/
Property changes on: dcplusplus/trunk
___________________________________________________________________
Name: bzr:revision-info
- timestamp: 2008-03-25 22:17:47.410000086 +0100
committer: Jacek Sieka <arn...@gm...>
properties:
branch-nick: dcplusplus
+ timestamp: 2008-03-26 09:41:10.022000074 +0100
committer: Jacek Sieka <arn...@gm...>
properties:
branch-nick: dcplusplus
Name: bzr:revision-id:v3-trunk1
- 1027 arn...@gm...-20080323183926-schknwnkgeo7ivdn
1028 zouzou123gen-20080323220411-r8usuc3qxwuh7zsn
1029 zouzou123gen-20080323221249-0su72zaj13e706mk
1030 arn...@gm...-20080324140623-muba1dl46m000o8c
1031 zouzou123gen-20080324141933-qbgr93ugpe0297m6
1032 arn...@gm...-20080324153706-siidja05n84i00b1
1033 arn...@gm...-20080324153823-lhn3awurnu77riln
1034 arn...@gm...-20080324165650-zapppziji67yf5a2
1035 zouzou123gen-20080324175936-4mqc2kh0lo5wtdu2
1036 zouzou123gen-20080325004602-6wdsoym95mjuhwd3
1037 arn...@gm...-20080325100659-8fqy6q65itmghlep
1038 zouzou123gen-20080325175216-s297sdiucukfvijh
1039 arn...@gm...-20080325210137-3dfqyoi8ykosy087
1040 arn...@gm...-20080325211747-nwwy1eb33r071sca
+ 1027 arn...@gm...-20080323183926-schknwnkgeo7ivdn
1028 zouzou123gen-20080323220411-r8usuc3qxwuh7zsn
1029 zouzou123gen-20080323221249-0su72zaj13e706mk
1030 arn...@gm...-20080324140623-muba1dl46m000o8c
1031 zouzou123gen-20080324141933-qbgr93ugpe0297m6
1032 arn...@gm...-20080324153706-siidja05n84i00b1
1033 arn...@gm...-20080324153823-lhn3awurnu77riln
1034 arn...@gm...-20080324165650-zapppziji67yf5a2
1035 zouzou123gen-20080324175936-4mqc2kh0lo5wtdu2
1036 zouzou123gen-20080325004602-6wdsoym95mjuhwd3
1037 arn...@gm...-20080325100659-8fqy6q65itmghlep
1038 zouzou123gen-20080325175216-s297sdiucukfvijh
1039 arn...@gm...-20080325210137-3dfqyoi8ykosy087
1040 arn...@gm...-20080325211747-nwwy1eb33r071sca
1041 arn...@gm...-20080326084110-qbselrjckku275xi
Modified: dcplusplus/trunk/smartwin/include/smartwin/aspects/AspectSelection.h
===================================================================
--- dcplusplus/trunk/smartwin/include/smartwin/aspects/AspectSelection.h 2008-03-26 14:19:33 UTC (rev 1065)
+++ dcplusplus/trunk/smartwin/include/smartwin/aspects/AspectSelection.h 2008-03-26 14:25:11 UTC (rev 1066)
@@ -28,6 +28,8 @@
#ifndef AspectSelection_h
#define AspectSelection_h
+#include "../Dispatchers.h"
+
namespace SmartWin
{
// begin namespace SmartWin
@@ -38,26 +40,12 @@
* E.g. the WidgetComboBox have a "selected" Aspect therefore it realizes the
* AspectSelection through inheritance.
*/
-template< class WidgetType >
-class AspectSelection
-{
+template< class WidgetType, typename IndexType >
+class AspectSelection {
WidgetType& W() { return *static_cast<WidgetType*>(this); }
+ const WidgetType& W() const { return *static_cast<const WidgetType*>(this); }
- struct Dispatcher
- {
- typedef std::tr1::function<void ()> F;
-
- Dispatcher(const F& f_) : f(f_) { }
-
- bool operator()(const MSG& msg, LRESULT& ret) {
- if ( !WidgetType::isValidSelectionChanged( msg.lParam ) )
- return false;
- f();
- return true;
- }
-
- F f;
- };
+ typedef Dispatchers::VoidVoid<> Dispatcher;
public:
/// \ingroup EventHandlersAspectSelection
/// Setting the event handler for the "selection changed" event
@@ -74,7 +62,7 @@
* selected item. You must add the items before you set the selected
* index.
*/
- virtual void setSelectedIndex( int idx ) = 0;
+ void setSelected( IndexType item );
/// Return the selected index of the Widget
/** The return value is the selected items index of the Widget, if no item is
@@ -83,13 +71,36 @@
* Some Widgets have the possibillity of selecting multiple items, if so you
* should not use this function but rather the multiple selection value getter.
*/
- virtual int getSelectedIndex() const = 0;
+ IndexType getSelected() const;
+
+ size_t countSelected() const;
+
+ bool hasSelected() const;
protected:
- virtual ~AspectSelection()
- {}
+ virtual ~AspectSelection() { }
};
+template< class WidgetType, typename IndexType >
+IndexType AspectSelection<WidgetType, IndexType>::getSelected() const {
+ return W().getSelectedImpl();
+}
+
+template< class WidgetType, typename IndexType >
+void AspectSelection<WidgetType, IndexType>::setSelected(IndexType item) {
+ W().setSelectedImpl(item);
+}
+
+template< class WidgetType, typename IndexType >
+size_t AspectSelection<WidgetType, IndexType>::countSelected() const {
+ return W().countSelectedImpl();
+}
+
+template< class WidgetType, typename IndexType >
+bool AspectSelection<WidgetType, IndexType>::hasSelected() const {
+ return countSelected() > 0;
+}
+
// end namespace SmartWin
}
Modified: dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetComboBox.h
===================================================================
--- dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetComboBox.h 2008-03-26 14:19:33 UTC (rev 1065)
+++ dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetComboBox.h 2008-03-26 14:25:11 UTC (rev 1066)
@@ -31,6 +31,7 @@
#include "../Widget.h"
#include "../aspects/AspectColor.h"
#include "../aspects/AspectClickable.h"
+#include "../aspects/AspectCollection.h"
#include "../aspects/AspectControl.h"
#include "../aspects/AspectDblClickable.h"
#include "../aspects/AspectFocus.h"
@@ -58,6 +59,7 @@
class WidgetComboBox :
// Aspects
public AspectClickable< WidgetComboBox >,
+ public AspectCollection<WidgetComboBox, int>,
public AspectColor< WidgetComboBox >,
public AspectColorCtlImpl<WidgetComboBox>,
public AspectControl<WidgetComboBox>,
@@ -65,12 +67,13 @@
public AspectFocus< WidgetComboBox >,
public AspectFont< WidgetComboBox >,
public AspectPainting< WidgetComboBox >,
- public AspectSelection< WidgetComboBox >,
+ public AspectSelection< WidgetComboBox, int >,
public AspectText< WidgetComboBox >
{
friend class WidgetCreator< WidgetComboBox >;
+ friend class AspectCollection<WidgetComboBox, int>;
friend class AspectColor<WidgetComboBox>;
-
+ friend class AspectSelection<WidgetComboBox, int>;
public:
/// Seed class
@@ -100,25 +103,11 @@
// Aspect expectation implementation
Message getDblClickMessage();
- // Commented in AspectSelection
- int getSelectedIndex() const;
-
- // Commented in AspectSelection
- void setSelectedIndex( int idx );
-
/// Return the selected value of the ComboBox
/** If no item is actually selected the return value is "".
*/
SmartUtil::tstring getSelectedValue();
- /// Removes all items from the ComboBox
- /** After this call there will be zero items in the ComboBox.
- */
- void removeAllItems();
-
- /// Remove an item from the ComboBox
- void removeItem( int index );
-
/// Appends a value to the ComboBox.
/** The return value is the index of the new item appended.
*/
@@ -129,11 +118,6 @@
*/
int insertValue(int pos, const SmartUtil::tstring & val );
- /// Returns the number of items present in the ComboBox.
- /** Returns the number of items present in the ComboBox.
- */
- int getCount();
-
/// Returns the string at the zero - based index of the items present in the
/// ComboBox.
/** Returns the string of the ComboBox at the given index. <br>
@@ -148,10 +132,6 @@
*/
void create( const Seed & cs = Seed() );
- static bool isValidSelectionChanged( LPARAM lPar )
- { return true;
- }
-
protected:
/// Constructor Taking pointer to parent
explicit WidgetComboBox( Widget * parent );
@@ -160,6 +140,18 @@
// WidgetFactory class which is friend
virtual ~WidgetComboBox()
{}
+
+private:
+
+ // AspectSelection
+ int getSelectedImpl() const;
+ void setSelectedImpl( int idx );
+
+ // AspectCollection
+ void eraseImpl( int row );
+ void clearImpl();
+ size_t sizeImpl() const;
+
};
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -181,14 +173,11 @@
return Message( WM_COMMAND, MAKEWPARAM(this->getControlId(), CBN_DBLCLK) );
}
-inline int WidgetComboBox::getSelectedIndex() const
-{
- int retVal = ComboBox_GetCurSel( handle() );
- return retVal;
+inline int WidgetComboBox::getSelectedImpl() const {
+ return ComboBox_GetCurSel( handle() );
}
-inline void WidgetComboBox::setSelectedIndex( int idx )
-{
+inline void WidgetComboBox::setSelectedImpl( int idx ) {
ComboBox_SetCurSel( handle(), idx );
}
@@ -202,12 +191,12 @@
return retVal;
}
-inline void WidgetComboBox::removeAllItems()
+inline void WidgetComboBox::clearImpl()
{
ComboBox_ResetContent( handle() );
}
-inline void WidgetComboBox::removeItem( int index )
+inline void WidgetComboBox::eraseImpl( int index )
{
ComboBox_DeleteString( handle(), index );
}
@@ -234,9 +223,8 @@
return newIdx;
}
-inline int WidgetComboBox::getCount()
-{
- return ComboBox_GetCount( handle() ); // Number of items present.
+inline size_t WidgetComboBox::sizeImpl() const {
+ return static_cast<size_t>(ComboBox_GetCount( handle() )); // Number of items present.
}
inline SmartUtil::tstring WidgetComboBox::getValue( int index )
Modified: dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetCoolbar.h
===================================================================
--- dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetCoolbar.h 2008-03-26 14:19:33 UTC (rev 1065)
+++ dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetCoolbar.h 2008-03-26 14:25:11 UTC (rev 1066)
@@ -159,6 +159,7 @@
parent->addChild( retVal );
return retVal;
#endif
+ return NULL;
}
/// Creates a Widget using its CreationalInfo
Modified: dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetListView.h
===================================================================
--- dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetListView.h 2008-03-26 14:19:33 UTC (rev 1065)
+++ dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetListView.h 2008-03-26 14:25:11 UTC (rev 1066)
@@ -78,7 +78,7 @@
public AspectFocus< WidgetListView >,
public AspectFont< WidgetListView >,
public AspectScrollable< WidgetListView >,
- public AspectSelection< WidgetListView >
+ public AspectSelection< WidgetListView, int >
{
struct HeaderDispatcher {
typedef std::tr1::function<void (int)> F;
@@ -99,6 +99,7 @@
friend class AspectCollection<WidgetListView, int>;
friend class AspectColor<WidgetListView>;
friend class AspectData<WidgetListView, int>;
+ friend class AspectSelection<WidgetListView, int>;
public:
typedef std::tr1::function<int (LPARAM a, LPARAM b)> SortFunction;
@@ -213,12 +214,6 @@
*/
void setText( unsigned row, unsigned column, const SmartUtil::tstring & newVal );
- /// Returns true if grid has got a "current selected item"
- /** If the List View has got a "currently selected" row, this function will
- * return true, if no row is selected it will return false.
- */
- bool hasSelection();
-
/// Returns a vector containing all the selected rows of the grid.
/** The return vector contains unsigned integer values, each value defines a row
* in the grid that is selected. <br>
@@ -226,24 +221,8 @@
* getSelectedRow function. <br>
* If grid does NOT have any selected items the return vector is empty.
*/
- std::vector< unsigned > getSelected();
+ std::vector< unsigned > getSelection() const;
- /// Returns an unsigned integer which is the selected row of the grid.
- /** The return value defines the row in the grid that is selected. <br>
- * If the grid is in "multiple selection mode" you should rather use the
- * getSelected function. <br>
- * If grid does NOT have a selected item the return value is - 1. <br>
- * Note! <br>
- * This returns the ROW of the selected item and NOT the lparam given when
- * inserted items meaning if you sort the grid or something this function will
- * return another number for the same item if its position has moved due to the
- * sort etc.
- */
- int getSelectedIndex() const;
-
- // Commented in AspectSelection
- void setSelectedIndex( int idx );
-
/// Clears the selection of the grid.
void clearSelection();
@@ -454,8 +433,6 @@
*/
void redraw( int firstRow = 0, int lastRow = -1 );
- int getSelectedCount();
-
void setListViewStyle(int style);
int insert(int mask, int i, LPCTSTR text, UINT state, UINT stateMask, int image, LPARAM lparam);
@@ -480,8 +457,6 @@
// Constructor Taking pointer to parent
explicit WidgetListView( SmartWin::Widget * parent );
- static bool isValidSelectionChanged( LPARAM lPar );
-
protected:
/// Adds or Removes extended list view styles from the list view
void addRemoveListViewExtendedStyle( DWORD addStyle, bool add );
@@ -548,6 +523,11 @@
// AspectColor
void setColorImpl(COLORREF text, COLORREF background);
+ // AspectSelection
+ int getSelectedImpl() const;
+ void setSelectedImpl( int idx );
+ size_t countSelectedImpl() const;
+
};
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -560,21 +540,6 @@
return retVal;
}
-inline bool WidgetListView::isValidSelectionChanged( LPARAM lPar )
-{
- //TODO: Make support for CHOOSING how onSelectedChanged is supposed to behave,
- //TODO: make non static function and pure abstract in base class and override
- //TODO: and add enum param to event handler setter which MUST have default
- //TODO: value to be backwards compatible
- NMLISTVIEW * tmp = reinterpret_cast< NMLISTVIEW * >( lPar );
- if ( ( tmp->uChanged & LVIF_STATE ) == LVIF_STATE &&
- ( tmp->uNewState & LVIS_SELECTED ) == LVIS_SELECTED &&
- ( tmp->uOldState & LVIS_SELECTED ) != LVIS_SELECTED &&
- ( tmp->uOldState & LVIS_FOCUSED ) != LVIS_FOCUSED )
- return true;
- return false;
-}
-
inline const Message & WidgetListView::getClickMessage()
{
static const Message retVal( WM_NOTIFY, NM_CLICK );
@@ -681,12 +646,12 @@
}
}
-inline bool WidgetListView::hasSelection() {
- return ListView_GetSelectedCount( this->handle() ) > 0;
+inline int WidgetListView::getSelectedImpl() const {
+ return getNext(-1, LVNI_SELECTED);
}
-inline int WidgetListView::getSelectedIndex() const {
- return getNext(-1, LVNI_SELECTED);
+inline size_t WidgetListView::countSelectedImpl() const {
+ return static_cast<size_t>(ListView_GetSelectedCount( this->handle() ));
}
inline void WidgetListView::setText( unsigned row, unsigned column, const SmartUtil::tstring & newVal ) {
@@ -825,10 +790,6 @@
return ::SendMessage(this->handle(), LVM_SETCOLUMNORDERARRAY, static_cast<WPARAM>(columns.size()), reinterpret_cast<LPARAM>(&columns[0])) > 0;
}
-inline int WidgetListView::getSelectedCount() {
- return ListView_GetSelectedCount(this->handle());
-}
-
inline void WidgetListView::setListViewStyle(int style) {
ListView_SetExtendedListViewStyle(this->handle(), style);
}
Modified: dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetTabSheet.h
===================================================================
--- dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetTabSheet.h 2008-03-26 14:19:33 UTC (rev 1065)
+++ dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetTabSheet.h 2008-03-26 14:25:11 UTC (rev 1066)
@@ -31,6 +31,7 @@
#include "../Widget.h"
#include "../resources/ImageList.h"
#include "../Rectangle.h"
+#include "../aspects/AspectCollection.h"
#include "../aspects/AspectControl.h"
#include "../aspects/AspectFocus.h"
#include "../aspects/AspectFont.h"
@@ -63,13 +64,17 @@
*/
class WidgetTabSheet :
// Aspects
+ public AspectCollection<WidgetTabSheet, int>,
public AspectControl<WidgetTabSheet>,
public AspectFocus< WidgetTabSheet >,
public AspectFont< WidgetTabSheet >,
public AspectPainting< WidgetTabSheet >,
- public AspectSelection< WidgetTabSheet >,
+ public AspectSelection< WidgetTabSheet, int >,
public AspectText< WidgetTabSheet >
{
+ friend class AspectCollection<WidgetTabSheet, int>;
+ friend class AspectSelection<WidgetTabSheet, int>;
+
struct ChangingDispatcher
{
typedef std::tr1::function<bool (unsigned)> F;
@@ -125,9 +130,6 @@
// AspectSelection expectation implementation
static const Message & getSelectionChangedMessage();
- // Commented in AspectSelection
- int getSelectedIndex() const;
-
SmartUtil::tstring getText(unsigned idx) const;
void setText(unsigned idx, const SmartUtil::tstring& text);
@@ -151,9 +153,6 @@
);
}
- // Commented in AspectSelection
- void setSelectedIndex( int idx );
-
/// Appends a "page" to the Tab Sheet
/** The return value is the index of the new item appended. The input index is
* where you wish to put the new page
@@ -228,22 +227,10 @@
*/
void setFlatSeparators( bool value = true );
- static bool isValidSelectionChanged( LPARAM lPar )
- { return true;
- }
-
void setImageList(const ImageListPtr& imageList);
const ImageListPtr& getImageList() const;
- size_t size() {
- return static_cast<size_t>(TabCtrl_GetItemCount(this->handle()));
- }
-
- void erase(size_t i) {
- TabCtrl_DeleteItem(this->handle(), i);
- }
-
int hitTest(const ScreenCoordinate& pt);
/// Get the area not used by the tabs
@@ -251,7 +238,7 @@
* the tabs can be calculated accurately. It returns coordinates respect to the
* TabControl, this is, you have to adjust for the position of the control itself.
*/
- SmartWin::Rectangle getUsableArea(bool cutBorders = false) const;
+ Rectangle getUsableArea(bool cutBorders = false) const;
protected:
// Constructor Taking pointer to parent
explicit WidgetTabSheet( Widget * parent );
@@ -264,6 +251,16 @@
private:
// Keep a copy so it won't get deallocated...
ImageListPtr imageList;
+
+ // AspectCollection
+ void eraseImpl( int row );
+ void clearImpl();
+ size_t sizeImpl() const;
+
+ // AspectSelection
+ int getSelectedImpl() const;
+ void setSelectedImpl( int idx );
+
};
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -276,10 +273,8 @@
return retVal;
}
-inline int WidgetTabSheet::getSelectedIndex() const
-{
- int retVal = TabCtrl_GetCurSel( this->handle() );
- return retVal;
+inline int WidgetTabSheet::getSelectedImpl() const {
+ return TabCtrl_GetCurSel( this->handle() );
}
inline int WidgetTabSheet::getImage(unsigned idx) const
@@ -312,8 +307,7 @@
return item.lParam;
}
-inline void WidgetTabSheet::setSelectedIndex( int idx )
-{
+inline void WidgetTabSheet::setSelectedImpl( int idx ) {
TabCtrl_SetCurSel( this->handle(), idx );
}
@@ -397,7 +391,18 @@
return TabCtrl_HitTest(handle(), &tci);
}
+inline void WidgetTabSheet::eraseImpl(int i) {
+ TabCtrl_DeleteItem(this->handle(), i);
+}
+inline void WidgetTabSheet::clearImpl() {
+ TabCtrl_DeleteAllItems(handle());
+}
+
+inline size_t WidgetTabSheet::sizeImpl() const {
+ return static_cast<size_t>(TabCtrl_GetItemCount(this->handle()));
+}
+
// end namespace SmartWin
}
Modified: dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetTreeView.h
===================================================================
--- dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetTreeView.h 2008-03-26 14:19:33 UTC (rev 1065)
+++ dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetTreeView.h 2008-03-26 14:25:11 UTC (rev 1066)
@@ -70,7 +70,7 @@
public AspectDblClickable< WidgetTreeView >,
public AspectFocus< WidgetTreeView >,
public AspectFont< WidgetTreeView >,
- public AspectSelection< WidgetTreeView >
+ public AspectSelection< WidgetTreeView, HTREEITEM >
{
protected:
struct Dispatcher
@@ -97,6 +97,7 @@
friend class AspectCollection<WidgetTreeView, HTREEITEM>;
friend class AspectColor<WidgetTreeView>;
friend class AspectData<WidgetTreeView, HTREEITEM>;
+ friend class AspectSelection<WidgetTreeView, HTREEITEM>;
public:
/// Seed class
@@ -140,16 +141,12 @@
HTREEITEM getParent(HTREEITEM node);
- HTREEITEM getSelection();
-
HTREEITEM getRoot();
ScreenCoordinate getContextMenuPos();
void expand(HTREEITEM node);
- void select(HTREEITEM item);
-
void select(const ScreenCoordinate& pt);
HTREEITEM hitTest(const ScreenCoordinate& pt);
@@ -227,24 +224,6 @@
*/
SmartUtil::tstring getText( HTREEITEM node );
- /// Returns the param of the current selected node
- /** The return value is a unique application defined unsigned number ( optionally
- * ) given when inserting nodes. <br>
- * Note! <br>
- * It is pointless calling this function if no param was given when inserting
- * the nodes. <br>
- * 0 is special case indicating failure
- */
- virtual int getSelectedIndex() const;
-
- /// Sets the currently selected node
- /** The parameter given is the param given when inserting the nodes <br>
- * Note! <br>
- * It is pointless calling this function if no param was given when inserting
- * the nodes.
- */
- virtual void setSelectedIndex( int idx );
-
/// \ingroup EventHandlersWidgetTreeView
/// Sets the event handler for what function to be called when a label is edited.
/** Event handler signature is must be "bool foo( WidgetTreeView *,
@@ -279,10 +258,6 @@
*/
void create( const Seed & cs = Seed() );
- static bool isValidSelectionChanged( LPARAM lPar )
- { return true;
- }
-
protected:
// Constructor Taking pointer to parent
explicit WidgetTreeView( Widget * parent );
@@ -308,6 +283,11 @@
// AspectColor
void setColorImpl(COLORREF text, COLORREF background);
+ // AspectSelection
+ HTREEITEM getSelectedImpl() const;
+ void setSelectedImpl( HTREEITEM item );
+ size_t countSelectedImpl() const;
+
};
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -339,10 +319,6 @@
TreeView_SetBkColor(this->handle(), background);
}
-inline void WidgetTreeView::select(HTREEITEM item) {
- TreeView_SelectItem(this->handle(), item);
-}
-
inline Rectangle WidgetTreeView::getItemRect(HTREEITEM item) {
RECT rc;
TreeView_GetItemRect(this->handle(), item, &rc, TRUE);
@@ -355,10 +331,6 @@
return TreeView_HitTest(this->handle(), &tvhti);
}
-inline HTREEITEM WidgetTreeView::getSelection() {
- return TreeView_GetSelection(this->handle());
-}
-
inline void WidgetTreeView::expand(HTREEITEM node) {
TreeView_Expand(this->handle(), node, TVE_EXPAND);
}
@@ -422,6 +394,19 @@
return retVal;
}
+inline HTREEITEM WidgetTreeView::getSelectedImpl() const {
+ return TreeView_GetSelection( this->handle() );
+}
+
+inline void WidgetTreeView::setSelectedImpl(HTREEITEM item) {
+ TreeView_SelectItem( this->handle(), item );
+ TreeView_EnsureVisible(this->handle(), item);
+}
+
+inline size_t WidgetTreeView::countSelectedImpl() const {
+ return getSelected() == NULL ? 0 : 1;
+}
+
inline WidgetTreeView::WidgetTreeView( Widget * parent )
: ControlType( parent )
{
Modified: dcplusplus/trunk/smartwin/source/widgets/WidgetListView.cpp
===================================================================
--- dcplusplus/trunk/smartwin/source/widgets/WidgetListView.cpp 2008-03-26 14:19:33 UTC (rev 1065)
+++ dcplusplus/trunk/smartwin/source/widgets/WidgetListView.cpp 2008-03-26 14:25:11 UTC (rev 1066)
@@ -105,41 +105,20 @@
}
}
-void WidgetListView::setSelectedIndex( int idx )
-{
- // TODO: Check if this is working right...
- LVITEM it = { LVIF_STATE };
- it.iItem = idx;
- it.state = LVIS_SELECTED | LVIS_FOCUSED;
- it.stateMask = LVIS_SELECTED | LVIS_FOCUSED;
- if ( ListView_SetItem( this->handle(), & it ) != TRUE )
- {
- xCeption err( _T( "Something went wrong while trying to set the selected property of the ListView" ) );
- throw err;
- }
- if ( ListView_EnsureVisible( this->handle(), idx, FALSE ) != TRUE )
- {
- xCeption err( _T( "Something went wrong while trying to scroll selected item into view in setSelectedIndex" ) );
- throw err;
- }
+void WidgetListView::setSelectedImpl(int item) {
+ clearSelection();
+ ListView_SetItemState(handle(), item, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED);
+ ListView_EnsureVisible(handle(), item, FALSE);
}
-void WidgetListView::clearSelection()
-{
- LVITEM it = { LVIF_STATE };
- it.stateMask = LVIS_SELECTED;
- it.state = 0;
- std::vector< unsigned > selectedItems = getSelected();
-
- for ( std::vector< unsigned >::iterator iter = selectedItems.begin(); iter != selectedItems.end(); ++iter )
- {
- it.iItem = * iter;
- if ( ListView_SetItem( this->handle(), & it ) != TRUE )
- {
- xCeption err( _T( "Something went wrong while trying to unset the selected property of the ListView" ) );
- throw err;
- }
+void WidgetListView::clearSelection() {
+ int i = -1;
+ while((i = getNext(i, LVNI_SELECTED)) != -1) {
+ ListView_SetItemState(handle(), i, 0, LVIS_SELECTED | LVIS_FOCUSED);
}
+ while((i = getNext(i, LVNI_FOCUSED)) != -1) {
+ ListView_SetItemState(handle(), i, 0, LVIS_FOCUSED);
+ }
}
void WidgetListView::createColumns( const std::vector< SmartUtil::tstring > & colNames )
@@ -229,7 +208,7 @@
return buffer;
}
-std::vector< unsigned > WidgetListView::getSelected()
+std::vector< unsigned > WidgetListView::getSelection() const
{
std::vector< unsigned > retVal;
int tmpIdx = - 1;
Modified: dcplusplus/trunk/smartwin/source/widgets/WidgetTabView.cpp
===================================================================
--- dcplusplus/trunk/smartwin/source/widgets/WidgetTabView.cpp 2008-03-26 14:19:33 UTC (rev 1065)
+++ dcplusplus/trunk/smartwin/source/widgets/WidgetTabView.cpp 2008-03-26 14:25:11 UTC (rev 1066)
@@ -68,7 +68,7 @@
}
WidgetChildWindow* WidgetTabView::getActive() {
- TabInfo* ti = getTabInfo(tab->getSelectedIndex());
+ TabInfo* ti = getTabInfo(tab->getSelected());
return ti ? ti->w : 0;
}
@@ -77,7 +77,7 @@
setActive(*(--(--viewOrder.end())));
}
- WidgetChildWindow* cur = getTabInfo(tab->getSelectedIndex())->w;
+ WidgetChildWindow* cur = getTabInfo(tab->getSelected())->w;
viewOrder.remove(w);
@@ -115,7 +115,7 @@
if(i == -1)
return;
- tab->setSelectedIndex(i);
+ tab->setSelected(i);
handleTabSelected();
}
@@ -137,7 +137,7 @@
}
void WidgetTabView::handleTabSelected() {
- int i = tab->getSelectedIndex();
+ int i = tab->getSelected();
if(i == active) {
return;
}
@@ -162,7 +162,7 @@
void WidgetTabView::mark(WidgetChildWindow* w) {
int i = findTab(w);
- if(i != -1 && i != tab->getSelectedIndex()) {
+ if(i != -1 && i != tab->getSelected()) {
tab->setHighlight(i, true);
}
}
@@ -210,7 +210,7 @@
void WidgetTabView::layout() {
Rectangle tmp = tab->getUsableArea(true);
if(!(tmp == clientSize)) {
- int i = tab->getSelectedIndex();
+ int i = tab->getSelected();
if(i != -1) {
::MoveWindow(getTabInfo(i)->w->handle(), tmp.x(), tmp.y(), tmp.width(), tmp.height(), TRUE);
}
@@ -340,7 +340,7 @@
tab->addPage(formatTitle(ti->w->getText()), dropPos, reinterpret_cast<LPARAM>(ti), image);
- active = tab->getSelectedIndex();
+ active = tab->getSelected();
layout();
}
@@ -349,7 +349,7 @@
bool WidgetTabView::handleContextMenu(ScreenCoordinate pt) {
TabInfo* ti = 0;
if(pt.x() == -1 && pt.y() == -1) {
- int i = tab->getSelectedIndex();
+ int i = tab->getSelected();
RECT rc;
if(i == -1 || !TabCtrl_GetItemRect(tab->handle(), i, &rc)) {
@@ -385,7 +385,7 @@
if(msg.message == WM_KEYUP && msg.wParam == VK_CONTROL) {
inTab = false;
- TabInfo* ti = getTabInfo(tab->getSelectedIndex());
+ TabInfo* ti = getTabInfo(tab->getSelected());
if(ti) {
setTop(ti->w);
}
@@ -400,7 +400,7 @@
bool WidgetTabView::tryFire(const MSG& msg, LRESULT& retVal) {
bool handled = PolicyType::tryFire(msg, retVal);
if(!handled && msg.message == WM_COMMAND && getTab()) {
- TabInfo* ti = getTabInfo(getTab()->getSelectedIndex());
+ TabInfo* ti = getTabInfo(getTab()->getSelected());
if(ti) {
handled = ti->w->tryFire(msg, retVal);
}
Modified: dcplusplus/trunk/smartwin/source/widgets/WidgetTreeView.cpp
===================================================================
--- dcplusplus/trunk/smartwin/source/widgets/WidgetTreeView.cpp 2008-03-26 14:19:33 UTC (rev 1065)
+++ dcplusplus/trunk/smartwin/source/widgets/WidgetTreeView.cpp 2008-03-26 14:25:11 UTC (rev 1066)
@@ -96,30 +96,6 @@
TreeView_SetImageList( this->Widget::handle(), imageList->getImageList(), TVSIL_STATE );
}
-int WidgetTreeView::getSelectedIndex() const
-{
- HTREEITEM hSelItem = TreeView_GetSelection( this->handle() );
- TVITEM item;
- ZeroMemory( & item, sizeof( TVITEM ) );
- item.mask = TVIF_HANDLE | TVIF_PARAM;
- item.hItem = hSelItem;
- if ( TreeView_GetItem( this->handle(), & item ) )
- return static_cast< unsigned >( item.lParam );
- return 0;
-}
-
-void WidgetTreeView::setSelectedIndex( int idx )
-{
- TVITEM item;
- item.mask = TVIF_PARAM;
- item.lParam = idx;
- if ( TreeView_GetItem( this->handle(), & item ) == FALSE )
- {
- throw xCeption( _T( "Couldn't find given item" ) );
- }
- TreeView_Select( this->handle(), item.hItem, TVGN_FIRSTVISIBLE );
-}
-
LPARAM WidgetTreeView::getDataImpl(HTREEITEM item) {
TVITEM tvitem = { TVIF_PARAM | TVIF_HANDLE };
tvitem.hItem = item;
@@ -137,7 +113,7 @@
}
ScreenCoordinate WidgetTreeView::getContextMenuPos() {
- HTREEITEM item = getSelection();
+ HTREEITEM item = getSelected();
POINT pt = { 0 };
if(item) {
RECT trc = this->getItemRect(item);
@@ -149,8 +125,8 @@
void WidgetTreeView::select(const ScreenCoordinate& pt) {
HTREEITEM ht = this->hitTest(pt);
- if(ht != NULL && ht != this->getSelection()) {
- this->select(ht);
+ if(ht != NULL && ht != this->getSelected()) {
+ this->setSelected(ht);
}
}
Modified: dcplusplus/trunk/win32/ADLSProperties.cpp
===================================================================
--- dcplusplus/trunk/win32/ADLSProperties.cpp 2008-03-26 14:19:33 UTC (rev 1065)
+++ dcplusplus/trunk/win32/ADLSProperties.cpp 2008-03-26 14:25:11 UTC (rev 1066)
@@ -62,7 +62,7 @@
searchType->addValue(T_("Filename"));
searchType->addValue(T_("Directory"));
searchType->addValue(T_("Full Path"));
- searchType->setSelectedIndex(search->sourceType);
+ searchType->setSelected(search->sourceType);
minSize = attachTextBox(IDC_MIN_FILE_SIZE);
minSize->setText((search->minFileSize > 0) ? Text::toT(Util::toString(search->minFileSize)) : Util::emptyStringT);
@@ -75,7 +75,7 @@
sizeType->addValue(T_("KiB"));
sizeType->addValue(T_("MiB"));
sizeType->addValue(T_("GiB"));
- sizeType->setSelectedIndex(search->typeFileSize);
+ sizeType->setSelected(search->typeFileSize);
destDir = attachTextBox(IDC_DEST_DIR);
destDir->setText(Text::toT(search->destDir));
@@ -106,7 +106,7 @@
void ADLSProperties::handleOKClicked() {
search->searchString = Text::fromT(searchString->getText());
- search->sourceType = (ADLSearch::SourceType)searchType->getSelectedIndex();
+ search->sourceType = ADLSearch::SourceType(searchType->getSelected());
tstring minFileSize = minSize->getText();
search->minFileSize = minFileSize.empty() ? -1 : Util::toInt64(Text::fromT(minFileSize));
@@ -114,7 +114,7 @@
tstring maxFileSize = maxSize->getText();
search->maxFileSize = maxFileSize.empty() ? -1 : Util::toInt64(Text::fromT(maxFileSize));
- search->typeFileSize = (ADLSearch::SizeType)sizeType->getSelectedIndex();
+ search->typeFileSize = ADLSearch::SizeType(sizeType->getSelected());
search->destDir = Text::fromT(destDir->getText());
Modified: dcplusplus/trunk/win32/ADLSearchFrame.cpp
===================================================================
--- dcplusplus/trunk/win32/ADLSearchFrame.cpp 2008-03-26 14:19:33 UTC (rev 1065)
+++ dcplusplus/trunk/win32/ADLSearchFrame.cpp 2008-03-26 14:25:11 UTC (rev 1066)
@@ -160,8 +160,8 @@
int index;
// Add new search to the end or if selected, just before
- if(items->getSelectedCount() == 1) {
- index = items->getSelectedIndex();
+ if(items->countSelected() == 1) {
+ index = items->getSelected();
collection.insert(collection.begin() + index, search);
} else {
index = -1;
@@ -174,7 +174,7 @@
void ADLSearchFrame::handleProperties() {
// Get selection info
- std::vector<unsigned> selected = items->getSelected();
+ std::vector<unsigned> selected = items->getSelection();
for(std::vector<unsigned>::const_iterator i = selected.begin(); i != selected.end(); ++i) {
// Edit existing
ADLSearchManager::SearchCollection& collection = ADLSearchManager::getInstance()->collection;
@@ -198,7 +198,7 @@
void ADLSearchFrame::handleUp() {
ADLSearchManager::SearchCollection& collection = ADLSearchManager::getInstance()->collection;
HoldRedraw hold(items);
- std::vector<unsigned> selected = items->getSelected();
+ std::vector<unsigned> selected = items->getSelection();
for(std::vector<unsigned>::const_iterator i = selected.begin(); i != selected.end(); ++i) {
if(*i > 0) {
ADLSearch search = collection[*i];
@@ -213,7 +213,7 @@
void ADLSearchFrame::handleDown() {
ADLSearchManager::SearchCollection& collection = ADLSearchManager::getInstance()->collection;
HoldRedraw hold(items);
- std::vector<unsigned> selected = items->getSelected();
+ std::vector<unsigned> selected = items->getSelection();
for(std::vector<unsigned>::reverse_iterator i = selected.rbegin(); i != selected.rend(); ++i) {
if(*i < items->size() - 1) {
ADLSearch search = collection[*i];
@@ -235,7 +235,7 @@
}
void ADLSearchFrame::handleDoubleClick() {
- if(items->hasSelection()) {
+ if(items->hasSelected()) {
handleProperties();
} else {
handleAdd();
@@ -287,7 +287,7 @@
contextMenu->appendItem(IDC_EDIT, T_("&Properties"), std::tr1::bind(&ADLSearchFrame::handleProperties, this));
contextMenu->appendItem(IDC_REMOVE, T_("&Remove"), std::tr1::bind(&ADLSearchFrame::handleRemove, this));
- bool status = items->hasSelection();
+ bool status = items->hasSelected();
contextMenu->setItemEnabled(IDC_EDIT, false, status);
contextMenu->setItemEnabled(IDC_REMOVE, false, status);
Modified: dcplusplus/trunk/win32/AppearancePage.cpp
===================================================================
--- dcplusplus/trunk/win32/AppearancePage.cpp 2008-03-26 14:19:33 UTC (rev 1065)
+++ dcplusplus/trunk/win32/AppearancePage.cpp 2008-03-26 14:25:11 UTC (rev 1066)
@@ -108,7 +108,7 @@
}
}
- languages->setSelectedIndex(selected);
+ languages->setSelected(selected);
attachTextBox(IDC_DEFAULT_AWAY_MESSAGE);
attachTextBox(IDC_TIME_STAMPS_FORMAT);
Modified: dcplusplus/trunk/win32/DirectoryListingFrame.cpp
===================================================================
--- dcplusplus/trunk/win32/DirectoryListingFrame.cpp 2008-03-26 14:19:33 UTC (rev 1065)
+++ dcplusplus/trunk/win32/DirectoryListingFrame.cpp 2008-03-26 14:25:11 UTC (rev 1066)
@@ -289,10 +289,10 @@
}
updateTree(d, ht);
- dirs->select(NULL);
+ dirs->setSelected(NULL);
selectItem(root);
- dcdebug("selected");
+ dcdebug("setSelecteded");
dirs->expand(treeRoot);
}
@@ -389,12 +389,12 @@
bool DirectoryListingFrame::handleFilesContextMenu(SmartWin::ScreenCoordinate pt) {
WidgetMenuPtr contextMenu;
- if(files->hasSelection()) {
+ if(files->hasSelected()) {
if(pt.x() == -1 && pt.y() == -1) {
pt = files->getContextMenuPos();
}
- if(files->getSelectedCount() == 1) {
+ if(files->countSelected() == 1) {
ItemInfo* ii = files->getSelectedData();
if(BOOLSETTING(SHOW_SHELL_MENU) && (dl->getUser() == ClientManager::getInstance()->getMe()) && ii->type == ItemInfo::FILE) {
string path;
@@ -432,7 +432,7 @@
dirs->select(pt);
}
- if(dirs->getSelection()) {
+ if(dirs->getSelected()) {
WidgetMenuPtr contextMenu = makeDirMenu();
usingDirMenu = true;
contextMenu->trackPopupMenu(pt, TPM_LEFTALIGN | TPM_RIGHTBUTTON);
@@ -488,7 +488,7 @@
}
}
} else {
- if(files->getSelectedCount() == 1) {
+ if(files->countSelected() == 1) {
ItemInfo* ii = files->getSelectedData();
try {
if(ii->type == ItemInfo::FILE) {
@@ -540,7 +540,7 @@
return;
}
- if(files->getSelectedCount() != 1) {
+ if(files->countSelected() != 1) {
return;
}
@@ -555,7 +555,7 @@
void DirectoryListingFrame::handleGoToDirectory() {
- if(files->getSelectedCount() != 1)
+ if(files->countSelected() != 1)
return;
tstring fullPath;
@@ -586,7 +586,7 @@
download(ii, target);
}
} else {
- if(files->getSelectedCount() == 1) {
+ if(files->countSelected() == 1) {
ItemInfo* ii = files->getSelectedData();
download(ii, target);
} else {
@@ -617,7 +617,7 @@
HTREEITEM ht = findItem(treeRoot, name);
if(ht != NULL) {
dirs->ensureVisible(ht);
- dirs->select(ht);
+ dirs->setSelected(ht);
}
}
@@ -638,7 +638,7 @@
void DirectoryListingFrame::updateStatus() {
if(!searching && !updating) {
- int cnt = files->getSelectedCount();
+ int cnt = files->countSelected();
int64_t total = 0;
if(cnt == 0) {
cnt = files->size();
@@ -713,13 +713,13 @@
}
void DirectoryListingFrame::up() {
- HTREEITEM t = dirs->getSelection();
+ HTREEITEM t = dirs->getSelected();
if(t == NULL)
return;
t = dirs->getParent(t);
if(t == NULL)
return;
- dirs->select(t);
+ dirs->setSelected(t);
}
void DirectoryListingFrame::back() {
@@ -811,24 +811,24 @@
// Do a search
int foundFile = -1, skipHitsTmp = skipHits;
- HTREEITEM const oldDir = dirs->getSelection();
+ HTREEITEM const oldDir = dirs->getSelected();
HTREEITEM const foundDir = findFile(StringSearch(findStr), treeRoot, foundFile, skipHitsTmp);
if(foundDir) {
// Highlight the directory tree and list if the parent dir/a matched dir was found
if(foundFile >= 0) {
// SelectItem won't update the list if SetRedraw was set to FALSE and then
- // to TRUE and the item selected is the same as the last one... workaround:
+ // to TRUE and the item setSelecteded is the same as the last one... workaround:
if(oldDir == foundDir)
- dirs->select(NULL);
+ dirs->setSelected(NULL);
- dirs->select(foundDir);
+ dirs->setSelected(foundDir);
} else {
- // Got a dir; select its parent directory in the tree if there is one
+ // Got a dir; setSelected its parent directory in the tree if there is one
HTREEITEM parentItem = dirs->getParent(foundDir);
if(parentItem) {
// Go to parent file list
- dirs->select(parentItem);
+ dirs->setSelected(parentItem);
// Locate the dir in the file list
DirectoryListing::Directory* dir = dirs->getData(foundDir)->dir;
@@ -836,25 +836,25 @@
foundFile = files->find(Text::toT(dir->getName()), -1, false);
} else {
// If no parent exists, just the dir tree item and skip the list highlighting
- dirs->select(foundDir);
+ dirs->setSelected(foundDir);
}
}
- // Remove prev. selection from file list
- if(files->hasSelection()) {
+ // Remove prev. setSelectedion from file list
+ if(files->hasSelected()) {
files->clearSelection();
}
// Highlight and focus the dir/file if possible
if(foundFile >= 0) {
files->setFocus();
- files->setSelectedIndex(foundFile);
+ files->setSelected(foundFile);
files->ensureVisible(foundFile);
} else {
dirs->setFocus();
}
} else {
- dirs->select(oldDir);
+ dirs->setSelected(oldDir);
createMessageBox().show(T_("No matches"), T_("Search for file"));
}
}
@@ -904,8 +904,8 @@
void DirectoryListingFrame::handleDoubleClickFiles() {
- HTREEITEM t = dirs->getSelection();
- int i = files->getSelectedIndex();
+ HTREEITEM t = dirs->getSelected();
+ int i = files->getSelected();
if(t != NULL && i != -1) {
ItemInfo* ii = files->getData(i);
@@ -919,7 +919,7 @@
HTREEITEM ht = dirs->getChild(t);
while(ht != NULL) {
if(dirs->getData(ht)->dir == ii->dir) {
- dirs->select(ht);
+ dirs->setSelected(ht);
break;
}
ht = dirs->getNextSibling(ht);
@@ -954,13 +954,13 @@
return true;
}
if(c == VK_RETURN) {
- if(files->getSelectedCount() == 1) {
+ if(files->countSelected() == 1) {
ItemInfo* ii = files->getSelectedData();
if(ii->type == ItemInfo::DIRECTORY) {
- HTREEITEM ht = dirs->getChild(dirs->getSelection());
+ HTREEITEM ht = dirs->getChild(dirs->getSelected());
while(ht != NULL) {
if(dirs->getData(ht)->dir == ii->dir) {
- dirs->select(ht);
+ dirs->setSelected(ht);
break;
}
ht = dirs->getNextSibling(ht);
Modified: dcplusplus/trunk/win32/FavHubsFrame.cpp
===================================================================
--- dcplusplus/trunk/win32/FavHubsFrame.cpp 2008-03-26 14:19:33 UTC (rev 1065)
+++ dcplusplus/trunk/win32/FavHubsFrame.cpp 2008-03-26 14:25:11 UTC (rev 1066)
@@ -181,8 +181,8 @@
}
void FavHubsFrame::handleProperties() {
- if(hubs->getSelectedCount() == 1) {
- int i = hubs->getSelectedIndex();
+ if(hubs->countSelected() == 1) {
+ int i = hubs->getSelected();
FavoriteHubEntryPtr e = reinterpret_cast<FavoriteHubEntryPtr>(hubs->getData(i));
dcassert(e != NULL);
FavHubProperties dlg(this, e);
@@ -201,7 +201,7 @@
nosave = true;
FavoriteHubEntryList& fh = FavoriteManager::getInstance()->getFavoriteHubs();
HoldRedraw hold(hubs);
- std::vector<unsigned> selected = hubs->getSelected();
+ std::vector<unsigned> selected = hubs->getSelection();
for(std::vector<unsigned>::const_iterator i = selected.begin(); i != selected.end(); ++i) {
if(*i > 0) {
FavoriteHubEntryPtr e = fh[*i];
@@ -219,7 +219,7 @@
nosave = true;
FavoriteHubEntryList& fh = FavoriteManager::getInstance()->getFavoriteHubs();
HoldRedraw hold(hubs);
- std::vector<unsigned> selected = hubs->getSelected();
+ std::vector<unsigned> selected = hubs->getSelection();
for(std::vector<unsigned>::reverse_iterator i = selected.rbegin(); i != selected.rend(); ++i) {
if(*i < hubs->size() - 1) {
FavoriteHubEntryPtr e = fh[*i];
@@ -234,7 +234,7 @@
}
void FavHubsFrame::handleRemove() {
- if(hubs->hasSelection() && (!BOOLSETTING(CONFIRM_HUB_REMOVAL) || createMessageBox().show(T_("Really remove?"), _T(APPNAME) _T(" ") _T(VERSIONSTRING), WidgetMessageBox::BOX_YESNO, WidgetMessageBox::BOX_ICONQUESTION) == WidgetMessageBox::RETBOX_YES)) {
+ if(hubs->hasSelected() && (!BOOLSETTING(CONFIRM_HUB_REMOVAL) || createMessageBox().show(T_("Really remove?"), _T(APPNAME) _T(" ") _T(VERSIONSTRING), WidgetMessageBox::BOX_YESNO, WidgetMessageBox::BOX_ICONQUESTION) == WidgetMessageBox::RETBOX_YES)) {
int i;
while((i = hubs->getNext(-1, LVNI_SELECTED)) != -1)
FavoriteManager::getInstance()->removeFavorite(reinterpret_cast<FavoriteHubEntryPtr>(hubs->getData(i)));
@@ -242,7 +242,7 @@
}
void FavHubsFrame::handleDoubleClick() {
- if(hubs->hasSelection()) {
+ if(hubs->hasSelected()) {
openSelected();
} else {
handleAdd();
@@ -290,7 +290,7 @@
menu->appendItem(IDC_REMOVE, T_("&Remove"), std::tr1::bind(&FavHubsFrame::handleRemove, this));
menu->setDefaultItem(IDC_CONNECT);
- bool status = hubs->hasSelection();
+ bool status = hubs->hasSelected();
menu->setItemEnabled(IDC_CONNECT, false, status);
menu->setItemEnabled(IDC_EDIT, false, status);
menu->setItemEnabled(IDC_MOVE_UP, false, status);
@@ -318,7 +318,7 @@
}
void FavHubsFrame::openSelected() {
- if(!hubs->hasSelection())
+ if(!hubs->hasSelected())
return;
if(SETTING(NICK).empty()) {
@@ -326,7 +326,7 @@
return;
}
- std::vector<unsigned> items = hubs->getSelected();
+ std::vector<unsigned> items = hubs->getSelection();
for(std::vector<unsigned>::iterator i = items.begin(); i != items.end(); ++i) {
FavoriteHubEntryPtr entry = reinterpret_cast<FavoriteHubEntryPtr>(hubs->getData(*i));
HubFrame::openWindow(getParent(), entry->getServer());
Modified: dcplusplus/trunk/win32/FavoriteDirsPage.cpp
===================================================================
--- dcplusplus/trunk/win32/FavoriteDirsPage.cpp 2008-03-26 14:19:33 UTC (rev 1065)
+++ dcplusplus/trunk/win32/FavoriteDirsPage.cpp 2008-03-26 14:25:11 UTC (rev 1066)
@@ -92,7 +92,7 @@
}
void FavoriteDirsPage::handleDoubleClick() {
- if(directories->hasSelection()) {
+ if(directories->hasSelected()) {
handleRenameClicked();
} else {
handleAddClicked();
@@ -112,9 +112,9 @@
}
LRESULT FavoriteDirsPage::handleItemChanged(WPARAM wParam, LPARAM lParam) {
- BOOL hasSelection = directories->hasSelection() ? TRUE : FALSE;
- ::EnableWindow(::GetDlgItem(handle(), IDC_RENAME), hasSelection);
- ::EnableWindow(::GetDlgItem(handle(), IDC_REMOVE), hasSelection);
+ BOOL hasSelected = directories->hasSelected() ? TRUE : FALSE;
+ ::EnableWindow(::GetDlgItem(handle(), IDC_RENAME), hasSelected);
+ ::EnableWindow(::GetDlgItem(handle(), IDC_REMOVE), hasSelected);
return 0;
}
Modified: dcplusplus/trunk/win32/FinishedFrameBase.h
===================================================================
--- dcplusplus/trunk/win32/FinishedFrameBase.h 2008-03-26 14:19:33 UTC (rev 1065)
+++ dcplusplus/trunk/win32/FinishedFrameBase.h 2008-03-26 14:25:11 UTC (rev 1066)
@@ -194,7 +194,7 @@
}
void handleDoubleClick() {
- if(items->hasSelection())
+ if(items->hasSelected())
items->getSelectedData()->openFile();
}
@@ -207,12 +207,12 @@
}
bool handleContextMenu(SmartWin::ScreenCoordinate pt) {
- if(items->hasSelection()) {
+ if(items->hasSelected()) {
if(pt.x() == -1 && pt.y() == -1) {
pt = items->getContextMenuPos();
}
- if(BOOLSETTING(SHOW_SHELL_MENU) && items->getSelectedCount() == 1) {
+ if(BOOLSETTING(SHOW_SHELL_MENU) && items->countSelected() == 1) {
string path = items->getSelectedData()->entry->getTarget();
if(File::getSize(path) != -1) {
CShellContextMenu shellMenu;
Modified: dcplusplus/trunk/win32/GeneralPage.cpp
===================================================================
--- dcplusplus/trunk/win32/GeneralPage.cpp 2008-03-26 14:19:33 UTC (rev 1065)
+++ dcplusplus/trunk/win32/GeneralPage.cpp 2008-03-26 14:25:11 UTC (rev 1066)
@@ -75,7 +75,7 @@
}
}
- connections->setSelectedIndex(selected);
+ connections->setSelected(selected);
nick = attachTextBox(IDC_NICK);
nick->setTextLimit(35);
Modified: dcplusplus/trunk/win32/HubFrame.cpp
===================================================================
--- dcplusplus/trunk/win32/HubFrame.cpp 2008-03-26 14:19:33 UTC (rev 1065)
+++ dcplusplus/trunk/win32/HubFrame.cpp 2008-03-26 14:25:11 UTC (rev 1066)
@@ -117,7 +117,7 @@
filterType->addValue(T_(columnNames[j]));
}
filterType->addValue(T_("Any"));
- filterType->setSelectedIndex(COLUMN_LAST);
+ filterType->setSelected(COLUMN_LAST);
filterType->onSelectionChanged(std::tr1::bind(&HubFrame::updateUserList, this, (UserInfo*)0));
}
@@ -902,7 +902,7 @@
tstring HubFrame::getStatusShared() const {
int64_t available;
- if (users->getSelectedCount() > 1) {
+ if (users->countSelected() > 1) {
available = users->forEachSelectedT(CountAvailable()).available;
} else {
available = std::for_each(userMap.begin(), userMap.end(), CountAvailable()).available;
@@ -919,8 +919,8 @@
}
tstring textForUsers;
- if (users->getSelectedCount() > 1)
- textForUsers += Text::toT(Util::toString(users->getSelectedCount()) + "/");
+ if (users->countSelected() > 1)
+ textForUsers += Text::toT(Util::toString(users->countSelected()) + "/");
if (showUsers->getChecked() && users->size() < userCount)
textForUsers += Text::toT(Util::toString(users->size()) + "/");
return textForUsers + str(TFN_("%1% user", "%1% users", userCount) % userCount);
@@ -1037,7 +1037,7 @@
int64_t size = -1;
FilterModes mode = NONE;
- int sel = filterType->getSelectedIndex();
+ int sel = filterType->getSelected();
bool doSizeCompare = parseFilter(mode, size) && sel == COLUMN_SHARED;
@@ -1130,7 +1130,7 @@
int pos = users->find(txt);
if(pos != -1) {
users->clearSelection();
- users->setSelectedIndex(pos);
+ users->setSelected(pos);
users->ensureVisible(pos);
doMenu = true;
}
@@ -1140,7 +1140,7 @@
}
bool HubFrame::handleUsersContextMenu(SmartWin::ScreenCoordinate pt) {
- if(users->hasSelection()) {
+ if(users->hasSelected()) {
if(pt.x() == -1 || pt.y() == -1) {
pt = users->getContextMenuPos();
}
@@ -1217,7 +1217,7 @@
}
void HubFrame::handleDoubleClickUsers() {
- if(users->hasSelection()) {
+ if(users->hasSelected()) {
users->getSelectedData()->getList();
}
}
@@ -1335,7 +1335,7 @@
// Maybe it found a unique match. If userlist showing, highlight.
if (showUsers->getChecked() && tabCompleteNicks.size() == 2) {
int i = users->find(Text::toT(tabCompleteNicks[1]));
- users->setSelectedIndex(i);
+ users->setSelected(i);
users->ensureVisible(i);
}
Modified: dcplusplus/trunk/win32/HubListsDlg.cpp
===================================================================
--- dcplusplus/trunk/win32/HubListsDlg.cpp 2008-03-26 14:19:33 UTC (rev 1065)
+++ dcplusplus/trunk/win32/HubListsDlg.cpp 2008-03-26 14:25:11 UTC (rev 1066)
@@ -93,7 +93,7 @@
}
void HubListsDlg::handleDoubleClick() {
- if(hubLists->hasSelection()) {
+ if(hubLists->hasSelected()) {
handleEditClicked();
}
}
@@ -119,7 +119,7 @@
void HubListsDlg::handleMoveUpClicked() {
HoldRedraw hold(hubLists);
- std::vector<unsigned> selected = hubLists->getSelected();
+ std::vector<unsigned> selected = hubLists->getSelection();
for(std::vector<unsigned>::const_iterator i = selected.begin(); i != selected.end(); ++i) {
if(*i > 0) {
tstring selText = hubLists->getText(*i, 0);
@@ -132,7 +132,7 @@
void HubListsDlg::handleMoveDownClicked() {
HoldRedraw hold(hubLists);
- std::vector<unsigned> selected = hubLists->getSelected();
+ std::vector<unsigned> selected = hubLists->getSelection();
for(std::vector<unsigned>::reverse_iterator i = selected.rbegin(); i != selected.rend(); ++i) {
if(*i < hubLists->size() - 1) {
tstring selText = hubLists->getText(*i, 0);
Modified: dcplusplus/trunk/win32/LogPage.cpp
===================================================================
--- dcplusplus/trunk/win32/LogPage.cpp 2008-03-26 14:19:33 UTC (rev 1065)
+++ dcplusplus/trunk/win32/LogPage.cpp 2008-03-26 14:25:11 UTC (rev 1066)
@@ -131,7 +131,7 @@
LRESULT LogPage::handleItemChanged() {
getValues();
- int sel = dataGrid->getSelectedIndex();
+ int sel = dataGrid->getSelected();
if(sel >= 0 && sel < LogManager::LAST) {
bool checkState = dataGrid->isChecked(sel);
Modified: dcplusplus/trunk/win32/PublicHubsFrame.cpp
===================================================================
--- dcplusplus/trunk/win32/PublicHubsFrame.cpp 2008-03-26 14:19:33 UTC (rev 1065)
+++ dcplusplus/trunk/win32/PublicHubsFrame.cpp 2008-03-26 14:25:11 UTC (rev 1066)
@@ -135,7 +135,7 @@
filterSel->addValue(T_(columnNames[j]));
}
filterSel->addValue(T_("Any"));
- filterSel->setSelectedIndex(COLUMN_LAST);
+ filterSel->setSelected(COLUMN_LAST);
filterSel->onSelectionChanged(std::tr1::bind(&PublicHubsFrame::updateList, this));
pubLists = createComboBox(WinUtil::Seeds::comboBoxStatic);
@@ -272,12 +272,12 @@
}
void PublicHubsFrame::updateDropDown() {
- pubLists->removeAllItems();
+ pubLists->clear();
StringList lists(FavoriteManager::getInstance()->getHubLists());
for(StringList::iterator idx = lists.begin(); idx != lists.end(); ++idx) {
pubLists->addValue(Text::toT(*idx).c_str());
}
- pubLists->setSelectedIndex(FavoriteManager::getInstance()->getSelectedHubList());
+ pubLists->setSelected(FavoriteManager::getInstance()->getSelectedHubList());
}
void PublicHubsFrame::updateList() {
@@ -290,7 +290,7 @@
double size = -1;
FilterModes mode = NONE;
- int sel = filterSel->getSelectedIndex();
+ int sel = filterSel->getSelected();
bool doSizeCompare = parseFilter(mode, size);
@@ -438,7 +438,7 @@
}
bool PublicHubsFrame::handleContextMenu(SmartWin::ScreenCoordinate pt) {
- if(hubs->hasSelection()) {
+ if(hubs->hasSelected()) {
if(pt.x() == -1 && pt.y() == -1) {
pt = hubs->getContextMenuPos();
}
@@ -471,7 +471,7 @@
if(!checkNick())
return;
- if(hubs->hasSelection() == 1) {
+ if(hubs->hasSelected() == 1) {
HubFrame::openWindow(getParent(), hubs->getSelectedData()->entry->getServer());
}
}
@@ -480,13 +480,13 @@
if(!checkNick())
return;
- if(hubs->hasSelection()) {
+ if(hubs->hasSelected()) {
FavoriteManager::getInstance()->addFavorite(*hubs->getSelectedData()->entry);
}
}
void PublicHubsFrame::handleCopyHub() {
- if(hubs->hasSelection()) {
+ if(hubs->hasSelected()) {
WinUtil::setClipboard(Text::toT(hubs->getSelectedData()->entry->getServer()));
}
}
@@ -504,7 +504,7 @@
if(!checkNick())
return;
- if(hubs->hasSelection()) {
+ if(hubs->hasSelected()) {
HubFrame::openWindow(getParent(), hubs->getSelectedData()->entry->getServer());
}
}
@@ -518,7 +518,7 @@
}
void PublicHubsFrame::handleListSelChanged() {
- FavoriteManager::getInstance()->setHubList(pubLists->getSelectedIndex());
+ FavoriteManager::getInstance()->setHubList(pubLists->getSelected());
entries = FavoriteManager::getInstance()->getPublicHubs();
updateList();
}
Modified: dcplusplus/trunk/win32/QueueFrame.cpp
===================================================================
--- dcplusplus/trunk/win32/QueueFrame.cpp 2008-03-26 14:19:33 UTC (rev 1065)
+++ dcplusplus/trunk/win32/QueueFrame.cpp 2008-03-26 14:25:11 UTC (rev 1066)
@@ -260,7 +260,7 @@
void QueueFrame::updateStatus() {
int64_t total = 0;
- int cnt = files->getSelectedCount();
+ int cnt = files->countSelected();
if(cnt < 2) {
cnt = files->size();
if(showTree->getChecked()) {
@@ -694,11 +694,11 @@
void QueueFrame::removeSelectedDir() {
if(!BOOLSETTING(CONFIRM_ITEM_REMOVAL) || createMessageBox().show(T_("Really remove?"), _T(APPNAME) _T(" ") _T(VERSIONSTRING), WidgetMessageBox::BOX_YESNO, WidgetMessageBox::BOX_ICONQUESTION) == IDYES)
- removeDir(dirs->getSelection());
+ removeDir(dirs->getSelected());
}
void QueueFrame::moveSelected() {
- int n = files->getSelectedCount();
+ int n = files->countSelected();
if(n == 1) {
// Single file, get the full filename and move...
QueueItemInfo* ii = files->getSelectedData();
@@ -738,14 +738,15 @@
}
void QueueFrame::moveSelectedDir() {
- if(dirs->getSelection() == NULL)
+ HTREEITEM item = dirs->getSelected();
+ if(!item)
return;
dcassert(!curDir.empty());
tstring name = Text::toT(curDir);
if(WinUtil::browseDirectory(name, handle())) {
- moveDir(dirs->getSelection(), Text::fromT(name));
+ moveDir(item, Text::fromT(name));
}
}
@@ -768,7 +769,7 @@
void QueueFrame::handleBrowseList(const UserPtr& user) {
- if(files->getSelectedCount() == 1) {
+ if(files->countSelected() == 1) {
try {
QueueManager::getInstance()->addList(user, QueueItem::FLAG_CLIENT_VIEW);
} catch(const Exception&) {
@@ -778,7 +779,7 @@
void QueueFrame::handleReadd(const UserPtr& user) {
- if(files->getSelectedCount() == 1) {
+ if(files->countSelected() == 1) {
QueueItemInfo* ii = files->getSelectedData();
if(!user) {
@@ -806,7 +807,7 @@
void QueueFrame::handleRemoveSource(const UserPtr& user) {
- if(files->getSelectedCount() == 1) {
+ if(files->countSelected() == 1) {
QueueItemInfo* ii = files->getSelectedData();
if(!user) {
@@ -824,7 +825,7 @@
}
void QueueFrame::handlePM(const UserPtr& user) {
- if(files->getSelectedCount() == 1) {
+ if(files->countSelected() == 1) {
PrivateFrame::openWindow(getParent(), user);
}
}
@@ -843,9 +844,9 @@
}
if(usingDirMenu) {
- setPriority(dirs->getSelection(), p);
+ setPriority(dirs->getSelected(), p);
} else {
- std::vector<size_t> selected = files->getSelected();
+ std::vector<size_t> selected = files->getSelection();
for(std::vector<size_t>::iterator i = selected.begin(); i != selected.end(); ++i) {
QueueManager::getInstance()->setPriority(files->getData(*i)->getTarget(), p);
}
@@ -871,7 +872,7 @@
* @param inc True = increase, False = decrease
*/
void QueueFrame::changePriority(bool inc){
- std::vector<size_t> selected = files->getSelected();
+ std::vector<size_t> selected = files->getSelection();
for(std::vector<size_t>::iterator i = selected.begin(); i != selected.end(); ++i) {
QueueItemInfo* ii = files->getData(*i);
QueueItem::Priority p = ii->getPriority();
@@ -1053,7 +1054,7 @@
}
bool QueueFrame::handleFilesContextMenu(SmartWin::ScreenCoordinate pt) {
- if(files->getSelectedCount() > 0) {
+ if(files->countSelected() > 0) {
if(pt.x() == -1 || pt.y() == -1) {
pt = files->getContextMenuPos();
}
@@ -1061,7 +1062,7 @@
usingDirMenu = false;
WidgetMenuPtr contextMenu;
- if(files->getSelectedCount() == 1) {
+ if(files->countSelected() == 1) {
QueueItemInfo* ii = files->getSelectedData();
contextMenu = makeSingleMenu(ii);
} else {
@@ -1081,7 +1082,7 @@
dirs->select(pt);
}
- if(dirs->getSelection()) {
+ if(dirs->hasSelected()) {
usingDirMenu = true;
WidgetMenuPtr contextMenu = makeDirMenu();
contextMenu->trackPopupMenu(pt, TPM_LEFTALIGN | TPM_RIGHTBUTTON);
Modified: dcplusplus/trunk/win32/SearchFrame.cpp
===================================================================
--- dcplusplus/trunk/win32/SearchFrame.cpp 2008-03-26 14:19:33 UTC (rev 1065)
+++ dcplusplus/trunk/win32/SearchFrame.cpp 2008-03-26 14:25:11 UTC (rev 1066)
@@ -172,7 +172,7 @@
sizeMode->addValue(T_("KiB"));
sizeMode->addValue(T_("MiB"));
sizeMode->addValue(T_("GiB"));
- sizeMode->setSelectedIndex((initialSize == 0) ? 2 : 0);
+ sizeMode->setSelected((initialSize == 0) ? 2 : 0);
}
{
@@ -275,14 +275,14 @@
if(!initialString.empty()) {
lastSearches.push_back(initialString);
searchBox->insertValue(0, initialString);
- searchBox->setSelectedIndex(0);
- mode->setSelectedIndex(initialMode);
+ searchBox->setSelected(0);
+ mode->setSelected(initialMode);
size->setText(Text::toT(Util::toString(initialSize)));
- fileType->setSelectedIndex(initialType);
+ fileType->setSelected(initialType);
runSearch();
} else {
- mode->setSelectedIndex(1);
- fileType->setSelectedIndex(SETTING(LAST_SEARCH_TYPE));
+ mode->setSelected(1);
+ fileType->setSelected(SETTING(LAST_SEARCH_TYPE));
}
searchBox->setFocus();
}
@@ -583,7 +583,7 @@
}
void SearchFrame::handlePurgeClicked() {
- searchBox->removeAllItems();
+ searchBox->clear();
lastSearches.clear();
}
@@ -623,7 +623,7 @@
}
bool SearchFrame::handleContextMenu(SmartWin::ScreenCoordinate pt) {
- if(results->getSelectedCount() > 0) {
+ if(results->countSelected() > 0) {
if(pt.x() == -1 && pt.y() == -1) {
pt = results->getContextMenuPos();
}
@@ -653,7 +653,7 @@
}
void SearchFrame::handleDownloadTo() {
- if(resul...
[truncated message content] |