From: <zou...@us...> - 2008-03-02 20:33:22
|
Revision: 1023 http://dcplusplus.svn.sourceforge.net/dcplusplus/?rev=1023&view=rev Author: zouzou123gen Date: 2008-03-02 12:31:51 -0800 (Sun, 02 Mar 2008) Log Message: ----------- fancy menus for every text box Modified Paths: -------------- dcplusplus/trunk/smartwin/include/smartwin/GCCHeaders.h dcplusplus/trunk/smartwin/include/smartwin/WidgetCreator.h dcplusplus/trunk/smartwin/include/smartwin/WidgetFactoryPlatformSmartWinDesktop.h dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetComboBox.h dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetMenu.h dcplusplus/trunk/smartwin/source/widgets/WidgetComboBox.cpp dcplusplus/trunk/smartwin/source/widgets/WidgetMenu.cpp dcplusplus/trunk/win32/AboutDlg.cpp dcplusplus/trunk/win32/AboutDlg.h dcplusplus/trunk/win32/Advanced3Page.cpp dcplusplus/trunk/win32/Appearance2Page.cpp dcplusplus/trunk/win32/AppearancePage.cpp dcplusplus/trunk/win32/CertificatesPage.cpp dcplusplus/trunk/win32/CertificatesPage.h dcplusplus/trunk/win32/CommandDlg.cpp dcplusplus/trunk/win32/CommandDlg.h dcplusplus/trunk/win32/DCPlusPlus.rc dcplusplus/trunk/win32/DownloadPage.cpp dcplusplus/trunk/win32/FavHubProperties.cpp dcplusplus/trunk/win32/FavHubProperties.h dcplusplus/trunk/win32/GeneralPage.cpp dcplusplus/trunk/win32/LineDlg.cpp dcplusplus/trunk/win32/LineDlg.h dcplusplus/trunk/win32/LogPage.cpp dcplusplus/trunk/win32/LogPage.h dcplusplus/trunk/win32/MDIChildFrame.h dcplusplus/trunk/win32/MagnetDlg.cpp dcplusplus/trunk/win32/MagnetDlg.h dcplusplus/trunk/win32/MainWindow.cpp dcplusplus/trunk/win32/NetworkPage.cpp dcplusplus/trunk/win32/PropPage.cpp dcplusplus/trunk/win32/PropPage.h dcplusplus/trunk/win32/QueuePage.cpp dcplusplus/trunk/win32/TransferView.h dcplusplus/trunk/win32/UploadPage.cpp dcplusplus/trunk/win32/WidgetFactory.h dcplusplus/trunk/win32/WidgetTextBox.h Added Paths: ----------- dcplusplus/trunk/win32/WidgetComboBox.cpp dcplusplus/trunk/win32/WidgetComboBox.h dcplusplus/trunk/win32/WidgetTextBox.cpp Modified: dcplusplus/trunk/smartwin/include/smartwin/GCCHeaders.h =================================================================== --- dcplusplus/trunk/smartwin/include/smartwin/GCCHeaders.h 2008-03-01 23:16:58 UTC (rev 1022) +++ dcplusplus/trunk/smartwin/include/smartwin/GCCHeaders.h 2008-03-02 20:31:51 UTC (rev 1023) @@ -81,6 +81,9 @@ #define COLOR_MENUBAR 30 #define ODS_HOTLIGHT 0x0040 #define ODS_INACTIVE 0x0080 + #ifndef MN_GETHMENU + #define MN_GETHMENU 0x01E1 + #endif #if(_WIN32_WINNT >= 0x0500) #ifndef ODS_NOACCEL #define ODS_NOACCEL 0x0100 Modified: dcplusplus/trunk/smartwin/include/smartwin/WidgetCreator.h =================================================================== --- dcplusplus/trunk/smartwin/include/smartwin/WidgetCreator.h 2008-03-01 23:16:58 UTC (rev 1022) +++ dcplusplus/trunk/smartwin/include/smartwin/WidgetCreator.h 2008-03-02 20:31:51 UTC (rev 1023) @@ -94,6 +94,12 @@ return retVal; } + static typename WidgetType::ObjectType attach( Widget * parent, HMENU hMenu, const typename WidgetType::Seed & cs ) + { + typename WidgetType::ObjectType retVal(new WidgetType( parent )); + retVal->attach( hMenu, cs ); + return retVal; + } }; // end namespace SmartWin Modified: dcplusplus/trunk/smartwin/include/smartwin/WidgetFactoryPlatformSmartWinDesktop.h =================================================================== --- dcplusplus/trunk/smartwin/include/smartwin/WidgetFactoryPlatformSmartWinDesktop.h 2008-03-01 23:16:58 UTC (rev 1022) +++ dcplusplus/trunk/smartwin/include/smartwin/WidgetFactoryPlatformSmartWinDesktop.h 2008-03-02 20:31:51 UTC (rev 1023) @@ -123,6 +123,11 @@ return WidgetCreator< WidgetMenu >::create( this, cs ); } + WidgetMenuPtr attachMenu(HMENU hMenu, const typename WidgetMenu::Seed& cs = WidgetMenu::Seed()) + { + return WidgetCreator< WidgetMenu >::attach( this, cs, hMenu ); + } + /// Creates a Tool Bar and returns a pointer to it. /** DON'T delete the returned pointer!!! */ Modified: dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetComboBox.h =================================================================== --- dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetComboBox.h 2008-03-01 23:16:58 UTC (rev 1022) +++ dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetComboBox.h 2008-03-02 20:31:51 UTC (rev 1023) @@ -39,7 +39,6 @@ #include "../aspects/AspectPainting.h" #include "../aspects/AspectSelection.h" #include "../aspects/AspectText.h" -#include "WidgetTextBox.h" namespace SmartWin { @@ -154,9 +153,6 @@ static bool isValidSelectionChanged( LPARAM lPar ) { return true; } - - typedef WidgetTextBox::ObjectType WidgetTextBoxPtr; - WidgetTextBoxPtr getTextBox(); protected: /// Constructor Taking pointer to parent @@ -166,9 +162,6 @@ // WidgetFactory class which is friend virtual ~WidgetComboBox() {} - -private: - WidgetTextBoxPtr textBox; }; /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -266,7 +259,7 @@ } inline WidgetComboBox::WidgetComboBox( Widget * parent ) - : ControlType( parent ), textBox(0) + : ControlType( parent ) { } Modified: dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetMenu.h =================================================================== --- dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetMenu.h 2008-03-01 23:16:58 UTC (rev 1022) +++ dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetMenu.h 2008-03-02 20:31:51 UTC (rev 1023) @@ -206,9 +206,10 @@ */ void create(const Seed& cs); - /// Attaches the menu to the parent window - void attach(); + 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 @@ -321,7 +322,7 @@ void removeAllItems(); /// Return the number of items in the menu - int getCount(); + 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 @@ -502,6 +503,8 @@ typedef std::map<unsigned, Widget::CallbackType> CallbackMap; CallbackMap callbacks; + void createHelper(const Seed& cs); + void addCommands(); // Returns item index in the menu item list Modified: dcplusplus/trunk/smartwin/source/widgets/WidgetComboBox.cpp =================================================================== --- dcplusplus/trunk/smartwin/source/widgets/WidgetComboBox.cpp 2008-03-01 23:16:58 UTC (rev 1022) +++ dcplusplus/trunk/smartwin/source/widgets/WidgetComboBox.cpp 2008-03-02 20:31:51 UTC (rev 1023) @@ -1,5 +1,4 @@ #include "../../include/smartwin/widgets/WidgetComboBox.h" -#include "../../include/smartwin/WidgetCreator.h" namespace SmartWin { @@ -19,16 +18,4 @@ sendMessage(CB_SETEXTENDEDUI, TRUE); } -WidgetComboBox::WidgetTextBoxPtr WidgetComboBox::getTextBox() { - if(!textBox) { - LONG_PTR style = ::GetWindowLongPtr(handle(), GWL_STYLE); - if((style & CBS_SIMPLE) == CBS_SIMPLE || (style & CBS_DROPDOWN) == CBS_DROPDOWN) { - HWND wnd = ::FindWindowEx(handle(), NULL, _T("EDIT"), NULL); - if(wnd && wnd != handle()) - textBox = WidgetCreator< WidgetTextBox >::attach(this, wnd); - } - } - return textBox; } - -} Modified: dcplusplus/trunk/smartwin/source/widgets/WidgetMenu.cpp =================================================================== --- dcplusplus/trunk/smartwin/source/widgets/WidgetMenu.cpp 2008-03-01 23:16:58 UTC (rev 1022) +++ dcplusplus/trunk/smartwin/source/widgets/WidgetMenu.cpp 2008-03-02 20:31:51 UTC (rev 1023) @@ -52,8 +52,7 @@ xAssert(itsParent != NULL, _T("A WidgetMenu must have a parent")); } -void WidgetMenu::create(const Seed& cs) -{ +void WidgetMenu::createHelper(const Seed& cs) { // save settings provided through the Seed ownerDrawn = cs.ownerDrawn; itsColorInfo = cs.colorInfo; @@ -70,8 +69,11 @@ itsParent->setCallback(Message(WM_DRAWITEM), DrawItemDispatcher(std::tr1::bind(&WidgetMenu::handleDrawItem, this, _1, _2))); itsParent->setCallback(Message(WM_MEASUREITEM), MeasureItemDispatcher(std::tr1::bind(&WidgetMenu::handleMeasureItem, this, _1))); } +} - // Create menu +void WidgetMenu::create(const Seed& cs) { + createHelper(cs); + if(cs.popup) itsHandle = ::CreatePopupMenu(); else @@ -83,11 +85,46 @@ } } -void WidgetMenu::attach() -{ +void WidgetMenu::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)) + itsItemDataRef.push_back( wrapper ); + else + throw xCeption( _T( "SetMenuItemInfo in WidgetMenu::attach fizzled..." ) ); + } else + throw xCeption( _T( "GetMenuItemInfo in WidgetMenu::attach fizzled..." ) ); + } + } +} + +void WidgetMenu::setMenu() { addCommands(); if ( ::SetMenu( itsParent->handle(), itsHandle ) == FALSE ) - throw xCeption( _T( "Couldn't attach menu to the parent window" ) ); + throw xCeption( _T( "SetMenu in WidgetMenu::setMenu fizzled..." ) ); } WidgetMenu::ObjectType WidgetMenu::appendPopup( const SmartUtil::tstring & text, MenuItemDataPtr itemData ) @@ -111,7 +148,7 @@ info.hSubMenu = retVal->handle(); // get position to insert - int position = ::GetMenuItemCount( itsHandle ); + int position = getCount(); ItemDataWrapper * wrapper = NULL; if(ownerDrawn) { @@ -167,7 +204,7 @@ int WidgetMenu::getItemIndex( unsigned int id ) { int index = 0; - const int itemCount = ::GetMenuItemCount( itsHandle ); + const int itemCount = getCount(); for ( index = 0; index < itemCount; ++index ) if ( ::GetMenuItemID( itsHandle, index ) == id ) // exit the loop if found @@ -190,7 +227,7 @@ WidgetMenu::~WidgetMenu() { // Destroy this menu - ::DestroyMenu( this->handle() ); + ::DestroyMenu( handle() ); std::for_each( itsItemDataRef.begin(), itsItemDataRef.end(), destroyItemDataWrapper ); } @@ -205,7 +242,7 @@ void WidgetMenu::setTitleFont( FontPtr font ) { itsTitleFont = font; - setTitle( itsTitle, this->drawSidebar ); // Easy for now, should be refactored... + setTitle( itsTitle, drawSidebar ); // Easy for now, should be refactored... } void WidgetMenu::clearTitle( bool clearSidebar /* = false */) @@ -222,12 +259,12 @@ void WidgetMenu::checkItem( unsigned id, bool value ) { - ::CheckMenuItem( this->handle(), id, value ? MF_CHECKED : MF_UNCHECKED ); + ::CheckMenuItem( handle(), id, value ? MF_CHECKED : MF_UNCHECKED ); } void WidgetMenu::setItemEnabled( unsigned id, bool byPosition, bool value ) { - if ( ::EnableMenuItem( this->handle(), id, (byPosition ? MF_BYPOSITION : MF_BYCOMMAND) | (value ? MF_ENABLED : MF_GRAYED) ) == - 1 ) + if ( ::EnableMenuItem( handle(), id, (byPosition ? MF_BYPOSITION : MF_BYCOMMAND) | (value ? MF_ENABLED : MF_GRAYED) ) == - 1 ) { xCeption x( _T( "Couldn't enable/disable the menu item, item doesn't exist" ) ); throw x; @@ -236,7 +273,7 @@ UINT WidgetMenu::getMenuState( UINT id, bool byPosition ) { - return ::GetMenuState(this->handle(), id, byPosition ? MF_BYPOSITION : MF_BYCOMMAND); + return ::GetMenuState(handle(), id, byPosition ? MF_BYPOSITION : MF_BYCOMMAND); } bool WidgetMenu::isSeparator( UINT id, bool byPosition ) @@ -261,7 +298,7 @@ void WidgetMenu::setDefaultItem( UINT id, bool byPosition ) { - ::SetMenuDefaultItem(this->handle(), id, byPosition); + ::SetMenuDefaultItem(handle(), id, byPosition); } SmartUtil::tstring WidgetMenu::getText( unsigned id, bool byPosition ) @@ -841,7 +878,7 @@ itemInfo.fType = MFT_SEPARATOR; // get position to insert - int position = ::GetMenuItemCount( itsHandle ); + int position = getCount(); ItemDataWrapper * wrapper = NULL; if(ownerDrawn) { @@ -863,7 +900,7 @@ HMENU popup = ::GetSubMenu( itsHandle, itemIndex ); // try to remove item - if ( ::RemoveMenu( itsHandle, itemIndex, MF_BYPOSITION ) == TRUE ) + if ( ::RemoveMenu( itsHandle, itemIndex, MF_BYPOSITION ) ) { size_t i = 0; @@ -906,13 +943,13 @@ void WidgetMenu::removeAllItems() { //must be backwards, since bigger indexes change on remove - for( int i = this->getCount() - 1; i >= 0; i-- ) + for( int i = getCount() - 1; i >= 0; i-- ) { - this->removeItem( i ); + removeItem( i ); } } -int WidgetMenu::getCount() +int WidgetMenu::getCount() const { int count = ::GetMenuItemCount( itsHandle ); if( count == -1 ) @@ -942,7 +979,7 @@ // set position to insert bool itemExists = index != - 1; - index = itemExists ? index : ::GetMenuItemCount( itsHandle ); + index = itemExists ? index : getCount(); ItemDataWrapper * wrapper = NULL; if(ownerDrawn) { @@ -954,8 +991,8 @@ info.dwItemData = reinterpret_cast< ULONG_PTR >( wrapper ); } - if ( ( !itemExists && ::InsertMenuItem( itsHandle, id, FALSE, & info ) == TRUE ) || - ( itemExists && ::SetMenuItemInfo( itsHandle, id, FALSE, & info ) == TRUE ) ) + if ( ( !itemExists && ::InsertMenuItem( itsHandle, id, FALSE, & info ) ) || + ( itemExists && ::SetMenuItemInfo( itsHandle, id, FALSE, & info ) ) ) { if(ownerDrawn) itsItemDataRef.push_back( wrapper ); @@ -991,8 +1028,8 @@ WidgetMenu::ObjectType WidgetMenu::getChild( unsigned position ) { HMENU h = ::GetSubMenu(handle(), position); - for(size_t i = 0; i < this->itsChildren.size(); ++i) { - ObjectType& menu = this->itsChildren[i]; + for(size_t i = 0; i < itsChildren.size(); ++i) { + ObjectType& menu = itsChildren[i]; if(menu->handle() == h) { return menu; } Modified: dcplusplus/trunk/win32/AboutDlg.cpp =================================================================== --- dcplusplus/trunk/win32/AboutDlg.cpp 2008-03-01 23:16:58 UTC (rev 1022) +++ dcplusplus/trunk/win32/AboutDlg.cpp 2008-03-02 20:31:51 UTC (rev 1023) @@ -44,7 +44,7 @@ "stanislav maslovski, david grundberg. " "Keep it coming!"; -AboutDlg::AboutDlg(SmartWin::Widget* parent) : SmartWin::WidgetFactory<SmartWin::WidgetModalDialog>(parent) { +AboutDlg::AboutDlg(SmartWin::Widget* parent) : WidgetFactory<SmartWin::WidgetModalDialog>(parent) { onInitDialog(std::tr1::bind(&AboutDlg::handleInitDialog, this)); onSpeaker(std::tr1::bind(&AboutDlg::handleSpeaker, this, _1, _2)); } @@ -54,8 +54,8 @@ bool AboutDlg::handleInitDialog() { setItemText(IDC_VERSION, Text::toT("DC++ " VERSIONSTRING "\n(c) Copyright 2001-2008 Jacek Sieka\nEx-codeveloper: Per Lind\303\251n\nGraphics: Martin Skogevall et al.\nDC++ is licenced under GPL\nhttp://dcplusplus.sourceforge.net/")); - setItemText(IDC_TTH, WinUtil::tth); - setItemText(IDC_THANKS, Text::toT(thanks)); + attachTextBox(IDC_TTH)->setText(WinUtil::tth); + attachTextBox(IDC_THANKS)->setText(Text::toT(thanks)); setItemText(IDC_TOTALS, str(TF_("Upload: %1%, Download: %2%") % Text::toT(Util::formatBytes(SETTING(TOTAL_UPLOAD))) % Text::toT(Util::formatBytes(SETTING(TOTAL_DOWNLOAD))))); if(SETTING(TOTAL_DOWNLOAD) > 0) { setItemText(IDC_RATIO, str(TF_("Ratio (up/down): %1$0.2f") % (((double)SETTING(TOTAL_UPLOAD)) / ((double)SETTING(TOTAL_DOWNLOAD))))); Modified: dcplusplus/trunk/win32/AboutDlg.h =================================================================== --- dcplusplus/trunk/win32/AboutDlg.h 2008-03-01 23:16:58 UTC (rev 1022) +++ dcplusplus/trunk/win32/AboutDlg.h 2008-03-02 20:31:51 UTC (rev 1023) @@ -21,10 +21,11 @@ #include <dcpp/HttpConnection.h> #include "resource.h" +#include "WidgetFactory.h" #include "AspectSpeaker.h" class AboutDlg : - public SmartWin::WidgetFactory<SmartWin::WidgetModalDialog>, + public WidgetFactory<SmartWin::WidgetModalDialog>, public AspectSpeaker<AboutDlg>, private HttpConnectionListener { Modified: dcplusplus/trunk/win32/Advanced3Page.cpp =================================================================== --- dcplusplus/trunk/win32/Advanced3Page.cpp 2008-03-01 23:16:58 UTC (rev 1022) +++ dcplusplus/trunk/win32/Advanced3Page.cpp 2008-03-02 20:31:51 UTC (rev 1023) @@ -68,6 +68,21 @@ WidgetSpinnerPtr spinner = attachSpinner(IDC_SEARCH_HISTORY_SPIN); spinner->setRange(0, 100); + + attachTextBox(IDC_ROLLBACK); + attachTextBox(IDC_MAX_HASH_SPEED); + attachTextBox(IDC_SHOW_LAST_LINES_LOG); + attachTextBox(IDC_SET_MINISLOT_SIZE); + attachTextBox(IDC_MAX_FILELIST_SIZE); + attachTextBox(IDC_PRIVATE_ID); + attachTextBox(IDC_AUTO_REFRESH_TIME); + attachTextBox(IDC_BUFFERSIZE); + attachTextBox(IDC_AUTO_SEARCH_LIMIT); + attachTextBox(IDC_SEARCH_HISTORY); + attachTextBox(IDC_BIND_ADDRESS); + attachTextBox(IDC_SOCKET_IN_BUFFER); + attachTextBox(IDC_SOCKET_OUT_BUFFER); + attachTextBox(IDC_MIN_SEGMENT_SIZE); } Advanced3Page::~Advanced3Page() { Modified: dcplusplus/trunk/win32/Appearance2Page.cpp =================================================================== --- dcplusplus/trunk/win32/Appearance2Page.cpp 2008-03-01 23:16:58 UTC (rev 1022) +++ dcplusplus/trunk/win32/Appearance2Page.cpp 2008-03-02 20:31:51 UTC (rev 1023) @@ -81,6 +81,8 @@ button = attachButton(IDC_BROWSE); button->onClicked(std::tr1::bind(&Appearance2Page::handleBrowseClicked, this)); + + attachTextBox(IDC_BEEPFILE); } Appearance2Page::~Appearance2Page() { Modified: dcplusplus/trunk/win32/AppearancePage.cpp =================================================================== --- dcplusplus/trunk/win32/AppearancePage.cpp 2008-03-01 23:16:58 UTC (rev 1022) +++ dcplusplus/trunk/win32/AppearancePage.cpp 2008-03-02 20:31:51 UTC (rev 1023) @@ -96,6 +96,9 @@ } languages->setSelectedIndex(selected); + + attachTextBox(IDC_DEFAULT_AWAY_MESSAGE); + attachTextBox(IDC_TIME_STAMPS_FORMAT); } AppearancePage::~AppearancePage() { Modified: dcplusplus/trunk/win32/CertificatesPage.cpp =================================================================== --- dcplusplus/trunk/win32/CertificatesPage.cpp 2008-03-01 23:16:58 UTC (rev 1022) +++ dcplusplus/trunk/win32/CertificatesPage.cpp 2008-03-02 20:31:51 UTC (rev 1023) @@ -50,10 +50,13 @@ PropPage::translate(handle(), texts); PropPage::read(handle(), items, listItems, ::GetDlgItem(handle(), IDC_TLS_OPTIONS)); + privateKeyFile = attachTextBox(IDC_TLS_PRIVATE_KEY_FILE); attachButton(IDC_BROWSE_PRIVATE_KEY)->onClicked(std::tr1::bind(&CertificatesPage::handleBrowsePrivateKeyClicked, this)); + certificateFile = attachTextBox(IDC_TLS_CERTIFICATE_FILE); attachButton(IDC_BROWSE_CERTIFICATE)->onClicked(std::tr1::bind(&CertificatesPage::handleBrowseCertificateClicked, this)); + trustedCertificatesPath = attachTextBox(IDC_TLS_TRUSTED_CERTIFICATES_PATH); attachButton(IDC_BROWSE_TRUSTED_PATH)->onClicked(std::tr1::bind(&CertificatesPage::handleBrowseTrustedPathClicked, this)); attachButton(IDC_GENERATE_CERTS)->onClicked(std::tr1::bind(&CertificatesPage::handleGenerateCertsClicked, this)); @@ -67,21 +70,21 @@ } void CertificatesPage::handleBrowsePrivateKeyClicked() { - tstring target = Text::toT(SETTING(TLS_PRIVATE_KEY_FILE)); + tstring target = privateKeyFile->getText(); if(WinUtil::browseFile(target, handle(), false, target)) - ::SetDlgItemText(handle(), IDC_TLS_PRIVATE_KEY_FILE, &target[0]); + privateKeyFile->setText(target); } void CertificatesPage::handleBrowseCertificateClicked() { - tstring target = Text::toT(SETTING(TLS_CERTIFICATE_FILE)); + tstring target = certificateFile->getText(); if(WinUtil::browseFile(target, handle(), false, target)) - ::SetDlgItemText(handle(), IDC_TLS_CERTIFICATE_FILE, &target[0]); + certificateFile->setText(target); } void CertificatesPage::handleBrowseTrustedPathClicked() { - tstring target = Text::toT(SETTING(TLS_TRUSTED_CERTIFICATES_PATH)); + tstring target = trustedCertificatesPath->getText(); if(WinUtil::browseDirectory(target, handle())) - ::SetDlgItemText(handle(), IDC_TLS_TRUSTED_CERTIFICATES_PATH, &target[0]); + trustedCertificatesPath->setText(target); } void CertificatesPage::handleGenerateCertsClicked() { Modified: dcplusplus/trunk/win32/CertificatesPage.h =================================================================== --- dcplusplus/trunk/win32/CertificatesPage.h 2008-03-01 23:16:58 UTC (rev 1022) +++ dcplusplus/trunk/win32/CertificatesPage.h 2008-03-02 20:31:51 UTC (rev 1023) @@ -35,6 +35,10 @@ static TextItem texts[]; static ListItem listItems[]; + WidgetTextBoxPtr privateKeyFile; + WidgetTextBoxPtr certificateFile; + WidgetTextBoxPtr trustedCertificatesPath; + void handleBrowsePrivateKeyClicked(); void handleBrowseCertificateClicked(); void handleBrowseTrustedPathClicked(); Modified: dcplusplus/trunk/win32/CommandDlg.cpp =================================================================== --- dcplusplus/trunk/win32/CommandDlg.cpp 2008-03-01 23:16:58 UTC (rev 1022) +++ dcplusplus/trunk/win32/CommandDlg.cpp 2008-03-02 20:31:51 UTC (rev 1023) @@ -28,7 +28,7 @@ #include "WinUtil.h" CommandDlg::CommandDlg(SmartWin::Widget* parent, int type_, int ctx_, const tstring& name_, const tstring& command_, const tstring& hub_) : - SmartWin::WidgetFactory<SmartWin::WidgetModalDialog>(parent), + WidgetFactory<SmartWin::WidgetModalDialog>(parent), separator(0), raw(0), chat(0), Modified: dcplusplus/trunk/win32/CommandDlg.h =================================================================== --- dcplusplus/trunk/win32/CommandDlg.h 2008-03-01 23:16:58 UTC (rev 1022) +++ dcplusplus/trunk/win32/CommandDlg.h 2008-03-02 20:31:51 UTC (rev 1023) @@ -20,8 +20,9 @@ #define DCPLUSPLUS_WIN32_COMMAND_DLG_H #include <dcpp/Util.h> +#include "WidgetFactory.h" -class CommandDlg : public SmartWin::WidgetFactory<SmartWin::WidgetModalDialog> +class CommandDlg : public WidgetFactory<SmartWin::WidgetModalDialog> { public: CommandDlg(SmartWin::Widget* parent, int type_ = 0, int ctx_ = 0, const tstring& name_ = Util::emptyStringT, const tstring& command_ = Util::emptyStringT, const tstring& hub_ = Util::emptyStringT); Modified: dcplusplus/trunk/win32/DCPlusPlus.rc =================================================================== --- dcplusplus/trunk/win32/DCPlusPlus.rc 2008-03-01 23:16:58 UTC (rev 1022) +++ dcplusplus/trunk/win32/DCPlusPlus.rc 2008-03-02 20:31:51 UTC (rev 1023) @@ -471,6 +471,8 @@ EDITTEXT IDC_PORT_TCP,230,28,29,14,ES_AUTOHSCROLL | ES_NUMBER LTEXT "UDP",IDC_SETTINGS_PORT_UDP,209,48,16,8 EDITTEXT IDC_PORT_UDP,230,45,30,14,ES_AUTOHSCROLL | ES_NUMBER + LTEXT "TLS",IDC_SETTINGS_PORT_TLS,209,64,21,8 + EDITTEXT IDC_PORT_TLS,230,61,30,14,ES_AUTOHSCROLL | ES_NUMBER LTEXT "External / WAN IP",IDC_SETTINGS_IP,59,59,68,8,NOT WS_GROUP EDITTEXT IDC_EXTERNAL_IP,59,69,99,14,ES_AUTOHSCROLL CONTROL "Don't allow hub/UPnP to override",IDC_OVERRIDE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,59,86,150,10 @@ -487,8 +489,6 @@ EDITTEXT IDC_SOCKS_PASSWORD,153,190,71,14,ES_AUTOHSCROLL CONTROL "Use SOCKS5 server to resolve hostnames",IDC_SOCKS_RESOLVE, "Button",BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP,59,207,165,10 - LTEXT "TLS",IDC_SETTINGS_PORT_TLS,209,64,21,8 - EDITTEXT IDC_PORT_TLS,230,61,30,14,ES_AUTOHSCROLL | ES_NUMBER END IDD_WINDOWSPAGE DIALOGEX 100, 0, 275, 225 Modified: dcplusplus/trunk/win32/DownloadPage.cpp =================================================================== --- dcplusplus/trunk/win32/DownloadPage.cpp 2008-03-01 23:16:58 UTC (rev 1022) +++ dcplusplus/trunk/win32/DownloadPage.cpp 2008-03-02 20:31:51 UTC (rev 1023) @@ -69,6 +69,12 @@ spinner = attachSpinner(IDC_SPEEDSPIN); spinner->setRange(0, 10000); + + attachTextBox(IDC_DOWNLOADDIR); + attachTextBox(IDC_TEMP_DOWNLOAD_DIRECTORY); + attachTextBox(IDC_DOWNLOADS); + attachTextBox(IDC_MAXSPEED); + attachTextBox(IDC_PROXY); } DownloadPage::~DownloadPage() { Modified: dcplusplus/trunk/win32/FavHubProperties.cpp =================================================================== --- dcplusplus/trunk/win32/FavHubProperties.cpp 2008-03-01 23:16:58 UTC (rev 1022) +++ dcplusplus/trunk/win32/FavHubProperties.cpp 2008-03-02 20:31:51 UTC (rev 1023) @@ -26,7 +26,7 @@ #include <dcpp/version.h> FavHubProperties::FavHubProperties(SmartWin::Widget* parent, FavoriteHubEntry *_entry) : - SmartWin::WidgetFactory<SmartWin::WidgetModalDialog>(parent), + WidgetFactory<SmartWin::WidgetModalDialog>(parent), name(0), address(0), description(0), Modified: dcplusplus/trunk/win32/FavHubProperties.h =================================================================== --- dcplusplus/trunk/win32/FavHubProperties.h 2008-03-01 23:16:58 UTC (rev 1022) +++ dcplusplus/trunk/win32/FavHubProperties.h 2008-03-02 20:31:51 UTC (rev 1023) @@ -22,7 +22,7 @@ #include <dcpp/forward.h> #include "WidgetFactory.h" -class FavHubProperties : public SmartWin::WidgetFactory<SmartWin::WidgetModalDialog> +class FavHubProperties : public WidgetFactory<SmartWin::WidgetModalDialog> { public: FavHubProperties(SmartWin::Widget* parent, FavoriteHubEntry *_entry); Modified: dcplusplus/trunk/win32/GeneralPage.cpp =================================================================== --- dcplusplus/trunk/win32/GeneralPage.cpp 2008-03-01 23:16:58 UTC (rev 1022) +++ dcplusplus/trunk/win32/GeneralPage.cpp 2008-03-02 20:31:51 UTC (rev 1023) @@ -64,6 +64,8 @@ nick->setTextLimit(35); nick->onTextChanged(std::tr1::bind(&GeneralPage::handleNickTextChanged, this)); + attachTextBox(IDC_EMAIL); + attachTextBox(IDC_DESCRIPTION)->setTextLimit(35); } Modified: dcplusplus/trunk/win32/LineDlg.cpp =================================================================== --- dcplusplus/trunk/win32/LineDlg.cpp 2008-03-01 23:16:58 UTC (rev 1022) +++ dcplusplus/trunk/win32/LineDlg.cpp 2008-03-02 20:31:51 UTC (rev 1023) @@ -21,7 +21,7 @@ #include "LineDlg.h" LineDlg::LineDlg(SmartWin::Widget* parent, const tstring& title_, const tstring& desc_, const tstring& initial_, bool password_) : - SmartWin::WidgetFactory<SmartWin::WidgetModalDialog>(parent), + WidgetFactory<SmartWin::WidgetModalDialog>(parent), title(title_), desc(desc_), initial(initial_), Modified: dcplusplus/trunk/win32/LineDlg.h =================================================================== --- dcplusplus/trunk/win32/LineDlg.h 2008-03-01 23:16:58 UTC (rev 1022) +++ dcplusplus/trunk/win32/LineDlg.h 2008-03-02 20:31:51 UTC (rev 1023) @@ -22,8 +22,9 @@ #include "resource.h" #include <dcpp/Util.h> +#include "WidgetFactory.h" -class LineDlg : public SmartWin::WidgetFactory<SmartWin::WidgetModalDialog> +class LineDlg : public WidgetFactory<SmartWin::WidgetModalDialog> { public: LineDlg(SmartWin::Widget* parent, const tstring& title_, const tstring& desc_, const tstring& initial_ = Util::emptyStringT, bool password_ = false); Modified: dcplusplus/trunk/win32/LogPage.cpp =================================================================== --- dcplusplus/trunk/win32/LogPage.cpp 2008-03-01 23:16:58 UTC (rev 1022) +++ dcplusplus/trunk/win32/LogPage.cpp 2008-03-02 20:31:51 UTC (rev 1023) @@ -65,22 +65,26 @@ options.push_back(pair); } - ::EnableWindow(::GetDlgItem(handle(), IDC_LOG_FORMAT), false); - ::EnableWindow(::GetDlgItem(handle(), IDC_LOG_FILE), false); + attachTextBox(IDC_LOG_DIRECTORY); - oldSelection = -1; - attachButton(IDC_BROWSE_LOG)->onClicked(std::tr1::bind(&LogPage::handleBrowseClicked, this)); - WidgetListViewPtr dataGrid = attachList(IDC_LOG_OPTIONS); - dataGrid->onRaw(std::tr1::bind(&LogPage::handleItemChanged, this, dataGrid, _1, _2), SmartWin::Message(WM_NOTIFY, LVN_ITEMCHANGED)); + dataGrid = attachList(IDC_LOG_OPTIONS); + dataGrid->onRaw(std::tr1::bind(&LogPage::handleItemChanged, this), SmartWin::Message(WM_NOTIFY, LVN_ITEMCHANGED)); + + logFormat = attachTextBox(IDC_LOG_FORMAT); + logFormat->setEnabled(false); + + logFile = attachTextBox(IDC_LOG_FILE); + logFile->setEnabled(false); + + oldSelection = -1; } LogPage::~LogPage() { } -void LogPage::write() -{ +void LogPage::write() { PropPage::write(handle(), items, listItems, ::GetDlgItem(handle(), IDC_LOG_OPTIONS)); const string& s = SETTING(LOG_DIRECTORY); @@ -115,27 +119,27 @@ } } -HRESULT LogPage::handleItemChanged(WidgetListViewPtr dataGrid, WPARAM wParam, LPARAM lParam) { +LRESULT LogPage::handleItemChanged() { getValues(); int sel = dataGrid->getSelectedIndex(); if(sel >= 0 && sel < LogManager::LAST) { - BOOL checkState = dataGrid->isChecked(sel) ? TRUE : FALSE; - ::EnableWindow(::GetDlgItem(handle(), IDC_LOG_FORMAT), checkState); - ::EnableWindow(::GetDlgItem(handle(), IDC_LOG_FILE), checkState); + bool checkState = dataGrid->isChecked(sel); + logFormat->setEnabled(checkState); + logFile->setEnabled(checkState); - ::SetDlgItemText(handle(), IDC_LOG_FILE, options[sel].first.c_str()); - ::SetDlgItemText(handle(), IDC_LOG_FORMAT, options[sel].second.c_str()); + logFile->setText(options[sel].first); + logFormat->setText(options[sel].second); //save the old selection so we know where to save the values oldSelection = sel; } else { - ::EnableWindow(::GetDlgItem(handle(), IDC_LOG_FORMAT), FALSE); - ::EnableWindow(::GetDlgItem(handle(), IDC_LOG_FILE), FALSE); + logFormat->setEnabled(false); + logFile->setEnabled(false); - ::SetDlgItemText(handle(), IDC_LOG_FILE, _T("")); - ::SetDlgItemText(handle(), IDC_LOG_FORMAT, _T("")); + logFile->setText(Util::emptyStringT); + logFormat->setText(Util::emptyStringT); } return 0; @@ -143,11 +147,7 @@ void LogPage::getValues() { if(oldSelection >= 0) { - TCHAR buf[512]; - - if(::GetDlgItemText(handle(), IDC_LOG_FILE, buf, 512) > 0) - options[oldSelection].first = buf; - if(::GetDlgItemText(handle(), IDC_LOG_FORMAT, buf, 512) > 0) - options[oldSelection].second = buf; + options[oldSelection].first = logFile->getText(); + options[oldSelection].second = logFormat->getText(); } } Modified: dcplusplus/trunk/win32/LogPage.h =================================================================== --- dcplusplus/trunk/win32/LogPage.h 2008-03-01 23:16:58 UTC (rev 1022) +++ dcplusplus/trunk/win32/LogPage.h 2008-03-02 20:31:51 UTC (rev 1023) @@ -36,6 +36,10 @@ static TextItem texts[]; static ListItem listItems[]; + WidgetListViewPtr dataGrid; + WidgetTextBoxPtr logFormat; + WidgetTextBoxPtr logFile; + int oldSelection; //store all log options here so we can discard them @@ -44,9 +48,8 @@ TStringPairList options; void handleBrowseClicked(); + LRESULT handleItemChanged(); - HRESULT handleItemChanged(WidgetListViewPtr dataGrid, WPARAM wParam, LPARAM lParam); - void getValues(); }; Modified: dcplusplus/trunk/win32/MDIChildFrame.h =================================================================== --- dcplusplus/trunk/win32/MDIChildFrame.h 2008-03-01 23:16:58 UTC (rev 1022) +++ dcplusplus/trunk/win32/MDIChildFrame.h 2008-03-02 20:31:51 UTC (rev 1023) @@ -127,9 +127,9 @@ bool reallyClose; - void addDlgCodeMessage(SmartWin::WidgetComboBox* widget) { + void addDlgCodeMessage(WidgetComboBox* widget) { widget->onRaw(std::tr1::bind(&ThisType::handleGetDlgCode, this, _1), SmartWin::Message(WM_GETDLGCODE)); - SmartWin::WidgetTextBox* text = widget->getTextBox(); + WidgetTextBox* text = widget->getTextBox(); if(text) text->onRaw(std::tr1::bind(&ThisType::handleGetDlgCode, this, _1), SmartWin::Message(WM_GETDLGCODE)); } @@ -139,9 +139,9 @@ widget->onRaw(std::tr1::bind(&ThisType::handleGetDlgCode, this, _1), SmartWin::Message(WM_GETDLGCODE)); } - void addColor(SmartWin::WidgetComboBox* widget) { + void addColor(WidgetComboBox* widget) { widget->onBackgroundColor(std::tr1::bind(&ThisType::handleBackgroundColor, this, _1)); - SmartWin::WidgetTextBox* text = widget->getTextBox(); + WidgetTextBox* text = widget->getTextBox(); if(text) text->onBackgroundColor(std::tr1::bind(&ThisType::handleBackgroundColor, this, _1)); } Modified: dcplusplus/trunk/win32/MagnetDlg.cpp =================================================================== --- dcplusplus/trunk/win32/MagnetDlg.cpp 2008-03-01 23:16:58 UTC (rev 1022) +++ dcplusplus/trunk/win32/MagnetDlg.cpp 2008-03-02 20:31:51 UTC (rev 1023) @@ -25,7 +25,7 @@ #include "WinUtil.h" MagnetDlg::MagnetDlg(SmartWin::Widget* parent, const tstring& aHash, const tstring& aFileName) : - SmartWin::WidgetFactory<SmartWin::WidgetModalDialog>(parent), + WidgetFactory<SmartWin::WidgetModalDialog>(parent), //queue(0), search(0), doNothing(0), @@ -44,8 +44,8 @@ setText(T_("MAGNET Link detected")); ::SetDlgItemText(handle(), IDC_MAGNET_TEXT, CT_("DC++ has detected a MAGNET link with a file hash that can be searched for on the Direct Connect network. What would you like to do?")); ::SetDlgItemText(handle(), IDC_MAGNET_HASH, CT_("File Hash:")); - ::SetDlgItemText(handle(), IDC_MAGNET_DISP_HASH, mHash.c_str()); - ::SetDlgItemText(handle(), IDC_MAGNET_NAME, CT_("Filename:")); + attachTextBox(IDC_MAGNET_DISP_HASH)->setText(mHash.c_str()); + attachTextBox(IDC_MAGNET_NAME)->setText(T_("Filename:")); ::SetDlgItemText(handle(), IDC_MAGNET_DISP_NAME, mFileName.c_str()); //queue = attachRadioButton(IDC_MAGNET_1_QUEUE); Modified: dcplusplus/trunk/win32/MagnetDlg.h =================================================================== --- dcplusplus/trunk/win32/MagnetDlg.h 2008-03-01 23:16:58 UTC (rev 1022) +++ dcplusplus/trunk/win32/MagnetDlg.h 2008-03-02 20:31:51 UTC (rev 1023) @@ -25,7 +25,9 @@ // and can take filename, size, etc. values from there. // - GargoyleMT -class MagnetDlg : public SmartWin::WidgetFactory<SmartWin::WidgetModalDialog> +#include "WidgetFactory.h" + +class MagnetDlg : public WidgetFactory<SmartWin::WidgetModalDialog> { public: MagnetDlg(SmartWin::Widget* parent, const tstring& aHash, const tstring& aFileName); Modified: dcplusplus/trunk/win32/MainWindow.cpp =================================================================== --- dcplusplus/trunk/win32/MainWindow.cpp 2008-03-01 23:16:58 UTC (rev 1022) +++ dcplusplus/trunk/win32/MainWindow.cpp 2008-03-02 20:31:51 UTC (rev 1023) @@ -254,7 +254,7 @@ help->appendItem(IDC_HELP_DONATE, T_("Donate (paypal)"), std::tr1::bind(&MainWindow::handleLink, this, _1)); } - mainMenu->attach(); + mainMenu->setMenu(); } void MainWindow::initToolbar() { Modified: dcplusplus/trunk/win32/NetworkPage.cpp =================================================================== --- dcplusplus/trunk/win32/NetworkPage.cpp 2008-03-01 23:16:58 UTC (rev 1022) +++ dcplusplus/trunk/win32/NetworkPage.cpp 2008-03-02 20:31:51 UTC (rev 1023) @@ -100,12 +100,17 @@ RADIO_ATTACH(IDC_SOCKS5); #undef RADIO_ATTACH -#define TEXTBOX_ATTACH(id) attachTextBox(id)->setTextLimit(250) - TEXTBOX_ATTACH(IDC_SOCKS_SERVER); - TEXTBOX_ATTACH(IDC_SOCKS_PORT); - TEXTBOX_ATTACH(IDC_SOCKS_USER); - TEXTBOX_ATTACH(IDC_SOCKS_PASSWORD); -#undef TEXTBOX_ATTACH +#define TEXTBOX_LIMIT(id) attachTextBox(id)->setTextLimit(250) + TEXTBOX_LIMIT(IDC_SOCKS_SERVER); + TEXTBOX_LIMIT(IDC_SOCKS_PORT); + TEXTBOX_LIMIT(IDC_SOCKS_USER); + TEXTBOX_LIMIT(IDC_SOCKS_PASSWORD); +#undef TEXTBOX_LIMIT + + attachTextBox(IDC_PORT_TCP); + attachTextBox(IDC_PORT_UDP); + attachTextBox(IDC_PORT_TLS); + attachTextBox(IDC_EXTERNAL_IP); } NetworkPage::~NetworkPage() { Modified: dcplusplus/trunk/win32/PropPage.cpp =================================================================== --- dcplusplus/trunk/win32/PropPage.cpp 2008-03-01 23:16:58 UTC (rev 1022) +++ dcplusplus/trunk/win32/PropPage.cpp 2008-03-02 20:31:51 UTC (rev 1023) @@ -23,8 +23,8 @@ #include "PropPage.h" #include <dcpp/SettingsManager.h> +#include "WinUtil.h" - PropPage::PropPage(SmartWin::Widget* parent) : WidgetFactory<SmartWin::WidgetDialog>(parent) { onRaw(std::tr1::bind(&PropPage::handleHelp, this, _1, _2), SmartWin::Message(WM_HELP)); } Modified: dcplusplus/trunk/win32/PropPage.h =================================================================== --- dcplusplus/trunk/win32/PropPage.h 2008-03-01 23:16:58 UTC (rev 1022) +++ dcplusplus/trunk/win32/PropPage.h 2008-03-02 20:31:51 UTC (rev 1023) @@ -22,7 +22,6 @@ #define SETTINGS_BUF_LEN 1024 #include "WidgetFactory.h" -#include "resource.h" class PropPage : public WidgetFactory<SmartWin::WidgetDialog> { Modified: dcplusplus/trunk/win32/QueuePage.cpp =================================================================== --- dcplusplus/trunk/win32/QueuePage.cpp 2008-03-01 23:16:58 UTC (rev 1022) +++ dcplusplus/trunk/win32/QueuePage.cpp 2008-03-02 20:31:51 UTC (rev 1023) @@ -84,6 +84,17 @@ PropPage::translate(handle(), texts); PropPage::read(handle(), items, 0, 0); PropPage::read(handle(), items, optionItems, ::GetDlgItem(handle(), IDC_OTHER_QUEUE_OPTIONS)); + + attachTextBox(IDC_PRIO_HIGHEST_SIZE); + attachTextBox(IDC_PRIO_NORMAL_SIZE); + attachTextBox(IDC_PRIO_HIGH_SIZE); + attachTextBox(IDC_PRIO_LOW_SIZE); + attachTextBox(IDC_AUTODROP_SPEED); + attachTextBox(IDC_AUTODROP_ELAPSED); + attachTextBox(IDC_AUTODROP_MINSOURCES); + attachTextBox(IDC_AUTODROP_INTERVAL); + attachTextBox(IDC_AUTODROP_INACTIVITY); + attachTextBox(IDC_AUTODROP_FILESIZE); } QueuePage::~QueuePage() { Modified: dcplusplus/trunk/win32/TransferView.h =================================================================== --- dcplusplus/trunk/win32/TransferView.h 2008-03-01 23:16:58 UTC (rev 1022) +++ dcplusplus/trunk/win32/TransferView.h 2008-03-02 20:31:51 UTC (rev 1023) @@ -25,6 +25,7 @@ #include <dcpp/QueueManagerListener.h> #include <dcpp/TaskQueue.h> #include <dcpp/forward.h> +#include <dcpp/MerkleTree.h> #include <dcpp/Util.h> #include "AspectSpeaker.h" Modified: dcplusplus/trunk/win32/UploadPage.cpp =================================================================== --- dcplusplus/trunk/win32/UploadPage.cpp 2008-03-01 23:16:58 UTC (rev 1022) +++ dcplusplus/trunk/win32/UploadPage.cpp 2008-03-02 20:31:51 UTC (rev 1023) @@ -103,6 +103,9 @@ spinner = attachSpinner(IDC_MIN_UPLOAD_SPIN); spinner->setRange(0, UD_MAXVAL); + + attachTextBox(IDC_MIN_UPLOAD_SPEED); + attachTextBox(IDC_SLOTS); } UploadPage::~UploadPage() { Added: dcplusplus/trunk/win32/WidgetComboBox.cpp =================================================================== --- dcplusplus/trunk/win32/WidgetComboBox.cpp (rev 0) +++ dcplusplus/trunk/win32/WidgetComboBox.cpp 2008-03-02 20:31:51 UTC (rev 1023) @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2001-2008 Jacek Sieka, arnetheduck on gmail point com + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#include "stdafx.h" + +#include "WidgetComboBox.h" + +WidgetComboBox::WidgetComboBox( SmartWin::Widget * parent ) : BaseType(parent), textBox(0) { +} + +WidgetComboBox::WidgetTextBoxPtr WidgetComboBox::getTextBox() { + if(!textBox) { + LONG_PTR style = ::GetWindowLongPtr(handle(), GWL_STYLE); + if((style & CBS_SIMPLE) == CBS_SIMPLE || (style & CBS_DROPDOWN) == CBS_DROPDOWN) { + HWND wnd = ::FindWindowEx(handle(), NULL, _T("EDIT"), NULL); + if(wnd && wnd != handle()) + textBox = SmartWin::WidgetCreator< WidgetTextBox >::attach(this, wnd); + } + } + return textBox; +} Added: dcplusplus/trunk/win32/WidgetComboBox.h =================================================================== --- dcplusplus/trunk/win32/WidgetComboBox.h (rev 0) +++ dcplusplus/trunk/win32/WidgetComboBox.h 2008-03-02 20:31:51 UTC (rev 1023) @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2001-2008 Jacek Sieka, arnetheduck on gmail point com + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#ifndef DCPLUSPLUS_WIN32_WIDGETCOMBOBOX_H_ +#define DCPLUSPLUS_WIN32_WIDGETCOMBOBOX_H_ + +#include "WidgetTextBox.h" + +class WidgetComboBox : public SmartWin::WidgetComboBox { +private: + typedef SmartWin::WidgetComboBox BaseType; +public: + typedef WidgetComboBox ThisType; + + typedef ThisType* ObjectType; + + explicit WidgetComboBox( SmartWin::Widget * parent ); + + typedef WidgetTextBox::ObjectType WidgetTextBoxPtr; + WidgetTextBoxPtr getTextBox(); + +private: + WidgetTextBoxPtr textBox; +}; + +#endif /*WIDGETCOMBOBOX_H_*/ Modified: dcplusplus/trunk/win32/WidgetFactory.h =================================================================== --- dcplusplus/trunk/win32/WidgetFactory.h 2008-03-01 23:16:58 UTC (rev 1022) +++ dcplusplus/trunk/win32/WidgetFactory.h 2008-03-02 20:31:51 UTC (rev 1023) @@ -20,6 +20,7 @@ #define DCPLUSPLUS_WIN32_WIDGETFACTORY2_H_ #include "WidgetTextBox.h" +#include "WidgetComboBox.h" #include "WidgetPaned.h" /** @@ -44,6 +45,20 @@ return SmartWin::WidgetCreator< WidgetTextBox >::attach( this, id ); } + /// ComboBox class type. + typedef ::WidgetComboBox WidgetComboBox; + + /// ComboBox object type. + typedef typename WidgetComboBox::ObjectType WidgetComboBoxPtr; + + WidgetComboBoxPtr createComboBox( const WidgetComboBox::Seed & cs = WidgetComboBox::Seed() ) { + return SmartWin::WidgetCreator< WidgetComboBox >::create( this, cs ); + } + + WidgetComboBoxPtr attachComboBox( unsigned id ) { + return SmartWin::WidgetCreator< WidgetComboBox >::attach( this, id ); + } + /// VPaned class type. typedef WidgetPaned< false > WidgetVPaned; Added: dcplusplus/trunk/win32/WidgetTextBox.cpp =================================================================== --- dcplusplus/trunk/win32/WidgetTextBox.cpp (rev 0) +++ dcplusplus/trunk/win32/WidgetTextBox.cpp 2008-03-02 20:31:51 UTC (rev 1023) @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2001-2008 Jacek Sieka, arnetheduck on gmail point com + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#include "stdafx.h" + +#include "WidgetTextBox.h" + +#include "WinUtil.h" + +WidgetTextBox::WidgetTextBox( SmartWin::Widget * parent ) : BaseType(parent), menuOpened(false) { + this->onLeftMouseDblClick(std::tr1::bind(&WidgetTextBox::handleLeftDblClick, this, _1)); + + this->onRaw(std::tr1::bind(&WidgetTextBox::handleEnterIdle, this, _1, _2), SmartWin::Message(WM_ENTERIDLE)); + this->onRaw(std::tr1::bind(&WidgetTextBox::handleMenuSelect, this, _1, _2), SmartWin::Message(WM_MENUSELECT)); +} + +void WidgetTextBox::handleLeftDblClick(const SmartWin::MouseEventResult& ev) { + WinUtil::parseDBLClick(textUnderCursor(ev.pos)); +} + +LRESULT WidgetTextBox::handleEnterIdle(WPARAM wParam, LPARAM lParam) { + if(wParam == MSGF_MENU && !menuOpened) { + menu = SmartWin::WidgetCreator<SmartWin::WidgetMenu>::attach(this, reinterpret_cast<HMENU>(::SendMessage(reinterpret_cast<HWND>(lParam), MN_GETHMENU, 0, 0)), WinUtil::Seeds::menu); + menuOpened = true; + } + return 0; +} + +LRESULT WidgetTextBox::handleMenuSelect(WPARAM wParam, LPARAM lParam) { + if((HIWORD(wParam) == 0xFFFF) && (lParam == 0)) + menuOpened = false; + return 0; +} Modified: dcplusplus/trunk/win32/WidgetTextBox.h =================================================================== --- dcplusplus/trunk/win32/WidgetTextBox.h 2008-03-01 23:16:58 UTC (rev 1022) +++ dcplusplus/trunk/win32/WidgetTextBox.h 2008-03-02 20:31:51 UTC (rev 1023) @@ -19,9 +19,7 @@ #ifndef DCPLUSPLUS_WIN32_WIDGETTEXTBOX_H_ #define DCPLUSPLUS_WIN32_WIDGETTEXTBOX_H_ -#include "WinUtil.h" - -/** Our own flavour of text boxes that handle double clicks */ +/** Our own flavour of text boxes that handle double clicks and have fancy menus */ class WidgetTextBox : public SmartWin::WidgetTextBox { private: typedef SmartWin::WidgetTextBox BaseType; @@ -30,14 +28,16 @@ typedef ThisType* ObjectType; - explicit WidgetTextBox( SmartWin::Widget * parent ) : BaseType(parent) { - this->onLeftMouseDblClick(std::tr1::bind(&WidgetTextBox::handleLeftDblClick, this, _1)); - } + explicit WidgetTextBox( SmartWin::Widget * parent ); private: - void handleLeftDblClick(const SmartWin::MouseEventResult& ev) { - WinUtil::parseDBLClick(textUnderCursor(ev.pos)); - } + void handleLeftDblClick(const SmartWin::MouseEventResult& ev); + + LRESULT handleEnterIdle(WPARAM wParam, LPARAM lParam); + LRESULT handleMenuSelect(WPARAM wParam, LPARAM lParam); + + SmartWin::WidgetMenu::ObjectType menu; + bool menuOpened; }; #endif /*WIDGETTEXTBOX_H_*/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |