From: <arn...@us...> - 2008-04-07 19:39:04
|
Revision: 1120 http://dcplusplus.svn.sourceforge.net/dcplusplus/?rev=1120&view=rev Author: arnetheduck Date: 2008-04-07 12:38:47 -0700 (Mon, 07 Apr 2008) Log Message: ----------- rename tabview Modified Paths: -------------- dcplusplus/trunk/smartwin/include/smartwin/SmartWin.h dcplusplus/trunk/smartwin/include/smartwin/WidgetFactory.h dcplusplus/trunk/smartwin/include/smartwin/forward.h dcplusplus/trunk/smartwin/include/smartwin/widgets/Composite.h dcplusplus/trunk/win32/ADLSearchFrame.cpp dcplusplus/trunk/win32/ADLSearchFrame.h dcplusplus/trunk/win32/AspectStatus.h dcplusplus/trunk/win32/DirectoryListingFrame.cpp dcplusplus/trunk/win32/DirectoryListingFrame.h dcplusplus/trunk/win32/FavHubsFrame.cpp dcplusplus/trunk/win32/FavHubsFrame.h dcplusplus/trunk/win32/FinishedDLFrame.cpp dcplusplus/trunk/win32/FinishedDLFrame.h dcplusplus/trunk/win32/FinishedFrameBase.h dcplusplus/trunk/win32/FinishedULFrame.cpp dcplusplus/trunk/win32/FinishedULFrame.h dcplusplus/trunk/win32/HubFrame.cpp dcplusplus/trunk/win32/HubFrame.h dcplusplus/trunk/win32/MDIChildFrame.h dcplusplus/trunk/win32/MainWindow.cpp dcplusplus/trunk/win32/MainWindow.h dcplusplus/trunk/win32/NotepadFrame.cpp dcplusplus/trunk/win32/NotepadFrame.h dcplusplus/trunk/win32/PrivateFrame.cpp dcplusplus/trunk/win32/PrivateFrame.h dcplusplus/trunk/win32/PublicHubsFrame.cpp dcplusplus/trunk/win32/PublicHubsFrame.h dcplusplus/trunk/win32/QueueFrame.cpp dcplusplus/trunk/win32/QueueFrame.h dcplusplus/trunk/win32/SearchFrame.cpp dcplusplus/trunk/win32/SearchFrame.h dcplusplus/trunk/win32/SpyFrame.cpp dcplusplus/trunk/win32/SpyFrame.h dcplusplus/trunk/win32/StaticFrame.h dcplusplus/trunk/win32/StatsFrame.cpp dcplusplus/trunk/win32/StatsFrame.h dcplusplus/trunk/win32/SystemFrame.cpp dcplusplus/trunk/win32/SystemFrame.h dcplusplus/trunk/win32/TextFrame.cpp dcplusplus/trunk/win32/TextFrame.h dcplusplus/trunk/win32/TransferView.cpp dcplusplus/trunk/win32/TransferView.h dcplusplus/trunk/win32/UserInfoBase.cpp dcplusplus/trunk/win32/UserInfoBase.h dcplusplus/trunk/win32/UsersFrame.cpp dcplusplus/trunk/win32/UsersFrame.h dcplusplus/trunk/win32/WaitingUsersFrame.cpp dcplusplus/trunk/win32/WaitingUsersFrame.h dcplusplus/trunk/win32/WinUtil.h dcplusplus/trunk/win32/stdafx.h Added Paths: ----------- dcplusplus/trunk/smartwin/include/smartwin/widgets/TabView.h dcplusplus/trunk/smartwin/source/widgets/TabView.cpp Removed Paths: ------------- dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetTabView.h dcplusplus/trunk/smartwin/source/widgets/WidgetTabView.cpp Property Changed: ---------------- dcplusplus/trunk/ Property changes on: dcplusplus/trunk ___________________________________________________________________ Name: bzr:revision-info - timestamp: 2008-04-02 20:12:35.286000013 +0200 committer: Jacek Sieka <arn...@gm...> properties: branch-nick: dcplusplus + timestamp: 2008-04-02 21:38:51.338000059 +0200 committer: Jacek Sieka <arn...@gm...> properties: branch-nick: dcplusplus Name: bzr:file-ids - + smartwin/include/smartwin/widgets/TabView.h 849@f586c4b0-9d0d-0410-bc51-f1fe239209fc:dcplusplus%2Ftrunk:smartwin%2Finclude%2Fsmartwin%2Fwidgets%2FWidgetTabView.h smartwin/source/widgets/TabView.cpp 849@f586c4b0-9d0d-0410-bc51-f1fe239209fc:dcplusplus%2Ftrunk:smartwin%2Fsource%2Fwidgets%2FWidgetTabView.cpp 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 1041 arn...@gm...-20080326084110-qbselrjckku275xi 1042 zouzou123gen-20080326123631-35642mgbk2i4ty32 1043 zouzou123gen-20080326124345-f4xwn2d3ty8ubd6r 1044 arn...@gm...-20080326162031-il0nyms30w0mky43 1045 arn...@gm...-20080326164801-8dru8mjc06xgzjpv 1046 arn...@gm...-20080326170438-uzl2rx8fqnohak7g 1047 zouzou123gen-20080326172821-d6uqcbmfb0c6rwlv 1048 arn...@gm...-20080326213257-qlgdh7m2712p2l0q 1049 arn...@gm...-20080326214313-ktnoekgk3s0wmatz 1050 arn...@gm...-20080326215256-0j1iqrf286b9g7zf 1051 arn...@gm...-20080327082121-hoi22wh1gwjdfbyd 1052 arn...@gm...-20080327120639-um3tukdt374rwvgm 1053 zouzou123gen-20080327130703-6vtek6uxy3vua543 1054 arn...@gm...-20080327215831-dmg5mkufskabwkro 1055 arn...@gm...-20080327231459-cdztcv25alsuyqmf 1056 arn...@gm...-20080328085925-gceybsr53oml1p24 1057 arn...@gm...-20080328200512-1sjuu6bcnl2dyd2a 1058 arn...@gm...-20080328210347-bussqjrm5mfswh7o 1059 arn...@gm...-20080329055630-braiir1dskv7a4qm 1060 arn...@gm...-20080329061558-rck8dz60wpj3c5ja 1061 arn...@gm...-20080329081253-if6o5jn329mbzfpl 1062 arn...@gm...-20080329081619-cb4x930j8sp55cs0 1063 arn...@gm...-20080329103216-hgjzo7ra2zixbztd 1064 arn...@gm...-20080329124042-q3aw4iodmo5kafyp 1065 arn...@gm...-20080329124926-2je1z18p0272zpua 1066 arn...@gm...-20080329150901-ehj9t32en7eps2dp 1067 zouzou123gen-20080329153653-36xlvpik2ns9r84r 1068 zouzou123gen-20080329162703-51xr8hg073pg7wq5 1069 zouzou123gen-20080329234706-8ddipdqu0xeudkql 1070 arn...@gm...-20080330081232-ubqr1171ewalrd4q 1071 zouzou123gen-20080330131607-yppbs3mgyjef1cux 1072 zouzou123gen-20080330134835-yv1nogy77ib1uehd 1073 zouzou123gen-20080331124549-alyw7vugdn30piqy 1074 zouzou123gen-20080331135108-q8frtqsin5bosfzm 1075 zouzou123gen-20080331140757-u94q52yccl5lsifk 1076 zouzou123gen-20080331152513-ue1x5qhigcw51348 1077 arn...@gm...-20080331184436-a8g6chibmg8nswls 1078 arn...@gm...-20080331220648-81485k28qmwruwz6 1079 zouzou123gen-20080401081001-2yjn07cf8s5sxr3a 1080 zouzou123gen-20080401081247-f3p4hdjojnd460jw 1081 zouzou123gen-20080401084117-24a454g8o0x656kg 1082 zouzou123gen-20080401133146-jabb5i8870fg6f66 1083 zouzou123gen-20080401154610-mxdqoo5bksru93e6 1084 arn...@gm...-20080401185530-lqj4tflt5ldmx46f 1085 arn...@gm...-20080401212616-ffl7m0xm8gt15knk 1086 arn...@gm...-20080402084515-ofmnwihzv159jton 1087 arn...@gm...-20080402133105-y70soi38owzl76i9 1088 arn...@gm...-20080402142417-rn2dbkx19wfz3vae 1089 arn...@gm...-20080402144459-u3z3hqvl8aqjc4a0 1090 zouzou123gen-20080402145051-zi8tmvy8u3r2mzu8 1091 arn...@gm...-20080402152137-f397uz1yp9qjvfwh 1092 zouzou123gen-20080402170355-29wda40wk3cy7lu5 1093 arn...@gm...-20080402180628-ipos9li0c4bsmq1h 1094 arn...@gm...-20080402181235-s2a6f4ww4lzayl46 + 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 1042 zouzou123gen-20080326123631-35642mgbk2i4ty32 1043 zouzou123gen-20080326124345-f4xwn2d3ty8ubd6r 1044 arn...@gm...-20080326162031-il0nyms30w0mky43 1045 arn...@gm...-20080326164801-8dru8mjc06xgzjpv 1046 arn...@gm...-20080326170438-uzl2rx8fqnohak7g 1047 zouzou123gen-20080326172821-d6uqcbmfb0c6rwlv 1048 arn...@gm...-20080326213257-qlgdh7m2712p2l0q 1049 arn...@gm...-20080326214313-ktnoekgk3s0wmatz 1050 arn...@gm...-20080326215256-0j1iqrf286b9g7zf 1051 arn...@gm...-20080327082121-hoi22wh1gwjdfbyd 1052 arn...@gm...-20080327120639-um3tukdt374rwvgm 1053 zouzou123gen-20080327130703-6vtek6uxy3vua543 1054 arn...@gm...-20080327215831-dmg5mkufskabwkro 1055 arn...@gm...-20080327231459-cdztcv25alsuyqmf 1056 arn...@gm...-20080328085925-gceybsr53oml1p24 1057 arn...@gm...-20080328200512-1sjuu6bcnl2dyd2a 1058 arn...@gm...-20080328210347-bussqjrm5mfswh7o 1059 arn...@gm...-20080329055630-braiir1dskv7a4qm 1060 arn...@gm...-20080329061558-rck8dz60wpj3c5ja 1061 arn...@gm...-20080329081253-if6o5jn329mbzfpl 1062 arn...@gm...-20080329081619-cb4x930j8sp55cs0 1063 arn...@gm...-20080329103216-hgjzo7ra2zixbztd 1064 arn...@gm...-20080329124042-q3aw4iodmo5kafyp 1065 arn...@gm...-20080329124926-2je1z18p0272zpua 1066 arn...@gm...-20080329150901-ehj9t32en7eps2dp 1067 zouzou123gen-20080329153653-36xlvpik2ns9r84r 1068 zouzou123gen-20080329162703-51xr8hg073pg7wq5 1069 zouzou123gen-20080329234706-8ddipdqu0xeudkql 1070 arn...@gm...-20080330081232-ubqr1171ewalrd4q 1071 zouzou123gen-20080330131607-yppbs3mgyjef1cux 1072 zouzou123gen-20080330134835-yv1nogy77ib1uehd 1073 zouzou123gen-20080331124549-alyw7vugdn30piqy 1074 zouzou123gen-20080331135108-q8frtqsin5bosfzm 1075 zouzou123gen-20080331140757-u94q52yccl5lsifk 1076 zouzou123gen-20080331152513-ue1x5qhigcw51348 1077 arn...@gm...-20080331184436-a8g6chibmg8nswls 1078 arn...@gm...-20080331220648-81485k28qmwruwz6 1079 zouzou123gen-20080401081001-2yjn07cf8s5sxr3a 1080 zouzou123gen-20080401081247-f3p4hdjojnd460jw 1081 zouzou123gen-20080401084117-24a454g8o0x656kg 1082 zouzou123gen-20080401133146-jabb5i8870fg6f66 1083 zouzou123gen-20080401154610-mxdqoo5bksru93e6 1084 arn...@gm...-20080401185530-lqj4tflt5ldmx46f 1085 arn...@gm...-20080401212616-ffl7m0xm8gt15knk 1086 arn...@gm...-20080402084515-ofmnwihzv159jton 1087 arn...@gm...-20080402133105-y70soi38owzl76i9 1088 arn...@gm...-20080402142417-rn2dbkx19wfz3vae 1089 arn...@gm...-20080402144459-u3z3hqvl8aqjc4a0 1090 zouzou123gen-20080402145051-zi8tmvy8u3r2mzu8 1091 arn...@gm...-20080402152137-f397uz1yp9qjvfwh 1092 zouzou123gen-20080402170355-29wda40wk3cy7lu5 1093 arn...@gm...-20080402180628-ipos9li0c4bsmq1h 1094 arn...@gm...-20080402181235-s2a6f4ww4lzayl46 1095 arn...@gm...-20080402193851-6mu64vgep6tijith Modified: dcplusplus/trunk/smartwin/include/smartwin/SmartWin.h =================================================================== --- dcplusplus/trunk/smartwin/include/smartwin/SmartWin.h 2008-04-07 19:35:01 UTC (rev 1119) +++ dcplusplus/trunk/smartwin/include/smartwin/SmartWin.h 2008-04-07 19:38:47 UTC (rev 1120) @@ -80,8 +80,10 @@ #include "widgets/Spinner.h" #include "widgets/Table.h" #include "widgets/TabSheet.h" +#include "widgets/TabView.h" #include "widgets/Tree.h" #include "widgets/ToolBar.h" +#include "widgets/ToolTip.h" #include "widgets/Window.h" namespace sw = SmartWin; Modified: dcplusplus/trunk/smartwin/include/smartwin/WidgetFactory.h =================================================================== --- dcplusplus/trunk/smartwin/include/smartwin/WidgetFactory.h 2008-04-07 19:35:01 UTC (rev 1119) +++ dcplusplus/trunk/smartwin/include/smartwin/WidgetFactory.h 2008-04-07 19:38:47 UTC (rev 1120) @@ -37,9 +37,7 @@ #include "widgets/LoadDialog.h" #include "widgets/SaveDialog.h" #include "widgets/StatusBar.h" -#include "widgets/WidgetTabView.h" #include "widgets/TextBox.h" -#include "widgets/ToolTip.h" #include "WidgetFactoryPlatformImplementation.h" #include "WidgetCreator.h" @@ -107,12 +105,6 @@ /// StatusBarSections object type. typedef typename StatusBarSections::ObjectType StatusBarSectionsPtr; - /// TabView class type. - typedef SmartWin::WidgetTabView WidgetTabView; - - /// TabView object type. - typedef typename WidgetTabView::ObjectType WidgetTabViewPtr; - /// LoadFileDialog class type. typedef SmartWin::LoadDialog LoadDialog; @@ -128,10 +120,6 @@ /// CheckBox object type. typedef typename CheckBox::ObjectType CheckBoxPtr; - typedef SmartWin::ToolTip ToolTip; - - typedef typename ToolTip::ObjectType ToolTipPtr; - /// Default Constructor creating a factory Widget /** Default Constructor creating a factory Widget without a parent, if you need * to explicitly state a parent like for instance you often would want in a @@ -207,19 +195,12 @@ */ ButtonPtr createButton( const typename Button::Seed & cs = Button::Seed() ); - /// Creates a Tab View and returns a pointer to it. - /** DON'T delete the returned pointer!!! - */ - WidgetTabViewPtr createTabView( const typename WidgetTabView::Seed& cs = WidgetTabView::Seed() ); - /// \ingroup SubclassDialog /// Subclasses a Button Control from the given resource id. /** DON'T delete the returned pointer!!!< br > * Use e.g. the Dialog Designer to design a dialog and attach the controls with this function. */ ButtonPtr attachButton( unsigned id ); - - ToolTipPtr createToolTip( const typename ToolTip::Seed & cs = ToolTip::Seed() ); protected: // Protected to try to avoid stack creation... virtual ~WidgetFactory() @@ -320,26 +301,12 @@ } template<typename ContainerWidgetType> -typename WidgetFactory< ContainerWidgetType >::WidgetTabViewPtr -WidgetFactory< ContainerWidgetType >::createTabView( const typename WidgetTabView::Seed & cs ) -{ - return WidgetCreator< WidgetTabView >::create( this, cs ); -} - -template<typename ContainerWidgetType> typename WidgetFactory< ContainerWidgetType >::ButtonPtr WidgetFactory< ContainerWidgetType >::attachButton( unsigned id ) { return WidgetCreator< Button >::attach( this, id ); } -template<typename ContainerWidgetType> -typename WidgetFactory< ContainerWidgetType >::ToolTipPtr -WidgetFactory< ContainerWidgetType >::createToolTip( const typename ToolTip::Seed & cs ) -{ - return WidgetCreator< ToolTip >::create( this, cs ); -} - // end namespace SmartWin } Modified: dcplusplus/trunk/smartwin/include/smartwin/forward.h =================================================================== --- dcplusplus/trunk/smartwin/include/smartwin/forward.h 2008-04-07 19:35:01 UTC (rev 1119) +++ dcplusplus/trunk/smartwin/include/smartwin/forward.h 2008-04-07 19:38:47 UTC (rev 1120) @@ -57,9 +57,15 @@ class TabSheet; typedef TabSheet* TabSheetPtr; +class TabView; +typedef TabView* TabViewPtr; + class ToolBar; typedef ToolBar* ToolBarPtr; +class ToolTip; +typedef ToolTip* ToolTipPtr; + class Tree; typedef Tree* TreePtr; Modified: dcplusplus/trunk/smartwin/include/smartwin/widgets/Composite.h =================================================================== --- dcplusplus/trunk/smartwin/include/smartwin/widgets/Composite.h 2008-04-07 19:35:01 UTC (rev 1119) +++ dcplusplus/trunk/smartwin/include/smartwin/widgets/Composite.h 2008-04-07 19:38:47 UTC (rev 1120) @@ -72,6 +72,8 @@ typedef SmartWin::TabSheetPtr TabSheetPtr; typedef SmartWin::ToolBar ToolBar; typedef SmartWin::ToolBarPtr ToolBarPtr; + typedef SmartWin::ToolTip ToolTip; + typedef SmartWin::ToolTipPtr ToolTipPtr; typedef SmartWin::Tree Tree; typedef SmartWin::TreePtr TreePtr; Copied: dcplusplus/trunk/smartwin/include/smartwin/widgets/TabView.h (from rev 1119, dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetTabView.h) =================================================================== --- dcplusplus/trunk/smartwin/include/smartwin/widgets/TabView.h (rev 0) +++ dcplusplus/trunk/smartwin/include/smartwin/widgets/TabView.h 2008-04-07 19:38:47 UTC (rev 1120) @@ -0,0 +1,142 @@ +#ifndef WIDGETTABVIEW_H_ +#define WIDGETTABVIEW_H_ + +#include "../WindowClass.h" +#include "../Policies.h" +#include "../aspects/AspectRaw.h" +#include "../aspects/AspectSizable.h" +#include "../aspects/AspectMouse.h" +#include <list> +#include <vector> + +namespace SmartWin { +/** + * A container that keeps widgets in tabs and handles switching etc + */ +class TabView : + public MessageMap< Policies::Normal >, + + public AspectRaw<TabView>, + public AspectSizable<TabView> +{ + typedef std::tr1::function<void (const SmartUtil::tstring&)> TitleChangedFunction; + typedef std::tr1::function<void (HWND, unsigned)> HelpFunction; + typedef std::tr1::function<bool (const ScreenCoordinate&)> ContextMenuFunction; + +public: + /// Class type + typedef TabView ThisType; + + /// Object type + typedef ThisType* ObjectType; + + typedef MessageMap<Policies::Normal> BaseType; + + struct Seed : public BaseType::Seed { + typedef ThisType WidgetType; + + bool toggleActive; + + /// Fills with default parameters + Seed(bool toggleActive_ = false); + }; + + void add(ContainerPtr w, const IconPtr& icon); + + void mark(ContainerPtr w); + + void remove(ContainerPtr w); + + void next(bool reverse = false); + + ContainerPtr getActive(); + void setActive(ContainerPtr w) { setActive(findTab(w)); } + + SmartUtil::tstring getTabText(ContainerPtr w); + + void onTitleChanged(const TitleChangedFunction& f) { + titleChangedFunction = f; + } + + void onTabContextMenu(ContainerPtr w, const ContextMenuFunction& f); + + void onHelp(const HelpFunction& f) { + helpFunction = f; + } + + bool filter(const MSG& msg); + + TabSheetPtr getTab(); + + const Rectangle& getClientSize() const { return clientSize; } + + void create( const Seed & cs = Seed() ); + +protected: + friend class WidgetCreator<TabView>; + + explicit TabView(Widget* parent); + + virtual ~TabView() { } + +private: + enum { MAX_TITLE_LENGTH = 20 }; + + struct TabInfo { + TabInfo(ContainerPtr w_) : w(w_) { } + ContainerPtr w; + ContextMenuFunction handleContextMenu; + }; + + static WindowClass windowClass; + + TabSheetPtr tab; + ToolTipPtr tip; + + TitleChangedFunction titleChangedFunction; + HelpFunction helpFunction; + + bool toggleActive; + + bool inTab; + + typedef std::list<ContainerPtr> WindowList; + typedef WindowList::iterator WindowIter; + WindowList viewOrder; + Rectangle clientSize; + std::vector<IconPtr> icons; + int active; + ContainerPtr dragging; + SmartUtil::tstring tipText; + + int findTab(ContainerPtr w); + + void setActive(int i); + TabInfo* getTabInfo(ContainerPtr w); + TabInfo* getTabInfo(int i); + + void setTop(ContainerPtr w); + + bool handleTextChanging(ContainerPtr w, const SmartUtil::tstring& newText); + void handleSized(const SizedEvent&); + void handleTabSelected(); + LRESULT handleToolTip(LPARAM lParam); + void handleLeftMouseDown(const MouseEventResult& mouseEventResult); + void handleLeftMouseUp(const MouseEventResult& mouseEventResult); + bool handleContextMenu(SmartWin::ScreenCoordinate pt); + void handleMiddleMouseDown(const MouseEventResult& mouseEventResult); + void handleHelp(HWND hWnd, unsigned id); + + SmartUtil::tstring formatTitle(SmartUtil::tstring title); + void layout(); + + int addIcon(const IconPtr& icon); + void swapWidgets(ContainerPtr oldW, ContainerPtr newW); +}; + +inline TabSheetPtr TabView::getTab() { + return tab; +} + +} +#endif /*WIDGETTABVIEW_H_*/ Deleted: dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetTabView.h =================================================================== --- dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetTabView.h 2008-04-07 19:35:01 UTC (rev 1119) +++ dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetTabView.h 2008-04-07 19:38:47 UTC (rev 1120) @@ -1,142 +0,0 @@ -#ifndef WIDGETTABVIEW_H_ -#define WIDGETTABVIEW_H_ - -#include "TabSheet.h" -#include "ToolTip.h" -#include "Container.h" -#include "../WindowClass.h" -#include <list> -#include <vector> - -namespace SmartWin { -/** - * A container that keeps widgets in tabs and handles switching etc - */ -class WidgetTabView : - public MessageMap< Policies::Normal >, - - public AspectRaw<WidgetTabView>, - public AspectSizable<WidgetTabView> -{ - typedef std::tr1::function<void (const SmartUtil::tstring&)> TitleChangedFunction; - typedef std::tr1::function<void (HWND, unsigned)> HelpFunction; - typedef std::tr1::function<bool (const ScreenCoordinate&)> ContextMenuFunction; - -public: - /// Class type - typedef WidgetTabView ThisType; - - /// Object type - typedef ThisType * ObjectType; - - typedef MessageMap<Policies::Normal> BaseType; - - struct Seed : public BaseType::Seed { - typedef ThisType WidgetType; - - bool toggleActive; - - /// Fills with default parameters - Seed(bool toggleActive_ = false); - }; - - void add(Container* w, const IconPtr& icon); - - void mark(Container* w); - - void remove(Container* w); - - void next(bool reverse = false); - - Container* getActive(); - void setActive(Container* w) { setActive(findTab(w)); } - - SmartUtil::tstring getTabText(Container* w); - - void onTitleChanged(const TitleChangedFunction& f) { - titleChangedFunction = f; - } - - void onTabContextMenu(Container* w, const ContextMenuFunction& f); - - void onHelp(const HelpFunction& f) { - helpFunction = f; - } - - bool filter(const MSG& msg); - - TabSheet::ObjectType getTab(); - - const Rectangle& getClientSize() const { return clientSize; } - - void create( const Seed & cs = Seed() ); - -protected: - friend class WidgetCreator<WidgetTabView>; - - explicit WidgetTabView(Widget* parent); - - virtual ~WidgetTabView() { } - -private: - enum { MAX_TITLE_LENGTH = 20 }; - - struct TabInfo { - TabInfo(Container* w_) : w(w_) { } - Container* w; - ContextMenuFunction handleContextMenu; - }; - - static WindowClass windowClass; - - TabSheet::ObjectType tab; - ToolTip::ObjectType tip; - - TitleChangedFunction titleChangedFunction; - HelpFunction helpFunction; - - bool toggleActive; - - bool inTab; - - typedef std::list<Container*> WindowList; - typedef WindowList::iterator WindowIter; - WindowList viewOrder; - Rectangle clientSize; - std::vector<IconPtr> icons; - int active; - Container* dragging; - SmartUtil::tstring tipText; - - int findTab(Container* w); - - void setActive(int i); - TabInfo* getTabInfo(Container* w); - TabInfo* getTabInfo(int i); - - void setTop(Container* w); - - bool handleTextChanging(Container* w, const SmartUtil::tstring& newText); - void handleSized(const SizedEvent&); - void handleTabSelected(); - LRESULT handleToolTip(LPARAM lParam); - void handleLeftMouseDown(const MouseEventResult& mouseEventResult); - void handleLeftMouseUp(const MouseEventResult& mouseEventResult); - bool handleContextMenu(SmartWin::ScreenCoordinate pt); - void handleMiddleMouseDown(const MouseEventResult& mouseEventResult); - void handleHelp(HWND hWnd, unsigned id); - - SmartUtil::tstring formatTitle(SmartUtil::tstring title); - void layout(); - - int addIcon(const IconPtr& icon); - void swapWidgets(Container* oldW, Container* newW); -}; - -inline TabSheet::ObjectType WidgetTabView::getTab() -{ - return tab; -} - -} -#endif /*WIDGETTABVIEW_H_*/ Copied: dcplusplus/trunk/smartwin/source/widgets/TabView.cpp (from rev 1119, dcplusplus/trunk/smartwin/source/widgets/WidgetTabView.cpp) =================================================================== --- dcplusplus/trunk/smartwin/source/widgets/TabView.cpp (rev 0) +++ dcplusplus/trunk/smartwin/source/widgets/TabView.cpp 2008-04-07 19:38:47 UTC (rev 1120) @@ -0,0 +1,416 @@ +#include "../../include/smartwin/widgets/TabView.h" + +#include "../../include/smartwin/widgets/Container.h" +#include "../../include/smartwin/widgets/ToolTip.h" +#include "../../include/smartwin/widgets/TabSheet.h" +#include "../../include/smartwin/WidgetCreator.h" + +namespace SmartWin { + +WindowClass TabView::windowClass(_T("TabView"), &TabView::wndProc, NULL, ( HBRUSH )( COLOR_WINDOW + 1 )); + +TabView::Seed::Seed(bool toggleActive_) : + BaseType::Seed(windowClass.getClassName(), WS_CHILD | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_VISIBLE), + toggleActive(toggleActive_) +{ +} + +TabView::TabView(Widget* w) : + BaseType(w), + tab(0), + tip(0), + toggleActive(false), + inTab(false), + active(-1), + dragging(0) + { } + +void TabView::create(const Seed & cs) { + PolicyType::create(cs); + toggleActive = cs.toggleActive; + + TabSheet::Seed tcs; + tcs.style = WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_VISIBLE | + TCS_HOTTRACK | TCS_MULTILINE | TCS_RAGGEDRIGHT | TCS_TOOLTIPS | TCS_FOCUSNEVER; + tab = WidgetCreator<TabSheet>::create(this, tcs); + tab->setImageList(ImageListPtr(new ImageList(16, 16, ILC_COLOR32 | ILC_MASK))); + tab->onSelectionChanged(std::tr1::bind(&TabView::handleTabSelected, this)); + onSized(std::tr1::bind(&TabView::handleSized, this, _1)); + tab->onLeftMouseDown(std::tr1::bind(&TabView::handleLeftMouseDown, this, _1)); + tab->onLeftMouseUp(std::tr1::bind(&TabView::handleLeftMouseUp, this, _1)); + tab->onContextMenu(std::tr1::bind(&TabView::handleContextMenu, this, _1)); + tab->onMiddleMouseDown(std::tr1::bind(&TabView::handleMiddleMouseDown, this, _1)); + tab->onHelp(std::tr1::bind(&TabView::handleHelp, this, _1, _2)); + + tip = WidgetCreator<ToolTip>::attach(this, tab->getToolTips()); // created and managed by the tab control thanks to the TCS_TOOLTIPS style + if(tip) { + tip->addRemoveStyle(TTS_NOPREFIX, true); + tip->onRaw(std::tr1::bind(&TabView::handleToolTip, this, _2), Message(WM_NOTIFY, TTN_GETDISPINFO)); + } +} + +void TabView::add(Container* w, const IconPtr& icon) { + int image = addIcon(icon); + size_t tabs = tab->size(); + TabInfo* ti = new TabInfo(w); + tab->addPage(formatTitle(w->getText()), tabs, reinterpret_cast<LPARAM>(ti), image); + + viewOrder.push_front(w); + + if(viewOrder.size() == 1 || w->getVisible()) { + if(viewOrder.size() > 1) { + swapWidgets(viewOrder.back(), w); + } else { + swapWidgets(0, w); + } + setActive(tabs); + } + + layout(); + + w->onTextChanging(std::tr1::bind(&TabView::handleTextChanging, this, w, _1)); +} + +Container* TabView::getActive() { + TabInfo* ti = getTabInfo(tab->getSelected()); + return ti ? ti->w : 0; +} + +void TabView::remove(Container* w) { + if(viewOrder.size() > 1 && viewOrder.back() == w) { + setActive(*(--(--viewOrder.end()))); + } + + Container* cur = getTabInfo(tab->getSelected())->w; + + viewOrder.remove(w); + + if(w == dragging) + dragging = 0; + + int i = findTab(w); + if(i != -1) { + delete getTabInfo(i); + tab->erase(i); + layout(); + } + active = findTab(cur); + + // when no tab is opened + if(titleChangedFunction && (active == -1)) + titleChangedFunction(SmartUtil::tstring()); +} + +SmartUtil::tstring TabView::getTabText(Container* w) { + int i = findTab(w); + if(i != -1) + return tab->getText(i); + return SmartUtil::tstring(); +} + +void TabView::onTabContextMenu(Container* w, const ContextMenuFunction& f) { + TabInfo* ti = getTabInfo(w); + if(ti) { + ti->handleContextMenu = f; + } +} + +void TabView::setActive(int i) { + if(i == -1) + return; + + tab->setSelected(i); + handleTabSelected(); +} + +void TabView::swapWidgets(Container* oldW, Container* newW) { + sendMessage(WM_SETREDRAW, FALSE); + + if(oldW) { + oldW->sendMessage(WM_ACTIVATE, WA_INACTIVE, reinterpret_cast<LPARAM>(newW->handle())); + ::ShowWindow(oldW->handle(), SW_HIDE); + } + + ::ShowWindow(newW->handle(), SW_SHOW); + ::MoveWindow(newW->handle(), clientSize.x(), clientSize.y(), clientSize.width(), clientSize.height(), FALSE); + + newW->sendMessage(WM_ACTIVATE, WA_ACTIVE, oldW ? reinterpret_cast<LPARAM>(oldW->handle()) : 0); + sendMessage(WM_SETREDRAW, TRUE); + ::RedrawWindow(handle(), NULL, NULL, RDW_FRAME | RDW_INVALIDATE | RDW_UPDATENOW | RDW_ALLCHILDREN); + +} + +void TabView::handleTabSelected() { + int i = tab->getSelected(); + if(i == active) { + return; + } + + TabInfo* old = getTabInfo(active); + + TabInfo* ti = getTabInfo(i); + + if(ti == old) + return; + + swapWidgets(old ? old->w : 0, ti->w); + + if(!inTab) + setTop(ti->w); + active = i; + tab->setHighlight(i, false); + + if(titleChangedFunction) + titleChangedFunction(ti->w->getText()); +} + +void TabView::mark(Container* w) { + int i = findTab(w); + if(i != -1 && i != tab->getSelected()) { + tab->setHighlight(i, true); + } +} + +int TabView::findTab(Container* w) { + for(size_t i = 0; i < tab->size(); ++i) { + if(getTabInfo(i)->w == w) { + return static_cast<int>(i); + } + } + return -1; +} + +TabView::TabInfo* TabView::getTabInfo(Container* w) { + return getTabInfo(findTab(w)); +} + +TabView::TabInfo* TabView::getTabInfo(int i) { + return i == -1 ? 0 : reinterpret_cast<TabInfo*>(tab->getData(i)); +} + +bool TabView::handleTextChanging(Container* w, const SmartUtil::tstring& newText) { + int i = findTab(w); + if(i != -1) { + tab->setText(i, formatTitle(newText)); + layout(); + + if((i == active) && titleChangedFunction) + titleChangedFunction(newText); + } + return true; +} + +SmartUtil::tstring TabView::formatTitle(SmartUtil::tstring title) { + if(title.length() > MAX_TITLE_LENGTH) + title = title.substr(0, MAX_TITLE_LENGTH - 3) + _T("..."); + return SmartUtil::escapeMenu(title); +} + +void TabView::handleSized(const SizedEvent& sz) { + tab->setBounds(Rectangle(sz.size)); + layout(); +} + +void TabView::layout() { + Rectangle tmp = tab->getUsableArea(true); + if(!(tmp == clientSize)) { + int i = tab->getSelected(); + if(i != -1) { + ::MoveWindow(getTabInfo(i)->w->handle(), tmp.x(), tmp.y(), tmp.width(), tmp.height(), TRUE); + } + clientSize = tmp; + } +} + +void TabView::next(bool reverse) { + if(viewOrder.size() < 2) { + return; + } + Container* wnd = getActive(); + if(!wnd) { + return; + } + + WindowIter i; + if(inTab) { + i = std::find(viewOrder.begin(), viewOrder.end(), wnd); + if(i == viewOrder.end()) { + return; + } + + if(!reverse) { + if(i == viewOrder.begin()) { + i = viewOrder.end(); + } + --i; + } else { + if(++i == viewOrder.end()) { + i = viewOrder.begin(); + } + ++i; + } + } else { + if(!reverse) { + i = --(--viewOrder.end()); + } else { + i = ++viewOrder.begin(); + } + } + + setActive(*i); + return; +} + +void TabView::setTop(Container* wnd) { + WindowIter i = std::find(viewOrder.begin(), viewOrder.end(), wnd); + if(i != viewOrder.end() && i != --viewOrder.end()) { + viewOrder.erase(i); + viewOrder.push_back(wnd); + } +} + +int TabView::addIcon(const IconPtr& icon) { + int image = -1; + if(icon) { + for(size_t i = 0; i < icons.size(); ++i) { + if(icon == icons[i]) { + image = i; + break; + } + } + if(image == -1) { + image = icons.size(); + icons.push_back(icon); + tab->getImageList()->add(*icon); + } + } + return image; +} + +LRESULT TabView::handleToolTip(LPARAM lParam) { + LPNMTTDISPINFO ttdi = reinterpret_cast<LPNMTTDISPINFO>(lParam); + TabInfo* ti = getTabInfo(ttdi->hdr.idFrom); // here idFrom corresponds to the index of the tab + if(ti) { + tipText = ti->w->getText(); + ttdi->lpszText = const_cast<LPTSTR>(tipText.c_str()); + } + return 0; +} + +void TabView::handleLeftMouseDown(const MouseEventResult& mouseEventResult) { + TabInfo* ti = getTabInfo(tab->hitTest(mouseEventResult.pos)); + if(ti) { + if(mouseEventResult.isShiftPressed) + ti->w->close(); + else { + dragging = ti->w; + ::SetCapture(tab->handle()); + } + } +} + +void TabView::handleLeftMouseUp(const MouseEventResult& mouseEventResult) { + ::ReleaseCapture(); + + if(dragging) { + int dragPos = findTab(dragging); + dragging = 0; + + if(dragPos == -1) + return; + + int dropPos = tab->hitTest(mouseEventResult.pos); + + if(dropPos == -1) { + // not in the tab control; move the tab to the end + dropPos = tab->size() - 1; + } + + if(dropPos == dragPos) { + // the tab hasn't moved; handle the click + if(dropPos == active) { + if(toggleActive) + next(); + } else + setActive(dropPos); + return; + } + + // save some information about the tab before we erase it + TabInfo* ti = getTabInfo(dragPos); + int image = tab->getImage(dragPos); + + tab->erase(dragPos); + + tab->addPage(formatTitle(ti->w->getText()), dropPos, reinterpret_cast<LPARAM>(ti), image); + + active = tab->getSelected(); + + layout(); + } +} + +bool TabView::handleContextMenu(ScreenCoordinate pt) { + TabInfo* ti = 0; + if(pt.x() == -1 && pt.y() == -1) { + int i = tab->getSelected(); + + RECT rc; + if(i == -1 || !TabCtrl_GetItemRect(tab->handle(), i, &rc)) { + return false; + } + pt = ScreenCoordinate(Point(rc.left, rc.top)); + ti = getTabInfo(i); + } else { + int i = tab->hitTest(pt); + if(i == -1) { + return false; + } + ti = getTabInfo(i); + } + + if(ti->handleContextMenu && ti->handleContextMenu(pt)) { + return true; + } + + return false; +} + +void TabView::handleMiddleMouseDown(const MouseEventResult& mouseEventResult) { + TabInfo* ti = getTabInfo(tab->hitTest(mouseEventResult.pos)); + if(ti) + ti->w->close(); +} + +void TabView::handleHelp(HWND hWnd, unsigned id) { + if(helpFunction) { + // hWnd and id are those of the whole tab control; not those of the specific tab on which the user wants help for + TabInfo* ti = getTabInfo(tab->hitTest(ScreenCoordinate(Point::fromLParam(::GetMessagePos())))); + if(ti) + id = ti->w->getHelpId(); + + // even if no tab was found below the cursor, forward the message to the application so that it can display its default help + helpFunction(hWnd, id); + } +} + +bool TabView::filter(const MSG& msg) { + if(tip) + tip->relayEvent(msg); + + if(msg.message == WM_KEYUP && msg.wParam == VK_CONTROL) { + inTab = false; + + TabInfo* ti = getTabInfo(tab->getSelected()); + if(ti) { + setTop(ti->w); + } + } else if(msg.message == WM_KEYDOWN && msg.wParam == VK_TAB && ::GetKeyState(VK_CONTROL) < 0) { + inTab = true; + next(::GetKeyState(VK_SHIFT) < 0); + return true; + } + return false; +} + +} Deleted: dcplusplus/trunk/smartwin/source/widgets/WidgetTabView.cpp =================================================================== --- dcplusplus/trunk/smartwin/source/widgets/WidgetTabView.cpp 2008-04-07 19:35:01 UTC (rev 1119) +++ dcplusplus/trunk/smartwin/source/widgets/WidgetTabView.cpp 2008-04-07 19:38:47 UTC (rev 1120) @@ -1,412 +0,0 @@ -#include "../../include/smartwin/widgets/WidgetTabView.h" -#include "../../include/smartwin/WidgetCreator.h" - -namespace SmartWin { - -WindowClass WidgetTabView::windowClass(_T("WidgetTabView"), &WidgetTabView::wndProc, NULL, ( HBRUSH )( COLOR_WINDOW + 1 )); - -WidgetTabView::Seed::Seed(bool toggleActive_) : - BaseType::Seed(windowClass.getClassName(), WS_CHILD | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_VISIBLE), - toggleActive(toggleActive_) -{ -} - -WidgetTabView::WidgetTabView(Widget* w) : - BaseType(w), - tab(0), - tip(0), - toggleActive(false), - inTab(false), - active(-1), - dragging(0) - { } - -void WidgetTabView::create(const Seed & cs) { - PolicyType::create(cs); - toggleActive = cs.toggleActive; - - TabSheet::Seed tcs; - tcs.style = WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_VISIBLE | - TCS_HOTTRACK | TCS_MULTILINE | TCS_RAGGEDRIGHT | TCS_TOOLTIPS | TCS_FOCUSNEVER; - tab = WidgetCreator<TabSheet>::create(this, tcs); - tab->setImageList(ImageListPtr(new ImageList(16, 16, ILC_COLOR32 | ILC_MASK))); - tab->onSelectionChanged(std::tr1::bind(&WidgetTabView::handleTabSelected, this)); - onSized(std::tr1::bind(&WidgetTabView::handleSized, this, _1)); - tab->onLeftMouseDown(std::tr1::bind(&WidgetTabView::handleLeftMouseDown, this, _1)); - tab->onLeftMouseUp(std::tr1::bind(&WidgetTabView::handleLeftMouseUp, this, _1)); - tab->onContextMenu(std::tr1::bind(&WidgetTabView::handleContextMenu, this, _1)); - tab->onMiddleMouseDown(std::tr1::bind(&WidgetTabView::handleMiddleMouseDown, this, _1)); - tab->onHelp(std::tr1::bind(&WidgetTabView::handleHelp, this, _1, _2)); - - tip = WidgetCreator<ToolTip>::attach(this, tab->getToolTips()); // created and managed by the tab control thanks to the TCS_TOOLTIPS style - if(tip) { - tip->addRemoveStyle(TTS_NOPREFIX, true); - tip->onRaw(std::tr1::bind(&WidgetTabView::handleToolTip, this, _2), Message(WM_NOTIFY, TTN_GETDISPINFO)); - } -} - -void WidgetTabView::add(Container* w, const IconPtr& icon) { - int image = addIcon(icon); - size_t tabs = tab->size(); - TabInfo* ti = new TabInfo(w); - tab->addPage(formatTitle(w->getText()), tabs, reinterpret_cast<LPARAM>(ti), image); - - viewOrder.push_front(w); - - if(viewOrder.size() == 1 || w->getVisible()) { - if(viewOrder.size() > 1) { - swapWidgets(viewOrder.back(), w); - } else { - swapWidgets(0, w); - } - setActive(tabs); - } - - layout(); - - w->onTextChanging(std::tr1::bind(&WidgetTabView::handleTextChanging, this, w, _1)); -} - -Container* WidgetTabView::getActive() { - TabInfo* ti = getTabInfo(tab->getSelected()); - return ti ? ti->w : 0; -} - -void WidgetTabView::remove(Container* w) { - if(viewOrder.size() > 1 && viewOrder.back() == w) { - setActive(*(--(--viewOrder.end()))); - } - - Container* cur = getTabInfo(tab->getSelected())->w; - - viewOrder.remove(w); - - if(w == dragging) - dragging = 0; - - int i = findTab(w); - if(i != -1) { - delete getTabInfo(i); - tab->erase(i); - layout(); - } - active = findTab(cur); - - // when no tab is opened - if(titleChangedFunction && (active == -1)) - titleChangedFunction(SmartUtil::tstring()); -} - -SmartUtil::tstring WidgetTabView::getTabText(Container* w) { - int i = findTab(w); - if(i != -1) - return tab->getText(i); - return SmartUtil::tstring(); -} - -void WidgetTabView::onTabContextMenu(Container* w, const ContextMenuFunction& f) { - TabInfo* ti = getTabInfo(w); - if(ti) { - ti->handleContextMenu = f; - } -} - -void WidgetTabView::setActive(int i) { - if(i == -1) - return; - - tab->setSelected(i); - handleTabSelected(); -} - -void WidgetTabView::swapWidgets(Container* oldW, Container* newW) { - sendMessage(WM_SETREDRAW, FALSE); - - if(oldW) { - oldW->sendMessage(WM_ACTIVATE, WA_INACTIVE, reinterpret_cast<LPARAM>(newW->handle())); - ::ShowWindow(oldW->handle(), SW_HIDE); - } - - ::ShowWindow(newW->handle(), SW_SHOW); - ::MoveWindow(newW->handle(), clientSize.x(), clientSize.y(), clientSize.width(), clientSize.height(), FALSE); - - newW->sendMessage(WM_ACTIVATE, WA_ACTIVE, oldW ? reinterpret_cast<LPARAM>(oldW->handle()) : 0); - sendMessage(WM_SETREDRAW, TRUE); - ::RedrawWindow(handle(), NULL, NULL, RDW_FRAME | RDW_INVALIDATE | RDW_UPDATENOW | RDW_ALLCHILDREN); - -} - -void WidgetTabView::handleTabSelected() { - int i = tab->getSelected(); - if(i == active) { - return; - } - - TabInfo* old = getTabInfo(active); - - TabInfo* ti = getTabInfo(i); - - if(ti == old) - return; - - swapWidgets(old ? old->w : 0, ti->w); - - if(!inTab) - setTop(ti->w); - active = i; - tab->setHighlight(i, false); - - if(titleChangedFunction) - titleChangedFunction(ti->w->getText()); -} - -void WidgetTabView::mark(Container* w) { - int i = findTab(w); - if(i != -1 && i != tab->getSelected()) { - tab->setHighlight(i, true); - } -} - -int WidgetTabView::findTab(Container* w) { - for(size_t i = 0; i < tab->size(); ++i) { - if(getTabInfo(i)->w == w) { - return static_cast<int>(i); - } - } - return -1; -} - -WidgetTabView::TabInfo* WidgetTabView::getTabInfo(Container* w) { - return getTabInfo(findTab(w)); -} - -WidgetTabView::TabInfo* WidgetTabView::getTabInfo(int i) { - return i == -1 ? 0 : reinterpret_cast<TabInfo*>(tab->getData(i)); -} - -bool WidgetTabView::handleTextChanging(Container* w, const SmartUtil::tstring& newText) { - int i = findTab(w); - if(i != -1) { - tab->setText(i, formatTitle(newText)); - layout(); - - if((i == active) && titleChangedFunction) - titleChangedFunction(newText); - } - return true; -} - -SmartUtil::tstring WidgetTabView::formatTitle(SmartUtil::tstring title) { - if(title.length() > MAX_TITLE_LENGTH) - title = title.substr(0, MAX_TITLE_LENGTH - 3) + _T("..."); - return SmartUtil::escapeMenu(title); -} - -void WidgetTabView::handleSized(const SizedEvent& sz) { - tab->setBounds(Rectangle(sz.size)); - layout(); -} - -void WidgetTabView::layout() { - Rectangle tmp = tab->getUsableArea(true); - if(!(tmp == clientSize)) { - int i = tab->getSelected(); - if(i != -1) { - ::MoveWindow(getTabInfo(i)->w->handle(), tmp.x(), tmp.y(), tmp.width(), tmp.height(), TRUE); - } - clientSize = tmp; - } -} - -void WidgetTabView::next(bool reverse) { - if(viewOrder.size() < 2) { - return; - } - Container* wnd = getActive(); - if(!wnd) { - return; - } - - WindowIter i; - if(inTab) { - i = std::find(viewOrder.begin(), viewOrder.end(), wnd); - if(i == viewOrder.end()) { - return; - } - - if(!reverse) { - if(i == viewOrder.begin()) { - i = viewOrder.end(); - } - --i; - } else { - if(++i == viewOrder.end()) { - i = viewOrder.begin(); - } - ++i; - } - } else { - if(!reverse) { - i = --(--viewOrder.end()); - } else { - i = ++viewOrder.begin(); - } - } - - setActive(*i); - return; -} - -void WidgetTabView::setTop(Container* wnd) { - WindowIter i = std::find(viewOrder.begin(), viewOrder.end(), wnd); - if(i != viewOrder.end() && i != --viewOrder.end()) { - viewOrder.erase(i); - viewOrder.push_back(wnd); - } -} - -int WidgetTabView::addIcon(const IconPtr& icon) { - int image = -1; - if(icon) { - for(size_t i = 0; i < icons.size(); ++i) { - if(icon == icons[i]) { - image = i; - break; - } - } - if(image == -1) { - image = icons.size(); - icons.push_back(icon); - tab->getImageList()->add(*icon); - } - } - return image; -} - -LRESULT WidgetTabView::handleToolTip(LPARAM lParam) { - LPNMTTDISPINFO ttdi = reinterpret_cast<LPNMTTDISPINFO>(lParam); - TabInfo* ti = getTabInfo(ttdi->hdr.idFrom); // here idFrom corresponds to the index of the tab - if(ti) { - tipText = ti->w->getText(); - ttdi->lpszText = const_cast<LPTSTR>(tipText.c_str()); - } - return 0; -} - -void WidgetTabView::handleLeftMouseDown(const MouseEventResult& mouseEventResult) { - TabInfo* ti = getTabInfo(tab->hitTest(mouseEventResult.pos)); - if(ti) { - if(mouseEventResult.isShiftPressed) - ti->w->close(); - else { - dragging = ti->w; - ::SetCapture(tab->handle()); - } - } -} - -void WidgetTabView::handleLeftMouseUp(const MouseEventResult& mouseEventResult) { - ::ReleaseCapture(); - - if(dragging) { - int dragPos = findTab(dragging); - dragging = 0; - - if(dragPos == -1) - return; - - int dropPos = tab->hitTest(mouseEventResult.pos); - - if(dropPos == -1) { - // not in the tab control; move the tab to the end - dropPos = tab->size() - 1; - } - - if(dropPos == dragPos) { - // the tab hasn't moved; handle the click - if(dropPos == active) { - if(toggleActive) - next(); - } else - setActive(dropPos); - return; - } - - // save some information about the tab before we erase it - TabInfo* ti = getTabInfo(dragPos); - int image = tab->getImage(dragPos); - - tab->erase(dragPos); - - tab->addPage(formatTitle(ti->w->getText()), dropPos, reinterpret_cast<LPARAM>(ti), image); - - active = tab->getSelected(); - - layout(); - } -} - -bool WidgetTabView::handleContextMenu(ScreenCoordinate pt) { - TabInfo* ti = 0; - if(pt.x() == -1 && pt.y() == -1) { - int i = tab->getSelected(); - - RECT rc; - if(i == -1 || !TabCtrl_GetItemRect(tab->handle(), i, &rc)) { - return false; - } - pt = ScreenCoordinate(Point(rc.left, rc.top)); - ti = getTabInfo(i); - } else { - int i = tab->hitTest(pt); - if(i == -1) { - return false; - } - ti = getTabInfo(i); - } - - if(ti->handleContextMenu && ti->handleContextMenu(pt)) { - return true; - } - - return false; -} - -void WidgetTabView::handleMiddleMouseDown(const MouseEventResult& mouseEventResult) { - TabInfo* ti = getTabInfo(tab->hitTest(mouseEventResult.pos)); - if(ti) - ti->w->close(); -} - -void WidgetTabView::handleHelp(HWND hWnd, unsigned id) { - if(helpFunction) { - // hWnd and id are those of the whole tab control; not those of the specific tab on which the user wants help for - TabInfo* ti = getTabInfo(tab->hitTest(ScreenCoordinate(Point::fromLParam(::GetMessagePos())))); - if(ti) - id = ti->w->getHelpId(); - - // even if no tab was found below the cursor, forward the message to the application so that it can display its default help - helpFunction(hWnd, id); - } -} - -bool WidgetTabView::filter(const MSG& msg) { - if(tip) - tip->relayEvent(msg); - - if(msg.message == WM_KEYUP && msg.wParam == VK_CONTROL) { - inTab = false; - - TabInfo* ti = getTabInfo(tab->getSelected()); - if(ti) { - setTop(ti->w); - } - } else if(msg.message == WM_KEYDOWN && msg.wParam == VK_TAB && ::GetKeyState(VK_CONTROL) < 0) { - inTab = true; - next(::GetKeyState(VK_SHIFT) < 0); - return true; - } - return false; -} - -} Modified: dcplusplus/trunk/win32/ADLSearchFrame.cpp =================================================================== --- dcplusplus/trunk/win32/ADLSearchFrame.cpp 2008-04-07 19:35:01 UTC (rev 1119) +++ dcplusplus/trunk/win32/ADLSearchFrame.cpp 2008-04-07 19:38:47 UTC (rev 1120) @@ -36,7 +36,7 @@ N_("Max Size") }; -ADLSearchFrame::ADLSearchFrame(SmartWin::WidgetTabView* mdiParent) : +ADLSearchFrame::ADLSearchFrame(SmartWin::TabView* mdiParent) : BaseType(mdiParent, T_("Automatic Directory Listing Search"), IDH_ADL_SEARCH, IDR_ADLSEARCH), add(0), properties(0), Modified: dcplusplus/trunk/win32/ADLSearchFrame.h =================================================================== --- dcplusplus/trunk/win32/ADLSearchFrame.h 2008-04-07 19:35:01 UTC (rev 1119) +++ dcplusplus/trunk/win32/ADLSearchFrame.h 2008-04-07 19:38:47 UTC (rev 1120) @@ -34,7 +34,7 @@ friend class StaticFrame<ADLSearchFrame>; friend class MDIChildFrame<ADLSearchFrame>; - ADLSearchFrame(SmartWin::WidgetTabView* mdiParent); + ADLSearchFrame(SmartWin::TabView* mdiParent); virtual ~ADLSearchFrame(); void layout(); Modified: dcplusplus/trunk/win32/AspectStatus.h =================================================================== --- dcplusplus/trunk/win32/AspectStatus.h 2008-04-07 19:35:01 UTC (rev 1119) +++ dcplusplus/trunk/win32/AspectStatus.h 2008-04-07 19:38:47 UTC (rev 1120) @@ -92,7 +92,7 @@ private: SmartWin::Application::FilterIter filterIter; - typename SmartWin::ToolTip::ObjectType statusTip; + SmartWin::ToolTipPtr statusTip; TStringList lastLines; tstring tip; Modified: dcplusplus/trunk/win32/DirectoryListingFrame.cpp =================================================================== --- dcplusplus/trunk/win32/DirectoryListingFrame.cpp 2008-04-07 19:35:01 UTC (rev 1119) +++ dcplusplus/trunk/win32/DirectoryListingFrame.cpp 2008-04-07 19:38:47 UTC (rev 1120) @@ -76,7 +76,7 @@ } } -void DirectoryListingFrame::openWindow(SmartWin::WidgetTabView* mdiParent, const tstring& aFile, const tstring& aDir, const UserPtr& aUser, int64_t aSpeed) { +void DirectoryListingFrame::openWindow(SmartWin::TabView* mdiParent, const tstring& aFile, const tstring& aDir, const UserPtr& aUser, int64_t aSpeed) { UserIter i = lists.find(aUser); if(i != lists.end()) { i->second->speed = aSpeed; @@ -94,7 +94,7 @@ ::PostMessage(i->second->handle(), WM_CLOSE, 0, 0); } -void DirectoryListingFrame::openWindow(SmartWin::WidgetTabView* mdiParent, const UserPtr& aUser, const string& txt, int64_t aSpeed) { +void DirectoryListingFrame::openWindow(SmartWin::TabView* mdiParent, const UserPtr& aUser, const string& txt, int64_t aSpeed) { UserIter i = lists.find(aUser); if(i != lists.end()) { i->second->speed = aSpeed; @@ -105,7 +105,7 @@ } } -DirectoryListingFrame::DirectoryListingFrame(SmartWin::WidgetTabView* mdiParent, const UserPtr& aUser, int64_t aSpeed) : +DirectoryListingFrame::DirectoryListingFrame(SmartWin::TabView* mdiParent, const UserPtr& aUser, int64_t aSpeed) : BaseType(mdiParent, _T(""), IDH_FILE_LIST, SmartWin::IconPtr(new SmartWin::Icon(IDR_DIRECTORY)), !BOOLSETTING(POPUNDER_FILELIST)), dirs(0), files(0), Modified: dcplusplus/trunk/win32/DirectoryListingFrame.h =================================================================== --- dcplusplus/trunk/win32/DirectoryListingFrame.h 2008-04-07 19:35:01 UTC (rev 1119) +++ dcplusplus/trunk/win32/DirectoryListingFrame.h 2008-04-07 19:38:47 UTC (rev 1120) @@ -48,8 +48,8 @@ STATUS_LAST }; - static void openWindow(SmartWin::WidgetTabView* mdiParent, const tstring& aFile, const tstring& aDir, const UserPtr& aUser, int64_t aSpeed); - static void openWindow(SmartWin::WidgetTabView* mdiParent, const UserPtr& aUser, const string& txt, int64_t aSpeed); + static void openWindow(SmartWin::TabView* mdiParent, const tstring& aFile, const tstring& aDir, const UserPtr& aUser, int64_t aSpeed); + static void openWindow(SmartWin::TabView* mdiParent, const UserPtr& aUser, const string& txt, int64_t aSpeed); static void closeAll(); protected: @@ -171,7 +171,7 @@ static UserMap lists; - DirectoryListingFrame(SmartWin::WidgetTabView* mdiParent, const UserPtr& aUser, int64_t aSpeed); + DirectoryListingFrame(SmartWin::TabView* mdiParent, const UserPtr& aUser, int64_t aSpeed); virtual ~DirectoryListingFrame(); WidgetMenuPtr makeSingleMenu(ItemInfo* ii); Modified: dcplusplus/trunk/win32/FavHubsFrame.cpp =================================================================== --- dcplusplus/trunk/win32/FavHubsFrame.cpp 2008-04-07 19:35:01 UTC (rev 1119) +++ dcplusplus/trunk/win32/FavHubsFrame.cpp 2008-04-07 19:38:47 UTC (rev 1120) @@ -37,7 +37,7 @@ N_("User Description") }; -FavHubsFrame::FavHubsFrame(SmartWin::WidgetTabView* mdiParent) : +FavHubsFrame::FavHubsFrame(SmartWin::TabView* mdiParent) : BaseType(mdiParent, T_("Favorite Hubs"), IDH_FAVORITE_HUBS, IDR_FAVORITES), hubs(0), connect(0), Modified: dcplusplus/trunk/win32/FavHubsFrame.h =================================================================== --- dcplusplus/trunk/win32/FavHubsFrame.h 2008-04-07 19:35:01 UTC (rev 1119) +++ dcplusplus/trunk/win32/FavHubsFrame.h 2008-04-07 19:38:47 UTC (rev 1120) @@ -39,7 +39,7 @@ friend class StaticFrame<FavHubsFrame>; friend class MDIChildFrame<FavHubsFrame>; - FavHubsFrame(SmartWin::WidgetTabView* mdiParent); + FavHubsFrame(SmartWin::TabView* mdiParent); virtual ~FavHubsFrame(); void layout(); Modified: dcplusplus/trunk/win32/FinishedDLFrame.cpp =================================================================== --- dcplusplus/trunk/win32/FinishedDLFrame.cpp 2008-04-07 19:35:01 UTC (rev 1119) +++ dcplusplus/trunk/win32/FinishedDLFrame.cpp 2008-04-07 19:38:47 UTC (rev 1120) @@ -21,7 +21,7 @@ #include "FinishedDLFrame.h" -FinishedDLFrame::FinishedDLFrame(SmartWin::WidgetTabView* mdiParent) : +FinishedDLFrame::FinishedDLFrame(SmartWin::TabView* mdiParent) : BaseType(mdiParent, T_("Finished Downloads"), IDH_FINISHED_DL, IDR_FINISHED_DL) { } Modified: dcplusplus/trunk/win32/FinishedDLFrame.h =================================================================== --- dcplusplus/trunk/win32/FinishedDLFrame.h 2008-04-07 19:35:01 UTC (rev 1119) +++ dcplusplus/trunk/win32/FinishedDLFrame.h 2008-04-07 19:38:47 UTC (rev 1120) @@ -25,7 +25,7 @@ class FinishedDLFrame : public FinishedFrameBase<FinishedDLFrame, false> { public: - FinishedDLFrame(SmartWin::WidgetTabView* mdiParent); + FinishedDLFrame(SmartWin::TabView* mdiParent); virtual ~FinishedDLFrame() { } typedef FinishedFrameBase<FinishedDLFrame, false> BaseType; Modified: dcplusplus/trunk/win32/FinishedFrameBase.h =================================================================== --- dcplusplus/trunk/win32/FinishedFrameBase.h 2008-04-07 19:35:01 UTC (rev 1119) +++ dcplusplus/trunk/win32/FinishedFrameBase.h 2008-04-07 19:38:47 UTC (rev 1120) @@ -47,7 +47,7 @@ friend class MDIChildFrame<T>; typedef FinishedFrameBase<T, in_UL> ThisType; - FinishedFrameBase(SmartWin::WidgetTabView* mdiParent, const tstring& title, unsigned helpId, int icon) : + FinishedFrameBase(SmartWin::TabView* mdiParent, const tstring& title, unsigned helpId, int icon) : BaseType(mdiParent, title, helpId, icon), items(0), totalBytes(0), Modified: dcplusplus/trunk/win32/FinishedULFrame.cpp =================================================================== --- dcplusplus/trunk/win32/FinishedULFrame.cpp 2008-04-07 19:35:01 UTC (rev 1119) +++ dcplusplus/trunk/win32/FinishedULFrame.cpp 2008-04-07 19:38:47 UTC (rev 1120) @@ -21,7 +21,7 @@ #include "FinishedULFrame.h" -FinishedULFrame::FinishedULFrame(SmartWin::WidgetTabView* mdiParent) : +FinishedULFrame::FinishedULFrame(SmartWin::TabView* mdiParent) : BaseType(mdiParent, T_("Finished Uploads"), IDH_FINISHED_UL, IDR_FINISHED_UL) { } Modified: dcplusplus/trunk/win32/FinishedULFrame.h =================================================================== --- dcplusplus/trunk/win32/FinishedULFrame.h 2008-04-07 19:35:01 UTC (rev 1119) +++ dcplusplus/trunk/win32/FinishedULFrame.h 2008-04-07 19:38:47 UTC (rev 1120) @@ -25,7 +25,7 @@ class FinishedULFrame : public FinishedFrameBase<FinishedULFrame, true> { public: - FinishedULFrame(SmartWin::WidgetTabView* mdiParent); + FinishedULFrame(SmartWin::TabView* mdiParent); virtual ~FinishedULFrame() { } typedef FinishedFrameBase<FinishedULFrame, true> BaseType; Modified: dcplusplus/trunk/win32/HubFrame.cpp =================================================================== --- dcplusplus/trunk/win32/HubFrame.cpp 2008-04-07 19:35:01 UTC (rev 1119) +++ dcplusplus/trunk/win32/HubFrame.cpp 2008-04-07 19:38:47 UTC (rev 1120) @@ -55,7 +55,7 @@ } } -void HubFrame::openWindow(SmartWin::WidgetTabView* mdiParent, const string& url) { +void HubFrame::openWindow(SmartWin::TabView* mdiParent, const string& url) { for(FrameIter i = frames.begin(); i!= frames.end(); ++i) { HubFrame* frame = *i; if(frame->url == url) { @@ -67,7 +67,7 @@ new HubFrame(mdiParent, url); } -HubFrame::HubFrame(SmartWin::WidgetTabView* mdiParent, const string& url_) : +HubFrame::HubFrame(SmartWin::TabView* mdiParent, const string& url_) : BaseType(mdiParent, Text::toT(url_), IDH_HUB, SmartWin::IconPtr(new SmartWin::Icon(IDR_HUB))), chat(0), message(0), Modified: dcplusplus/trunk/win32/HubFrame.h =================================================================== --- dcplusplus/trunk/win32/HubFrame.h 2008-04-07 19:35:01 UTC (rev 1119) +++ dcplusplus/trunk/win32/HubFrame.h 2008-04-07 19:38:47 UTC (rev 1120) @@ -52,7 +52,7 @@ STATUS_LAST }; - static void openWindow(SmartWin::WidgetTabView* mdiParent, const string& url); + static void openWindow(SmartWin::TabView* mdiParent, const string& url); static void closeDisconnected(); static void resortUsers(); @@ -192,7 +192,7 @@ typedef FrameList::iterator FrameIter; static FrameList frames; - HubFrame(SmartWin::WidgetTabView* mdiParent, const string& url); + HubFrame(SmartWin::TabView* mdiParent, const string& url); virtual ~HubFrame(); void layout(); Modified: dcplusplus/trunk/win32/MDIChildFrame.h =================================================================== --- dcplusplus/trunk/win32/MDIChildFrame.h 2008-04-07 19:35:01 UTC (rev 1119) +++ dcplusplus/trunk/win32/MDIChildFrame.h 2008-04-07 19:38:47 UTC (rev 1120) @@ -38,7 +38,7 @@ typedef WidgetFactory< SmartWin::Container > BaseType; protected: - MDIChildFrame(SmartWin::WidgetTabView* tabView, const tstring& title, unsigned helpId = 0, SmartWin::IconPtr icon = SmartWin::IconPtr(), bool activate = true) : + MDIChildFrame(SmartWin::TabView* tabView, const tstring& title, unsigned helpId = 0, SmartWin::IconPtr icon = SmartWin::IconPtr(), bool activate = true) : BaseType(tabView->getTab()), lastFocus(NULL), alwaysSameFocus(false), @@ -122,8 +122,8 @@ getParent()->setActive(this); } - SmartWin::WidgetTabView* getParent() { - return static_cast<SmartWin::WidgetTabView*>(BaseType::getParent()->getParent()); + SmartWin::TabView* getParent() { + return static_cast<SmartWin::TabView*>(BaseType::getParent()->getParent()); } private: Modified: dcplusplus/trunk/win32/MainWindow.cpp =================================================================== --- dcplusplus/trunk/win32/MainWindow.cpp 2008-04-07 19:35:01 UTC (rev 1119) +++ dcplusplus/trunk/win32/MainWindow.cpp 2008-04-07 19:38:47 UTC (rev 1120) @@ -315,7 +315,7 @@ void MainWindow::initTabs() { dcdebug("initTabs\n"); - tabs = addChild(WidgetTabView::Seed(BOOLSETTING(TOGGLE_ACTIVE_WINDOW))); + tabs = addChild(SmartWin::TabView::Seed(BOOLSETTING(TOGGLE_ACTIVE_WINDOW))); tabs->onTitleChanged(std::tr1::bind(&MainWindow::handleTabsTitleChanged, this, _1)); tabs->onHelp(std::tr1::bind(&WinUtil::help, _1, _2)); paned->setFirst(tabs); Modified: dcplusplus/trunk/win32/MainWindow.h =================================================================== --- dcplusplus/trunk/win32/MainWindow.h 2008-04-07 19:35:01 UTC (rev 1119) +++ dcplusplus/trunk/win32/MainWindow.h 2008-04-07 19:38:47 UTC (rev 1120) @@ -55,7 +55,7 @@ STATUS_LAST }; - WidgetTabView* getTabView() { return tabs; } + SmartWin::TabViewPtr getTabView() { return tabs; } virtual bool tryFire( const MSG & msg, LRESULT & retVal ); @@ -105,7 +105,7 @@ WidgetMenuPtr mainMenu; TransferView* transfers; ToolBarPtr toolbar; - WidgetTabViewPtr tabs; + SmartWin::TabViewPtr tabs; /** Is the tray icon visible? */ bool trayIcon; Modified: dcplusplus/trunk/win32/NotepadFrame.cpp =================================================================== --- dcplusplus/trunk/win32/NotepadFrame.cpp 2008-04-07 19:35:01 UTC (rev 1119) +++ dcplusplus/trunk/win32/NotepadFrame.cpp 2008-04-07 19:38:47 UTC (rev 1120) @@ -23,7 +23,7 @@ #include <dcpp/File.h> #include <dcpp/Text.h> -NotepadFrame::NotepadFrame(SmartWin::WidgetTabView* mdiParent) : +NotepadFrame::NotepadFrame(SmartWin::TabView* mdiParent) : BaseType(mdiParent, T_("Notepad"), IDH_NOTEPAD, IDR_NOTEPAD), pad(0) { Modified: dcplusplus/trunk/win32/NotepadFrame.h =================================================================== --- dcplusplus/trunk/win32/NotepadFrame.h 2008-04-07 19:35:01 UTC (rev 1119) +++ dcplusplus/trunk/win32/NotepadFrame.h 2008-04-07 19:38:47 UTC (rev 1120) @@ -34,7 +34,7 @@ friend class StaticFrame<NotepadFrame>; friend class MDIChildFrame<NotepadFrame>; - NotepadFrame(SmartWin::WidgetTabView* mdiParent); + NotepadFrame(SmartWin::TabView* mdiParent); virtual ~NotepadFrame(); void layout(); Modified: dcplusplus/trunk/win32/PrivateFrame.cpp =================================================================== --- dcplusplus/trunk/win32/PrivateFrame.cpp 2008-04-07 19:35:01 UTC (rev 1119) +++ dcplusplus/trunk/win32/PrivateFrame.cpp 2008-04-07 19:38:47 UTC (rev 1120) @@ -35,7 +35,7 @@ PrivateFrame::FrameMap PrivateFrame::frames; -void PrivateFrame::openWindow(SmartWin::WidgetTabView* mdiParent, const UserPtr& replyTo_, const tstring& msg) { +void PrivateFrame::openWindow(SmartWin::TabView* mdiParent, const UserPtr& replyTo_, const tstring& msg) { PrivateFrame* pf = 0; FrameIter i = frames.find(replyTo_); if(i == frames.end()) { @@ -49,7 +49,7 @@ } -void PrivateFrame::gotMessage(SmartWin::WidgetTabView* mdiParent, const UserPtr& from, const UserPtr& to, const UserPtr& replyTo, const tstring& aMessage) { +void PrivateFrame::gotMessage(SmartWin::TabView* mdiParent, const UserPtr& from, const UserPtr& to, const UserPtr& replyTo, const tstring& aMessage) { PrivateFrame* p = 0; const UserPtr& user = (replyTo == ClientManager::getInstance()->getMe()) ? to : replyTo; @@ -91,7 +91,7 @@ } } -PrivateFrame::PrivateFrame(SmartWin::WidgetTabView* mdiParent, const UserPtr& replyTo_, bool activate) : +PrivateFrame::PrivateFrame(SmartWin::TabView* mdiParent, const UserPtr& replyTo_, bool activate) : BaseType(mdiParent, _T(""), IDH_PM, SmartWin::IconPtr(new SmartWin::Icon(IDR_PRIVATE)), activate), chat(0), message(0), Modified: dcplusplus/trunk/win32/PrivateFrame.h =================================================================== --- dcplusplus/trunk/win32/PrivateFrame.h 2008-04-07 19:35:01 UTC (rev 1119) +++ dcplusplus/trunk/win32/PrivateFrame.h 2008-04-07 19:38:47 UTC (rev 1120) @@ -36,8 +36,8 @@ STATUS_LAST }; - static void gotMessage(SmartWin::WidgetTabView* mdiPare... [truncated message content] |