From: <arn...@us...> - 2008-04-14 20:38:28
|
Revision: 1160 http://dcplusplus.svn.sourceforge.net/dcplusplus/?rev=1160&view=rev Author: arnetheduck Date: 2008-04-14 13:38:17 -0700 (Mon, 14 Apr 2008) Log Message: ----------- Rename widgetmenu Modified Paths: -------------- dcplusplus/trunk/dwt/include/dwt/WidgetFactoryPlatformSmartWinDesktop.h dcplusplus/trunk/dwt/include/dwt/doxygen.h dcplusplus/trunk/dwt/include/dwt/forward.h dcplusplus/trunk/win32/ADLSearchFrame.cpp dcplusplus/trunk/win32/DirectoryListingFrame.cpp dcplusplus/trunk/win32/DirectoryListingFrame.h dcplusplus/trunk/win32/FavHubsFrame.cpp dcplusplus/trunk/win32/FinishedFrameBase.h dcplusplus/trunk/win32/HubFrame.cpp dcplusplus/trunk/win32/MDIChildFrame.h dcplusplus/trunk/win32/MainWindow.cpp dcplusplus/trunk/win32/MainWindow.h dcplusplus/trunk/win32/PrivateFrame.cpp dcplusplus/trunk/win32/PublicHubsFrame.cpp dcplusplus/trunk/win32/QueueFrame.cpp dcplusplus/trunk/win32/QueueFrame.h dcplusplus/trunk/win32/SearchFrame.cpp dcplusplus/trunk/win32/SearchFrame.h dcplusplus/trunk/win32/ShellContextMenu.cpp dcplusplus/trunk/win32/ShellContextMenu.h dcplusplus/trunk/win32/SpyFrame.cpp dcplusplus/trunk/win32/TextBox.cpp dcplusplus/trunk/win32/TextBox.h dcplusplus/trunk/win32/TransferView.cpp dcplusplus/trunk/win32/TransferView.h dcplusplus/trunk/win32/UsersFrame.cpp dcplusplus/trunk/win32/WaitingUsersFrame.cpp dcplusplus/trunk/win32/WinUtil.cpp dcplusplus/trunk/win32/WinUtil.h Added Paths: ----------- dcplusplus/trunk/dwt/include/dwt/widgets/Menu.h dcplusplus/trunk/dwt/src/widgets/Menu.cpp Removed Paths: ------------- dcplusplus/trunk/dwt/include/dwt/widgets/WidgetMenu.h dcplusplus/trunk/dwt/src/widgets/WidgetMenu.cpp Property Changed: ---------------- dcplusplus/trunk/ Property changes on: dcplusplus/trunk ___________________________________________________________________ Name: bzr:revision-info - timestamp: 2008-04-11 22:40:47.565000057 +0200 committer: Jacek Sieka <arn...@gm...> properties: branch-nick: dcplusplus + timestamp: 2008-04-11 22:54:45.322000027 +0200 committer: Jacek Sieka <arn...@gm...> properties: branch-nick: dcplusplus Name: bzr:file-ids - + dwt/include/dwt/widgets/Menu.h 1003@f586c4b0-9d0d-0410-bc51-f1fe239209fc:dcplusplus%2Ftrunk:smartwin%2Finclude%2Fsmartwin%2Fwidgets%2FWidgetMenu.h dwt/src/widgets/Menu.cpp 1003@f586c4b0-9d0d-0410-bc51-f1fe239209fc:dcplusplus%2Ftrunk:smartwin%2Fsource%2Fwidgets%2FWidgetMenu.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 1095 arn...@gm...-20080402193851-6mu64vgep6tijith 1096 arn...@gm...-20080402203810-86zpxsx69q83zf3r 1097 arn...@gm...-20080402204331-so2e8n892o23pejr 1098 poy-20080402224153-225qylr2cfwhqrg7 1099 mrmikejj-20080403125112-o8polh8rkn62umyh 1100 arn...@gm...-20080403125139-8xub76j1xazhfxna 1101 po...@12...-20080403140544-13kockkjho883nb4 1102 po...@12...-20080403143012-bxghtoodiolugpbs 1103 arn...@gm...-20080403190809-bbi4bz5rfcvjnt20 1104 arn...@gm...-20080403205410-czxru1vcg1s4wcws 1105 arn...@gm...-20080403213124-54spdrwszgyimd90 1106 po...@12...-20080404002406-aj74x5tngi6mmmj1 1107 arn...@gm...-20080404122415-mjy07qzbaxyhagra 1108 po...@12...-20080404145445-84lyk5tyy3b3br14 1109 po...@12...-20080404231417-v4v8x7u3f0hm0ejc 1110 po...@12...-20080405001107-14d1ojjof8xhvcj8 1111 arn...@gm...-20080405071929-jmnrul21sxx04kky 1112 arn...@gm...-20080405080105-9qbda7be0pi7y1ai 1113 po...@12...-20080405154555-yuj2n5kyndfjlpsf 1114 po...@12...-20080405220250-8y09d0samsj8ja94 1115 po...@12...-20080406134101-4860ytb61sbu3yhg 1116 po...@12...-20080406155849-2wzxzuzs5m8zpk0g 1117 po...@12...-20080406164835-bv5dydhm3qqydsty 1118 arn...@gm...-20080406210237-c7tyfgiz2sjgv044 1119 po...@12...-20080407114423-4yajg1rffidq76bj 1120 arn...@gm...-20080407194826-c42t4bjzw4vflejn 1121 po...@12...-20080407214303-o7ul1bvcn6gvaoc9 1122 po...@12...-20080407220647-r7f3em92til5j67s 1123 po...@12...-20080408212439-54t3bqlhvw1nu4xc 1124 arn...@gm...-20080409193708-y6erfzwrcb1seet3 1125 arn...@gm...-20080409195827-ub6t2s3wdf28nfpz 1126 po...@12...-20080409215055-1zmqhhm2859878c1 1127 arn...@gm...-20080410102447-l4es4cbukkqwcnpc 1128 arn...@gm...-20080410214118-b70g50tl27cq9q29 1129 arn...@gm...-20080411074730-w1pu78qigtx87lx3 1130 arn...@gm...-20080411090724-kwdj9pg9hrv1xhwb 1131 po...@12...-20080411153057-tn7zhxqk0z7ceref 1132 arn...@gm...-20080411200946-ierqlg8v9vzj18n2 1133 arn...@gm...-20080411201718-ecshulwd7ic0wdci 1134 arn...@gm...-20080411204047-jc9vzcsf32j38dvc + 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 1096 arn...@gm...-20080402203810-86zpxsx69q83zf3r 1097 arn...@gm...-20080402204331-so2e8n892o23pejr 1098 poy-20080402224153-225qylr2cfwhqrg7 1099 mrmikejj-20080403125112-o8polh8rkn62umyh 1100 arn...@gm...-20080403125139-8xub76j1xazhfxna 1101 po...@12...-20080403140544-13kockkjho883nb4 1102 po...@12...-20080403143012-bxghtoodiolugpbs 1103 arn...@gm...-20080403190809-bbi4bz5rfcvjnt20 1104 arn...@gm...-20080403205410-czxru1vcg1s4wcws 1105 arn...@gm...-20080403213124-54spdrwszgyimd90 1106 po...@12...-20080404002406-aj74x5tngi6mmmj1 1107 arn...@gm...-20080404122415-mjy07qzbaxyhagra 1108 po...@12...-20080404145445-84lyk5tyy3b3br14 1109 po...@12...-20080404231417-v4v8x7u3f0hm0ejc 1110 po...@12...-20080405001107-14d1ojjof8xhvcj8 1111 arn...@gm...-20080405071929-jmnrul21sxx04kky 1112 arn...@gm...-20080405080105-9qbda7be0pi7y1ai 1113 po...@12...-20080405154555-yuj2n5kyndfjlpsf 1114 po...@12...-20080405220250-8y09d0samsj8ja94 1115 po...@12...-20080406134101-4860ytb61sbu3yhg 1116 po...@12...-20080406155849-2wzxzuzs5m8zpk0g 1117 po...@12...-20080406164835-bv5dydhm3qqydsty 1118 arn...@gm...-20080406210237-c7tyfgiz2sjgv044 1119 po...@12...-20080407114423-4yajg1rffidq76bj 1120 arn...@gm...-20080407194826-c42t4bjzw4vflejn 1121 po...@12...-20080407214303-o7ul1bvcn6gvaoc9 1122 po...@12...-20080407220647-r7f3em92til5j67s 1123 po...@12...-20080408212439-54t3bqlhvw1nu4xc 1124 arn...@gm...-20080409193708-y6erfzwrcb1seet3 1125 arn...@gm...-20080409195827-ub6t2s3wdf28nfpz 1126 po...@12...-20080409215055-1zmqhhm2859878c1 1127 arn...@gm...-20080410102447-l4es4cbukkqwcnpc 1128 arn...@gm...-20080410214118-b70g50tl27cq9q29 1129 arn...@gm...-20080411074730-w1pu78qigtx87lx3 1130 arn...@gm...-20080411090724-kwdj9pg9hrv1xhwb 1131 po...@12...-20080411153057-tn7zhxqk0z7ceref 1132 arn...@gm...-20080411200946-ierqlg8v9vzj18n2 1133 arn...@gm...-20080411201718-ecshulwd7ic0wdci 1134 arn...@gm...-20080411204047-jc9vzcsf32j38dvc 1135 arn...@gm...-20080411205445-ojuz2a29yq8ww37j Modified: dcplusplus/trunk/dwt/include/dwt/WidgetFactoryPlatformSmartWinDesktop.h =================================================================== --- dcplusplus/trunk/dwt/include/dwt/WidgetFactoryPlatformSmartWinDesktop.h 2008-04-14 20:35:32 UTC (rev 1159) +++ dcplusplus/trunk/dwt/include/dwt/WidgetFactoryPlatformSmartWinDesktop.h 2008-04-14 20:38:17 UTC (rev 1160) @@ -39,7 +39,7 @@ #include "WidgetFactoryPlatformCommon.h" #include "widgets/FontDialog.h" -#include "widgets/WidgetMenu.h" +#include "widgets/Menu.h" #include "WidgetCreator.h" namespace dwt { @@ -54,10 +54,10 @@ { public: /// Menu class type. - typedef dwt::WidgetMenu WidgetMenu; + typedef dwt::Menu Menu; /// Menu object type. - typedef typename WidgetMenu::ObjectType WidgetMenuPtr; + typedef typename Menu::ObjectType MenuPtr; /// ChooseFont class and object type. typedef dwt::FontDialog FontDialog; @@ -78,18 +78,18 @@ } /// Creates a Menu - /** The returned object is of type std::tr1::shared_ptr< WidgetMenu >, but - * you should use the typedef WidgetMenuPtr and not <br> + /** The returned object is of type std::tr1::shared_ptr< Menu >, but + * you should use the typedef MenuPtr and not <br> * the shared_ptr itself since this may change in future releases. */ - WidgetMenuPtr createMenu(const typename WidgetMenu::Seed& cs = WidgetMenu::Seed()) + MenuPtr createMenu(const typename Menu::Seed& cs = Menu::Seed()) { - return WidgetCreator< WidgetMenu >::create( this, cs ); + return WidgetCreator< Menu >::create( this, cs ); } - WidgetMenuPtr attachMenu(HMENU hMenu, const typename WidgetMenu::Seed& cs = WidgetMenu::Seed()) + MenuPtr attachMenu(HMENU hMenu, const typename Menu::Seed& cs = Menu::Seed()) { - return WidgetCreator< WidgetMenu >::attach( this, cs, hMenu ); + return WidgetCreator< Menu >::attach( this, cs, hMenu ); } }; Modified: dcplusplus/trunk/dwt/include/dwt/doxygen.h =================================================================== --- dcplusplus/trunk/dwt/include/dwt/doxygen.h 2008-04-14 20:35:32 UTC (rev 1159) +++ dcplusplus/trunk/dwt/include/dwt/doxygen.h 2008-04-14 20:38:17 UTC (rev 1160) @@ -100,7 +100,7 @@ * \EventHandlerGenericInfo */ -/** \defgroup EventHandlersWidgetMenu Event Handlers for WidgetMenu +/** \defgroup EventHandlersMenu Event Handlers for Menu * \EventHandlerGenericInfo */ Modified: dcplusplus/trunk/dwt/include/dwt/forward.h =================================================================== --- dcplusplus/trunk/dwt/include/dwt/forward.h 2008-04-14 20:35:32 UTC (rev 1159) +++ dcplusplus/trunk/dwt/include/dwt/forward.h 2008-04-14 20:38:17 UTC (rev 1160) @@ -32,6 +32,10 @@ #ifndef DWT_FORWARD_H_ #define DWT_FORWARD_H_ +namespace std { namespace tr1 { +template<class T> class shared_ptr; +} } + namespace dwt { template< class WidgetType > @@ -61,6 +65,9 @@ class Label; typedef Label* LabelPtr; +class Menu; +typedef std::tr1::shared_ptr<Menu> MenuPtr; + class MDIChild; typedef MDIChild* MDIChildPtr; Copied: dcplusplus/trunk/dwt/include/dwt/widgets/Menu.h (from rev 1159, dcplusplus/trunk/dwt/include/dwt/widgets/WidgetMenu.h) =================================================================== --- dcplusplus/trunk/dwt/include/dwt/widgets/Menu.h (rev 0) +++ dcplusplus/trunk/dwt/include/dwt/widgets/Menu.h 2008-04-14 20:38:17 UTC (rev 1160) @@ -0,0 +1,518 @@ +/* + DC++ Widget Toolkit + + Copyright (c) 2007-2008, Jacek Sieka + + SmartWin++ + + Copyright (c) 2005 Thomas Hansen + + All rights reserved. + + Redistribution and use in source and binary forms, with or without modification, + are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of the DWT nor SmartWin++ nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef WINCE +#ifndef DWT_Menu_h +#define DWT_Menu_h + +#include "../resources/Bitmap.h" +#include "../resources/Font.h" +#include "../Dispatchers.h" +#include "../CanvasClasses.h" + +#include <memory> +#include <vector> +#include <map> + +namespace dwt { + +/// Contains information about menu item +struct MenuItemData +{ + /// Menu item text color + COLORREF TextColor; + + /// Menu item image + BitmapPtr Image; + + /// Creates new menu item with specified data + MenuItemData( + BitmapPtr image = BitmapPtr( new Bitmap( ( HBITMAP ) NULL ) ), // defaults to empty bitmap + COLORREF textColor = ::GetSysColor( COLOR_MENUTEXT ) ) + : TextColor( textColor ), + Image( image ) + {} +}; + +/// \ingroup GlobalStuff +// MenuItemDataPtr type, contains rendering data for e.g. Menu +/** Helps easily create color values and so on for a Menu item! <br> +* Each Menu Item can have different colors and so on, use this smart pointer to set +* those values! +*/ +typedef std::tr1::shared_ptr< MenuItemData > MenuItemDataPtr; + +/// Struct for coloring different areas of Menu +/** Contains the different color settings of the Menu <br> +* Default values to constructor makes menu look roughly like MSVC++7.1 menus +*/ +struct MenuColorInfo +{ + /// Menu color + COLORREF colorMenu; + + /// Strip bar color + COLORREF colorStrip; + + /// Highlighted menu item color + COLORREF colorHighlight; + + /// Text of highlighted menu item color + COLORREF colorHighlightText; + + /// Title text color + COLORREF colorTitleText; + + /// Item image background color, used for transparency effects + COLORREF colorImageBackground; + + /// Constructs MenuColorInfo objects + /** If all the default arguments are used it will construct an object making + * menus look roughly like they do in MSVC++ 7.1 <br> + * Pass your own arguments to construct other color effects + */ + MenuColorInfo( COLORREF menuColor = ColorUtilities::darkenColor( ::GetSysColor( COLOR_WINDOW ), 0.02 ), + COLORREF stripColor = ColorUtilities::darkenColor( ::GetSysColor( COLOR_3DFACE ), 0.02 ), + COLORREF highlightColor = ::GetSysColor( COLOR_HIGHLIGHT ), + COLORREF highlightTextColor = ::GetSysColor( COLOR_HIGHLIGHTTEXT ), + COLORREF titleTextColor = ::GetSysColor( COLOR_MENUTEXT ), + COLORREF imageBackground = RGB( 0, 0, 0 ) ) // black + : colorMenu( menuColor ), + colorStrip( stripColor ), + colorHighlight( highlightColor ), + colorHighlightText( highlightTextColor ), + colorTitleText( titleTextColor ), + colorImageBackground( imageBackground ) + {} +}; + +/// Menu class +/** \ingroup WidgetControls +* \WidgetUsageInfo +* \image html menu.png +* Class for creating a Menu Control which then can be attached to e.g. a +* Window. <br> +* Note for Desktop version only! <br> +*/ +class Menu : public boost::noncopyable +{ + // friends + friend class WidgetCreator< Menu >; + +public: + /// Type of object + typedef Menu ThisType; + + /// Object type + typedef std::tr1::shared_ptr<Menu> ObjectType; + + struct Seed { + Seed(bool ownerDrawn_ = true, const MenuColorInfo& colorInfo_ = MenuColorInfo(), FontPtr font_ = 0); + bool popup; + bool ownerDrawn; + MenuColorInfo colorInfo; + FontPtr font; + }; + + struct IdDispatcher + { + typedef std::tr1::function<void (unsigned)> F; + + IdDispatcher(const F& f_) : f(f_) { } + + bool operator()(const MSG& msg, LRESULT& ret) { + f(LOWORD(msg.wParam)); + return true; + } + + F f; + }; + + typedef Dispatchers::VoidVoid<> SimpleDispatcher; + + struct DrawItemDispatcher { + typedef std::tr1::function<bool (int, LPDRAWITEMSTRUCT)> F; + + DrawItemDispatcher(const F& f_) : f(f_) { } + + bool operator()(const MSG& msg, LRESULT& ret) { + return f(msg.wParam, reinterpret_cast<LPDRAWITEMSTRUCT>(msg.lParam)); + } + + F f; + }; + + struct MeasureItemDispatcher { + typedef std::tr1::function<bool (LPMEASUREITEMSTRUCT)> F; + + MeasureItemDispatcher(const F& f_) : f(f_) { } + + bool operator()(const MSG& msg, LRESULT& ret) { + return f(reinterpret_cast<LPMEASUREITEMSTRUCT>(msg.lParam)); + } + + F f; + }; + + /// Rendering settting settings + static const int borderGap; /// Gap between the border and item + static const int pointerGap; /// Gap between item text and sub - menu pointer + static const int textIconGap; /// Gap between text and icon + static const int textBorderGap; /// Gap between text and rectangel border + static const int separatorHeight; /// Defines default height for rectangle containing separator + static const int minSysMenuItemWidth; /// Minimum width for system menu items + static Point defaultImageSize; /// Default image size, used when no image is available + + HMENU handle() const { + return itsHandle; + } + + Widget* getParent() const { + return itsParent; + } + + /// Actually creates the menu + /** Creates the menu, the menu will be created initially empty! + */ + void create(const Seed& cs); + + void attach(HMENU hMenu, const Seed& cs); + + void setMenu(); + + /// Appends a popup to the menu + /** Everything you "append" to a menu is added sequentially to the menu <br> + * This specific "append" function appends a "popup" menu which is a menu + * containing other menus. <br> + * With other words a menu which is not an "option" but rather a new "subgroup". + * <br> + * The "File" menu of most application is for instance a "popup" menu while the + * File/Print is often NOT a popup. <br> + * To append items to the popup created call one of the appendItem overloaded + * functions on the returned value of this function. <br> + * Also, although references to all menu objects must be kept ( since they're + * not collected automatically like other Widgets ) <br> + * you don't have to keep a reference to the return value of this function since + * it's being added as a reference to the children list of the "this" object. + * <br> + * A popup is basically another branch in the menu hierarchy <br> + * See the Menu project for a demonstration. + */ + ObjectType appendPopup( const tstring & text, MenuItemDataPtr itemData = MenuItemDataPtr(new MenuItemData()) ); + + /// Returns the "System Menu" + /** The system menu is a special menu that ( normally ) is accessed by pressing + * the "window icon" at the top left of the window. <br> + * In SmartWin++ this menu can ALSO be easily manipulated and added items to + * etc... <br> + * Also, although references to all menu objects must be kept ( since they're + * not collected automatically like other Widgets ) <br> + * you don't have to keep a reference to the return value of this function since + * it's being added as a reference to the children list <br> + * of the "this" object. <br> + * See the Menu sample project for a demonstration. + */ + ObjectType getSystemMenu(); + + /// Setting event handler for Draw Item Event + /** The Draw Item Event will be raised when the menu needs to draw itself, if you + * wish to truly be creative and be 100% in control you must handle this Event + * and do the actualy drawing of the Menu yourself, but for most people it will + * be enough to just manipulate the background colors etc of the MenuItemData + * given to the menu in the appendItem function <br> + * Note! <br> + * If this event is handled you also MUST handle the Measure Item Event!! + */ + bool handleDrawItem(int id, LPDRAWITEMSTRUCT drawInfo); + + /// Setting event handler for Measure Item Event + /** The Measure Item Event is nessecary to handle if you want to draw the menu + * yourself since it is inside this Event Handler you're telling the system how + * much space you need to actually do the drawing <br> + * Note! <br> + * If this event is handled you also MUST handle the Draw Item Event!! + */ + bool handleMeasureItem(LPMEASUREITEMSTRUCT measureInfo); + + /// Appends a separator item to the menu + /** A menu separator is basically just "air" between menu items.< br > + * A separator cannot be "clicked" or "chosen". + */ + void appendSeparatorItem(); + + /// Appends a Menu Item + /** eventHandler is the function that will receive the "click" event from the + * menu item. <br> + * Event handler's signature must be "void foo( ObjectType, unsigned + * int )" and it must be contained as a member <br> + * of the class that is defined as the Widget, normally either the + * Window derived class or the class derived from Menu. <br> + * See e.g. Menu for an example. <br> + * The reason to why we have this "id" is because the same event handler can be + * defined for several menu items even in fact across menu objects, therefore + * this number should be unique across the application. + */ + void appendItem(unsigned int id, const tstring & text, MenuItemDataPtr itemData = MenuItemDataPtr(new MenuItemData())); + + template<typename DispatcherType> + void appendItem(unsigned int id, const tstring & text, const typename DispatcherType::F& f, MenuItemDataPtr itemData = MenuItemDataPtr(new MenuItemData())) { + appendItem(id, text, itemData); + callbacks.insert(std::make_pair(id, DispatcherType(f))); + } + + void appendItem(unsigned int id, const tstring & text, const IdDispatcher::F& f, MenuItemDataPtr itemData = MenuItemDataPtr(new MenuItemData())) { + appendItem<IdDispatcher>(id, text, f, itemData); + } + + void appendItem(unsigned int id, const tstring & text, BitmapPtr image); + + template<typename DispatcherType> + void appendItem(unsigned int id, const tstring & text, const typename DispatcherType::F& f, BitmapPtr image) { + MenuItemDataPtr itemData(new MenuItemData()); + if(ownerDrawn) + itemData->Image = image; + appendItem<DispatcherType>(id, text, f, itemData); + } + + void appendItem(unsigned int id, const tstring & text, const IdDispatcher::F& f, BitmapPtr image) { + appendItem<IdDispatcher>(id, text, f, image); + } + + /// Removes specified item from this menu + /** Call this function to actually DELETE a menu item from the menu hierarchy. + * Note that you have to specify the item position; and whenever you remove an item, + * all subsequent items change positions. To remove a range of items, remove from + * end to start. + */ + void removeItem( unsigned itemIndex ); + + /// Remove all items from the menu + /** Will also delete any submenus. + */ + void removeAllItems(); + + /// Return the number of items in the menu + int getCount() const; + + /// Displays and handles a menu which can appear anywhere in the window. + /** Typically called by a Right Mouse click. If both the x and the y coordinate + * is - 1 ( default ) it'll show the context menu on the position the mouse was + * at when the system last recieved a message, basically the "right" place... + * <br> + * Depending on the flags it might return the id of the menu item selected, or 0 + * if none was chosen. Flags with TPM_RETURNCMD will return the menu - item, but + * not do the menu command. + * < ul > + * < li >TPM_CENTERALIGN : Centers the shortcut menu horizontally relative to the coordinate specified by the x parameter< /li > + * < li >TPM_LEFTALIGN : Function positions the shortcut menu so that its left side is aligned with the coordinate specified by the x parameter< /li > + * < li >TPM_RIGHTALIGN : Opposite of LEFTALIGN< /li > + * < li >TPM_BOTTOMALIGN : Aligns menu bottoms to the coordinate specified by the y parameter< /li > + * < li >TPM_TOPALIGN : Opposite of BOTTOMALIGN< /li > + * < li >TPM_VCENTERALIGN : Centers vertically relative to the y parameter< /li > + * < li >TPM_NONOTIFY : Restricts the menu from sending notifications when user clicks item< /li > + * < li >TPM_RETURNCMD : returns the menu item identifier of the user's selection in the return value but DOES NOT carry out the event handler< /li > + * < li >TPM_LEFTBUTTON : Restricts users to selecting menu items with only left mouse button< /li > + * < li >TPM_RIGHTBUTTON : User can choose menu item with both mouse buttons< /li > + * < /ul > + * None of the following are used by default but can be manually chosen if you + * manually call SystemParametersInfo + * < ul > + * < li >TPM_HORNEGANIMATION : Animates the menu from right to left< /li > + * < li >TPM_HORPOSANIMATION : Animates the menu from left to right< /li > + * < li >TPM_NOANIMATION : Displays menu without animation< /li > + * < li >TPM_VERNEGANIMATION : Animates the menu from bottom to top< /li > + * < li >TPM_VERPOSANIMATION : Animates the menu from top to bottom< /li > + * < /ul > + */ + unsigned trackPopupMenu( const ScreenCoordinate& sc, unsigned flags = 0 ); + + /// Sets menu title + /** A Menu can have a title, this function sets that title + */ + void setTitle( const tstring & title, bool drawSidebar = false ); + + /// Sets title font + /** Create a font through e.g. createFont in WidgetFactory or similar and set the + * title font to the menu title through using this function + */ + void setTitleFont( FontPtr font ); + + /// Removes menu title + /** If clearSidebar is true, sidebar is removed + */ + void clearTitle( bool clearSidebar = false ); + + /// Checks (or uncheck) a specific menu item + /** Which menu item you wish to check ( or uncheck ) is passed in as the "id" + * parameter. <br> + * If the "value" parameter is true the item will be checked, otherwise it will + * be unchecked + */ + void checkItem( unsigned id, bool value = true ); + + /// Enables (or disables) a specific menu item + /** Which menu item you wish to enable ( or disable ) is passed in as the "id" + * parameter. <br> + * If the "value" parameter is true the item becomes enabled, otherwise disabled + */ + void setItemEnabled( unsigned id, bool byPosition = false, bool value = true ); + + UINT getMenuState(UINT id, bool byPosition = false); + + /// Return true if the item is a separator (by position) + bool isSeparator(UINT id, bool byPosition = false); + /// Return true if the menu item is checked + bool isChecked(UINT id, bool byPosition = false); + /// Return true if the menu item is a popup menu + bool isPopup(UINT id, bool byPosition = false); + /// Return true if the menu item is enabled (not grey and not disabled) + bool isEnabled(UINT id, bool byPosition = false); + + void setDefaultItem(UINT id, bool byPosition = false); + + /// Returns true if menu is "system menu" (icon in top left of window) + bool isSystemMenu() + { + return isSysMenu; + } + + /// Returns the text of a specific menu item + /** Which menu item you wish to retrieve the text for is defined by the "id" + * parameter of the function. + */ + tstring getText( unsigned idOrPos, bool byPos ); + + /// Sets the text of a specific menu item + /** Which menu item you wish to set the text is defined by the "id" + * parameter of the function. + */ + void setText( unsigned id, const tstring& text ); + + /// Returns item data + MenuItemDataPtr getData( int itemIndex ); + + ObjectType getChild(UINT position); + + virtual ~Menu(); + +private: + /// Constructor Taking pointer to parent + explicit Menu( dwt::Widget * parent ); + + // //////////////////////////////////////////////////////////////////////// + // Menu item data wrapper, used internally + // MENUITEMINFO's dwItemData *should* point to it + // //////////////////////////////////////////////////////////////////////// + struct ItemDataWrapper + { + // The menu item belongs to + // For some messages (e.g. WM_MEASUREITEM), + // Windows doesn't specify it, so + // we need to keep this + const Menu* menu; + + // Item index in the menu + // This is needed, because ID's for items + // are not unique (although Windows claims) + // e.g. we can have an item with ID 0, + // that is either separator or popup menu + int index; + + // Specifies if item is menu title + bool isMenuTitleItem; + + // Contains item data + MenuItemDataPtr data; + + // Wrapper Constructor + ItemDataWrapper( const Menu* menu_, int itemIndex, MenuItemDataPtr itemData, bool isTitleItem = false ) + : menu( menu_ ) + , index( itemIndex ) + , isMenuTitleItem( isTitleItem ) + , data( itemData ) + {} + + ~ItemDataWrapper() + {} + }; + + // This is used during menu destruction + static void destroyItemDataWrapper( ItemDataWrapper * wrapper ); + + // True is menu is "system menu" (icon in top left of window) + bool isSysMenu; + + // its sub menus + std::vector< ObjectType > itsChildren; + + // its item data + std::vector < ItemDataWrapper * > itsItemData; + + HMENU itsHandle; + + Widget* itsParent; + + bool ownerDrawn; + + // Contains information about menu colors + MenuColorInfo itsColorInfo; + + FontPtr font; + + // Menu title + tstring itsTitle; + + // Menu title font + FontPtr itsTitleFont; + + // if true title is drawn as sidebar + bool drawSidebar; + + typedef std::map<unsigned, Widget::CallbackType> CallbackMap; + CallbackMap callbacks; + + void createHelper(const Seed& cs); + + void addCommands(); + + // Returns item index in the menu item list + // If no item with specified id is found, - 1 is returned + int getItemIndex( unsigned int id ); +}; + +} + +#endif +#endif Deleted: dcplusplus/trunk/dwt/include/dwt/widgets/WidgetMenu.h =================================================================== --- dcplusplus/trunk/dwt/include/dwt/widgets/WidgetMenu.h 2008-04-14 20:35:32 UTC (rev 1159) +++ dcplusplus/trunk/dwt/include/dwt/widgets/WidgetMenu.h 2008-04-14 20:38:17 UTC (rev 1160) @@ -1,517 +0,0 @@ -/* - DC++ Widget Toolkit - - Copyright (c) 2007-2008, Jacek Sieka - - SmartWin++ - - Copyright (c) 2005 Thomas Hansen - - All rights reserved. - - Redistribution and use in source and binary forms, with or without modification, - are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - * Neither the name of the DWT nor SmartWin++ nor the names of its contributors - may be used to endorse or promote products derived from this software - without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#ifndef WINCE -#ifndef DWT_WidgetMenu_h -#define DWT_WidgetMenu_h - -#include "../resources/Bitmap.h" -#include "../resources/Font.h" -#include "../Dispatchers.h" -#include "../CanvasClasses.h" - -#include <vector> -#include <map> - -namespace dwt { - -/// Contains information about menu item -struct MenuItemData -{ - /// Menu item text color - COLORREF TextColor; - - /// Menu item image - BitmapPtr Image; - - /// Creates new menu item with specified data - MenuItemData( - BitmapPtr image = BitmapPtr( new Bitmap( ( HBITMAP ) NULL ) ), // defaults to empty bitmap - COLORREF textColor = ::GetSysColor( COLOR_MENUTEXT ) ) - : TextColor( textColor ), - Image( image ) - {} -}; - -/// \ingroup GlobalStuff -// MenuItemDataPtr type, contains rendering data for e.g. WidgetMenu -/** Helps easily create color values and so on for a WidgetMenu item! <br> -* Each Menu Item can have different colors and so on, use this smart pointer to set -* those values! -*/ -typedef std::tr1::shared_ptr< MenuItemData > MenuItemDataPtr; - -/// Struct for coloring different areas of WidgetMenu -/** Contains the different color settings of the WidgetMenu <br> -* Default values to constructor makes menu look roughly like MSVC++7.1 menus -*/ -struct MenuColorInfo -{ - /// Menu color - COLORREF colorMenu; - - /// Strip bar color - COLORREF colorStrip; - - /// Highlighted menu item color - COLORREF colorHighlight; - - /// Text of highlighted menu item color - COLORREF colorHighlightText; - - /// Title text color - COLORREF colorTitleText; - - /// Item image background color, used for transparency effects - COLORREF colorImageBackground; - - /// Constructs MenuColorInfo objects - /** If all the default arguments are used it will construct an object making - * menus look roughly like they do in MSVC++ 7.1 <br> - * Pass your own arguments to construct other color effects - */ - MenuColorInfo( COLORREF menuColor = ColorUtilities::darkenColor( ::GetSysColor( COLOR_WINDOW ), 0.02 ), - COLORREF stripColor = ColorUtilities::darkenColor( ::GetSysColor( COLOR_3DFACE ), 0.02 ), - COLORREF highlightColor = ::GetSysColor( COLOR_HIGHLIGHT ), - COLORREF highlightTextColor = ::GetSysColor( COLOR_HIGHLIGHTTEXT ), - COLORREF titleTextColor = ::GetSysColor( COLOR_MENUTEXT ), - COLORREF imageBackground = RGB( 0, 0, 0 ) ) // black - : colorMenu( menuColor ), - colorStrip( stripColor ), - colorHighlight( highlightColor ), - colorHighlightText( highlightTextColor ), - colorTitleText( titleTextColor ), - colorImageBackground( imageBackground ) - {} -}; - -/// Menu class -/** \ingroup WidgetControls -* \WidgetUsageInfo -* \image html menu.png -* Class for creating a Menu Control which then can be attached to e.g. a -* Window. <br> -* Note for Desktop version only! <br> -*/ -class WidgetMenu : public boost::noncopyable -{ - // friends - friend class WidgetCreator< WidgetMenu >; - -public: - /// Type of object - typedef WidgetMenu ThisType; - - /// Object type - typedef std::tr1::shared_ptr<WidgetMenu> ObjectType; - - struct Seed { - Seed(bool ownerDrawn_ = true, const MenuColorInfo& colorInfo_ = MenuColorInfo(), FontPtr font_ = 0); - bool popup; - bool ownerDrawn; - MenuColorInfo colorInfo; - FontPtr font; - }; - - struct IdDispatcher - { - typedef std::tr1::function<void (unsigned)> F; - - IdDispatcher(const F& f_) : f(f_) { } - - bool operator()(const MSG& msg, LRESULT& ret) { - f(LOWORD(msg.wParam)); - return true; - } - - F f; - }; - - typedef Dispatchers::VoidVoid<> SimpleDispatcher; - - struct DrawItemDispatcher { - typedef std::tr1::function<bool (int, LPDRAWITEMSTRUCT)> F; - - DrawItemDispatcher(const F& f_) : f(f_) { } - - bool operator()(const MSG& msg, LRESULT& ret) { - return f(msg.wParam, reinterpret_cast<LPDRAWITEMSTRUCT>(msg.lParam)); - } - - F f; - }; - - struct MeasureItemDispatcher { - typedef std::tr1::function<bool (LPMEASUREITEMSTRUCT)> F; - - MeasureItemDispatcher(const F& f_) : f(f_) { } - - bool operator()(const MSG& msg, LRESULT& ret) { - return f(reinterpret_cast<LPMEASUREITEMSTRUCT>(msg.lParam)); - } - - F f; - }; - - /// Rendering settting settings - static const int borderGap; /// Gap between the border and item - static const int pointerGap; /// Gap between item text and sub - menu pointer - static const int textIconGap; /// Gap between text and icon - static const int textBorderGap; /// Gap between text and rectangel border - static const int separatorHeight; /// Defines default height for rectangle containing separator - static const int minSysMenuItemWidth; /// Minimum width for system menu items - static Point defaultImageSize; /// Default image size, used when no image is available - - HMENU handle() const { - return itsHandle; - } - - Widget* getParent() const { - return itsParent; - } - - /// Actually creates the menu - /** Creates the menu, the menu will be created initially empty! - */ - void create(const Seed& cs); - - void attach(HMENU hMenu, const Seed& cs); - - void setMenu(); - - /// Appends a popup to the menu - /** Everything you "append" to a menu is added sequentially to the menu <br> - * This specific "append" function appends a "popup" menu which is a menu - * containing other menus. <br> - * With other words a menu which is not an "option" but rather a new "subgroup". - * <br> - * The "File" menu of most application is for instance a "popup" menu while the - * File/Print is often NOT a popup. <br> - * To append items to the popup created call one of the appendItem overloaded - * functions on the returned value of this function. <br> - * Also, although references to all menu objects must be kept ( since they're - * not collected automatically like other Widgets ) <br> - * you don't have to keep a reference to the return value of this function since - * it's being added as a reference to the children list of the "this" object. - * <br> - * A popup is basically another branch in the menu hierarchy <br> - * See the WidgetMenu project for a demonstration. - */ - ObjectType appendPopup( const tstring & text, MenuItemDataPtr itemData = MenuItemDataPtr(new MenuItemData()) ); - - /// Returns the "System Menu" - /** The system menu is a special menu that ( normally ) is accessed by pressing - * the "window icon" at the top left of the window. <br> - * In SmartWin++ this menu can ALSO be easily manipulated and added items to - * etc... <br> - * Also, although references to all menu objects must be kept ( since they're - * not collected automatically like other Widgets ) <br> - * you don't have to keep a reference to the return value of this function since - * it's being added as a reference to the children list <br> - * of the "this" object. <br> - * See the WidgetMenu sample project for a demonstration. - */ - ObjectType getSystemMenu(); - - /// Setting event handler for Draw Item Event - /** The Draw Item Event will be raised when the menu needs to draw itself, if you - * wish to truly be creative and be 100% in control you must handle this Event - * and do the actualy drawing of the Menu yourself, but for most people it will - * be enough to just manipulate the background colors etc of the MenuItemData - * given to the menu in the appendItem function <br> - * Note! <br> - * If this event is handled you also MUST handle the Measure Item Event!! - */ - bool handleDrawItem(int id, LPDRAWITEMSTRUCT drawInfo); - - /// Setting event handler for Measure Item Event - /** The Measure Item Event is nessecary to handle if you want to draw the menu - * yourself since it is inside this Event Handler you're telling the system how - * much space you need to actually do the drawing <br> - * Note! <br> - * If this event is handled you also MUST handle the Draw Item Event!! - */ - bool handleMeasureItem(LPMEASUREITEMSTRUCT measureInfo); - - /// Appends a separator item to the menu - /** A menu separator is basically just "air" between menu items.< br > - * A separator cannot be "clicked" or "chosen". - */ - void appendSeparatorItem(); - - /// Appends a Menu Item - /** eventHandler is the function that will receive the "click" event from the - * menu item. <br> - * Event handler's signature must be "void foo( ObjectType, unsigned - * int )" and it must be contained as a member <br> - * of the class that is defined as the Widget, normally either the - * Window derived class or the class derived from WidgetMenu. <br> - * See e.g. WidgetMenu for an example. <br> - * The reason to why we have this "id" is because the same event handler can be - * defined for several menu items even in fact across menu objects, therefore - * this number should be unique across the application. - */ - void appendItem(unsigned int id, const tstring & text, MenuItemDataPtr itemData = MenuItemDataPtr(new MenuItemData())); - - template<typename DispatcherType> - void appendItem(unsigned int id, const tstring & text, const typename DispatcherType::F& f, MenuItemDataPtr itemData = MenuItemDataPtr(new MenuItemData())) { - appendItem(id, text, itemData); - callbacks.insert(std::make_pair(id, DispatcherType(f))); - } - - void appendItem(unsigned int id, const tstring & text, const IdDispatcher::F& f, MenuItemDataPtr itemData = MenuItemDataPtr(new MenuItemData())) { - appendItem<IdDispatcher>(id, text, f, itemData); - } - - void appendItem(unsigned int id, const tstring & text, BitmapPtr image); - - template<typename DispatcherType> - void appendItem(unsigned int id, const tstring & text, const typename DispatcherType::F& f, BitmapPtr image) { - MenuItemDataPtr itemData(new MenuItemData()); - if(ownerDrawn) - itemData->Image = image; - appendItem<DispatcherType>(id, text, f, itemData); - } - - void appendItem(unsigned int id, const tstring & text, const IdDispatcher::F& f, BitmapPtr image) { - appendItem<IdDispatcher>(id, text, f, image); - } - - /// Removes specified item from this menu - /** Call this function to actually DELETE a menu item from the menu hierarchy. - * Note that you have to specify the item position; and whenever you remove an item, - * all subsequent items change positions. To remove a range of items, remove from - * end to start. - */ - void removeItem( unsigned itemIndex ); - - /// Remove all items from the menu - /** Will also delete any submenus. - */ - void removeAllItems(); - - /// Return the number of items in the menu - int getCount() const; - - /// Displays and handles a menu which can appear anywhere in the window. - /** Typically called by a Right Mouse click. If both the x and the y coordinate - * is - 1 ( default ) it'll show the context menu on the position the mouse was - * at when the system last recieved a message, basically the "right" place... - * <br> - * Depending on the flags it might return the id of the menu item selected, or 0 - * if none was chosen. Flags with TPM_RETURNCMD will return the menu - item, but - * not do the menu command. - * < ul > - * < li >TPM_CENTERALIGN : Centers the shortcut menu horizontally relative to the coordinate specified by the x parameter< /li > - * < li >TPM_LEFTALIGN : Function positions the shortcut menu so that its left side is aligned with the coordinate specified by the x parameter< /li > - * < li >TPM_RIGHTALIGN : Opposite of LEFTALIGN< /li > - * < li >TPM_BOTTOMALIGN : Aligns menu bottoms to the coordinate specified by the y parameter< /li > - * < li >TPM_TOPALIGN : Opposite of BOTTOMALIGN< /li > - * < li >TPM_VCENTERALIGN : Centers vertically relative to the y parameter< /li > - * < li >TPM_NONOTIFY : Restricts the menu from sending notifications when user clicks item< /li > - * < li >TPM_RETURNCMD : returns the menu item identifier of the user's selection in the return value but DOES NOT carry out the event handler< /li > - * < li >TPM_LEFTBUTTON : Restricts users to selecting menu items with only left mouse button< /li > - * < li >TPM_RIGHTBUTTON : User can choose menu item with both mouse buttons< /li > - * < /ul > - * None of the following are used by default but can be manually chosen if you - * manually call SystemParametersInfo - * < ul > - * < li >TPM_HORNEGANIMATION : Animates the menu from right to left< /li > - * < li >TPM_HORPOSANIMATION : Animates the menu from left to right< /li > - * < li >TPM_NOANIMATION : Displays menu without animation< /li > - * < li >TPM_VERNEGANIMATION : Animates the menu from bottom to top< /li > - * < li >TPM_VERPOSANIMATION : Animates the menu from top to bottom< /li > - * < /ul > - */ - unsigned trackPopupMenu( const ScreenCoordinate& sc, unsigned flags = 0 ); - - /// Sets menu title - /** A WidgetMenu can have a title, this function sets that title - */ - void setTitle( const tstring & title, bool drawSidebar = false ); - - /// Sets title font - /** Create a font through e.g. createFont in WidgetFactory or similar and set the - * title font to the menu title through using this function - */ - void setTitleFont( FontPtr font ); - - /// Removes menu title - /** If clearSidebar is true, sidebar is removed - */ - void clearTitle( bool clearSidebar = false ); - - /// Checks (or uncheck) a specific menu item - /** Which menu item you wish to check ( or uncheck ) is passed in as the "id" - * parameter. <br> - * If the "value" parameter is true the item will be checked, otherwise it will - * be unchecked - */ - void checkItem( unsigned id, bool value = true ); - - /// Enables (or disables) a specific menu item - /** Which menu item you wish to enable ( or disable ) is passed in as the "id" - * parameter. <br> - * If the "value" parameter is true the item becomes enabled, otherwise disabled - */ - void setItemEnabled( unsigned id, bool byPosition = false, bool value = true ); - - UINT getMenuState(UINT id, bool byPosition = false); - - /// Return true if the item is a separator (by position) - bool isSeparator(UINT id, bool byPosition = false); - /// Return true if the menu item is checked - bool isChecked(UINT id, bool byPosition = false); - /// Return true if the menu item is a popup menu - bool isPopup(UINT id, bool byPosition = false); - /// Return true if the menu item is enabled (not grey and not disabled) - bool isEnabled(UINT id, bool byPosition = false); - - void setDefaultItem(UINT id, bool byPosition = false); - - /// Returns true if menu is "system menu" (icon in top left of window) - bool isSystemMenu() - { - return isSysMenu; - } - - /// Returns the text of a specific menu item - /** Which menu item you wish to retrieve the text for is defined by the "id" - * parameter of the function. - */ - tstring getText( unsigned idOrPos, bool byPos ); - - /// Sets the text of a specific menu item - /** Which menu item you wish to set the text is defined by the "id" - * parameter of the function. - */ - void setText( unsigned id, const tstring& text ); - - /// Returns item data - MenuItemDataPtr getData( int itemIndex ); - - ObjectType getChild(UINT position); - - virtual ~WidgetMenu(); - -private: - /// Constructor Taking pointer to parent - explicit WidgetMenu( dwt::Widget * parent ); - - // //////////////////////////////////////////////////////////////////////// - // Menu item data wrapper, used internally - // MENUITEMINFO's dwItemData *should* point to it - // //////////////////////////////////////////////////////////////////////// - struct ItemDataWrapper - { - // The menu item belongs to - // For some messages (e.g. WM_MEASUREITEM), - // Windows doesn't specify it, so - // we need to keep this - const WidgetMenu* menu; - - // Item index in the menu - // This is needed, because ID's for items - // are not unique (although Windows claims) - // e.g. we can have an item with ID 0, - // that is either separator or popup menu - int index; - - // Specifies if item is menu title - bool isMenuTitleItem; - - // Contains item data - MenuItemDataPtr data; - - // Wrapper Constructor - ItemDataWrapper( const WidgetMenu* menu_, int itemIndex, MenuItemDataPtr itemData, bool isTitleItem = false ) - : menu( menu_ ) - , index( itemIndex ) - , isMenuTitleItem( isTitleItem ) - , data( itemData ) - {} - - ~ItemDataWrapper() - {} - }; - - // This is used during menu destruction - static void destroyItemDataWrapper( ItemDataWrapper * wrapper ); - - // True is menu is "system menu" (icon in top left of window) - bool isSysMenu; - - // its sub menus - std::vector< ObjectType > itsChildren; - - // its item data - std::vector < ItemDataWrapper * > itsItemData; - - HMENU itsHandle; - - Widget* itsParent; - - bool ownerDrawn; - - // Contains information about menu colors - MenuColorInfo itsColorInfo; - - FontPtr font; - - // Menu title - tstring itsTitle; - - // Menu title font - FontPtr itsTitleFont; - - // if true title is drawn as sidebar - bool drawSidebar; - - typedef std::map<unsigned, Widget::CallbackType> CallbackMap; - CallbackMap callbacks; - - void createHelper(const Seed& cs); - - void addCommands(); - - // Returns item index in the menu item list - // If no item with specified id is found, - 1 is returned - int getItemIndex( unsigned int id ); -}; - -} - -#endif -#endif Copied: dcplusplus/trunk/dwt/src/widgets/Menu.cpp (from rev 1159, dcplusplus/trunk/dwt/src/widgets/WidgetMenu.cpp) =================================================================== --- dcplusplus/trunk/dwt/src/widgets/Menu.cpp (rev 0) +++ dcplusplus/trunk/dwt/src/widgets/Menu.cpp 2008-04-14 20:38:17 UTC (rev 1160) @@ -0,0 +1,1019 @@ +/* + DC++ Widget Toolkit + + Copyright (c) 2007-2008, Jacek Sieka + + SmartWin++ + + Copyright (c) 2005 Thomas Hansen + + All rights reserved. + + Redistribution and use in source and binary forms, with or without modification, + are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of the DWT nor SmartWin++ nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef WINCE + +#include <dwt/widgets/Menu.h> + +#include <dwt/resources/Brush.h> +#include <dwt/resources/Pen.h> + +namespace dwt { + +const int Menu::borderGap = 3; +const int Menu::pointerGap = 5; +const int Menu::textIconGap = 8; +const int Menu::textBorderGap = 4; +const int Menu::separatorHeight = 8; +const int Menu::minSysMenuItemWidth = 130; +Point Menu::defaultImageSize = Point( 16, 16 ); + +Menu::Seed::Seed(bool ownerDrawn_, const MenuColorInfo& colorInfo_, FontPtr font_) : +popup(true), +ownerDrawn(ownerDrawn_), +colorInfo(colorInfo_), +font(font_) +{ +} + +Menu::Menu( dwt::Widget* parent ) : +isSysMenu(false), +itsParent(parent), +drawSidebar(false) +{ + xAssert(itsParent != NULL, _T("A Menu must have a parent")); +} + +void Menu::createHelper(const Seed& cs) { + // save settings provided through the Seed + ownerDrawn = cs.ownerDrawn; + itsColorInfo = cs.colorInfo; + + if(ownerDrawn) { + if(cs.font) + font = cs.font; + else + font = new Font(DefaultGuiFont); + + { + LOGFONT lf; + ::GetObject(font->handle(), sizeof(lf), &lf); + lf.lfWeight = FW_BOLD; + itsTitleFont = FontPtr(new Font(::CreateFontIndirect(&lf), true)); + } + + // set default drawing + itsParent->setCallback(Message(WM_DRAWITEM), DrawItemDispatcher(std::tr1::bind(&Menu::handleDrawItem, this, _1, _2))); + itsParent->setCallback(Message(WM_MEASUREITEM), MeasureItemDispatcher(std::tr1::bind(&Menu::handleMeasureItem, this, _1))); + } +} + +void Menu::create(const Seed& cs) { + createHelper(cs); + + if(cs.popup) + itsHandle = ::CreatePopupMenu(); + else + itsHandle = ::CreateMenu(); + if ( !itsHandle ) + { + xCeption x( _T( "CreateMenu in Menu::create fizzled..." ) ); + throw x; + } +} + +void Menu::attach(HMENU hMenu, const Seed& cs) { + createHelper(cs); + + itsHandle = hMenu; + + if(ownerDrawn) { + // update all current items to be owner-drawn + // @todo update sub-menus too... + const int count = getCount(); + for(int i = 0; i < count; ++i) { + // init structure for items + MENUITEMINFO info; + memset( & info, 0, sizeof( info ) ); + info.cbSize = sizeof( MENUITEMINFO ); + + // set flags + info.fMask = MIIM_FTYPE | MIIM_DATA; + + if(::GetMenuItemInfo(itsHandle, i, TRUE, &info)) { + info.fMask |= MIIM_DATA; + info.fType |= MFT_OWNERDRAW; + + // create item data wrapper + ItemDataWrapper * wrapper = new ItemDataWrapper( this, i, MenuItemDataPtr( new MenuItemData() ) ); + info.dwItemData = reinterpret_cast< ULONG_PTR >( wrapper ); + + if(::SetMenuItemInfo(itsHandle, i, TRUE, &info)) + itsItemData.push_back( wrapper ); + else + throw xCeption( _T( "SetMenuItemInfo in Menu::attach fizzled..." ) ); + } else + throw xCeption( _T( "GetMenuItemInfo in Menu::attach fizzled..." ) ); + } + } +} + +void Menu::setMenu() { + add... [truncated message content] |