------------------------------------------------------------ revno: 2293 committer: poy <[email protected]> branch nick: trunk timestamp: Sat 2010-11-13 17:49:19 +0100 message: remove unused class from dwt removed: dwt/include/dwt/Anchors.h dwt/include/dwt/Threads.h modified: dwt/include/dwt/dwt.hpp
-- lp:dcplusplus https://code.launchpad.net/~dcplusplus-team/dcplusplus/trunk Your team Dcplusplus-team is subscribed to branch lp:dcplusplus. To unsubscribe from this branch go to https://code.launchpad.net/~dcplusplus-team/dcplusplus/trunk/+edit-subscription
=== removed file 'dwt/include/dwt/Anchors.h' --- dwt/include/dwt/Anchors.h 2008-07-07 15:48:22 +0000 +++ dwt/include/dwt/Anchors.h 1970-01-01 00:00:00 +0000 @@ -1,217 +0,0 @@ -/* Copyright (c) 2006 - Carmi Grushko ([email protected]) - * Implements behaviour similar to Delphi's Control.Anchor - * Permission to use under the BSD license - */ - -#ifndef DWT_ANCHORS_H -#define DWT_ANCHORS_H - -#include "Widget.h" -#include <stdexcept> - -namespace dwt { - -/// AnchoredItem defined the possible parameters for the addAnchored function. -/** Each value describes where the widget will be anchored. "top" for example - * indicated that the widget will always remain the same distance from its parent's top. -*/ -struct AnchoredItem { - enum {top=1, bottom=2, left=4, right=8}; // Attach to that side. - enum { box = (top | bottom | left | right) }; // Attach to all sides; ie adjust to shape of parent. - enum { dialog = (bottom | right) }; // Adjust from lower right corner - enum { row = (left | right) }; // Span across the parent in a row. - enum { col = (top | bottom) }; // Span as a column on the parent. - - //Widget* widget; - HWND wnd; - HWND parent; - int anchors; - ::RECT edgeDistances; -}; - -/// Anchor fixed sized widgets to the sides of their parent window. -/** \ingroup WidgetLayout -* A helper class to do some auto-resizings of widgets in SmartWin++. -* -* Take for example the common dialog Open File. -* Whenever resized, the "Open" and "Cancel" buttons remain in the same location relative -* to the lower-right corner of the dialog. On the other hand, the control that lists all -* the files in the current directory, grows or shrinks according to the size of the dialog. -* -* That's what Anchors does. After the widgets were created, you add them to a special list, -* and in the event handler of OnSize (of your Window), you call a special method that -* resizes all the widgets you've added before. -* -* Supposed to be simple. -* Credit Carmi Grushko (venndigram) - 2006-10-02 20:38 -* -*/ -class AnchorManager { -public: - -/// Adds a widget to the vector of "anchored" widgets, according to the anchors bitmap. -/** The addAnchored() function measures and stores the distances from the sides of - * the widget's parent. It also stores the anchors bitmap which specifies which sides - * of the parent should be used in resizing the widget later on. <br> - * IN: widget: Any widget that has already been sized and placed in its parent's window. <br> - * anchors: a combination of AnchoredItem::left, AnchoredItem::right, AnchoredItem::top, AnchoredItem::bottom <br> - * Specifing "AnchoredItem::right" will ensure that the widget will always be the - * same distance from its parent's right edge. Specifing "AnchoredItem::row" will cause the widget to go - * from the left to the right side of the parent, keeping its original size. - * See the AnchoredItem structure above. - */ -void addAnchored( dwt::Widget* widget, int anchors ) -{ - if( widget == NULL || widget->handle() == 0 || - widget->getParent() == NULL || widget->getParent()->handle() == 0 ) - throw std::runtime_error( "AnchorManager: Invalid widget" ); - - AnchoredItem item; - item.wnd = widget->handle(); - item.parent = widget->getParent()->handle(); - item.anchors = anchors; - - // Calculating edgeDistances - ::RECT r1, r2; - ::POINT p1, p2; - GetWindowRect( item.wnd, &r1 ); - GetClientRect( item.parent, &r2 ); - p1.x = r2.left; - p1.y = r2.top; - p2.x = r2.right; - p2.y = r2.bottom; - ClientToScreen( item.parent, &p1 ); - ClientToScreen( item.parent, &p2 ); - r2.left = p1.x; - r2.top = p1.y; - r2.right = p2.x; - r2.bottom = p2.y; - - item.edgeDistances.top = r1.top - r2.top; - item.edgeDistances.left = r1.left - r2.left; - item.edgeDistances.bottom = r2.bottom - r1.bottom; - item.edgeDistances.right = r2.right - r1.right; - - anchored.push_back( item ); -} - -/// Resizes each Widget according to the new size of its parent window. -/** The addAnchored() function measures and stores the distances from the sides of - * the widget's parent. It also stores the anchors bitmap which specifies which sides - * of the parent should be used in resizing the widget later on. <br> - * IN: anchors: a combination of AnchoredItem::left, AnchoredItem::right, AnchoredItem::top, AnchoredItem::bottom - * See the AnchoredItem structure above for AnchoredItem::box and AnchoredItem::dialog - */ -void resizeAnchored() -{ - for( vector<AnchoredItem>::const_iterator i = anchored.begin(); - i != anchored.end(); ++i ) - { - resizeAnchoredItem( *i ); - } -} - - - -private: - std::vector<AnchoredItem> anchored; - - -void resizeAnchoredItem( const AnchoredItem& item ) -{ - ::RECT r1, r2, newR; - - int flags = SWP_NOZORDER; - if( ( (item.anchors & (AnchoredItem::left | AnchoredItem::right) ) == 0) && - ( (item.anchors & (AnchoredItem::top | AnchoredItem::bottom) ) == 0) ) - flags |= SWP_NOSIZE; - if( (item.anchors & AnchoredItem::left) && (item.anchors & AnchoredItem::top) ) - flags |= SWP_NOMOVE; - - if( (flags & SWP_NOSIZE) && (flags & SWP_NOMOVE) ) - return; // Nothing to do - - GetClientRect( item.parent, &r1 ); - GetWindowRect( item.wnd, &r2 ); - r2.right -= r2.left; - r2.bottom -= r2.top; - - if( item.anchors & AnchoredItem::left ) - { - if( item.anchors & AnchoredItem::right ) - { - newR.left = item.edgeDistances.left; - newR.right = r1.right - item.edgeDistances.right - item.edgeDistances.left; - } - else - { - newR.left = item.edgeDistances.left; - newR.right = r2.right; - } - } - else - { - if( item.anchors & AnchoredItem::right ) - { - newR.left = r1.right - item.edgeDistances.right - r2.right; - newR.right = r2.right; - } - else - { - - } - } - - if( item.anchors & AnchoredItem::top ) - { - if( item.anchors & AnchoredItem::bottom ) - { - newR.top = item.edgeDistances.top; - newR.bottom = r1.bottom - item.edgeDistances.bottom - item.edgeDistances.top; - } - else - { - newR.top = item.edgeDistances.top; - newR.bottom = r2.bottom; - } - } - else - { - if( item.anchors & AnchoredItem::bottom ) - { - newR.top = r1.bottom - item.edgeDistances.bottom - r2.bottom; - newR.bottom = r2.bottom; - } - else - { - - } - } - - - SetWindowPos( item.wnd, 0, - newR.left, newR.top, newR.right, newR.bottom, - flags ); -} - - -}; - -/* -* An example project (working with the Sally IDE & with a mingw32 makefile) is available online. -* -* (The anchors-sample.zip contains everything needed to compile, including the anchors source, and a compiled exe. -* -* http://t2.technion.ac.il/~scg/anchors-sample.zip -* http://t2.technion.ac.il/~scg/anchors-source.zip -* By: Carmi Grushko (venndigram) - 2006-10-02 20:38 -*/ - -} - - -#endif - //region SallyIDE Text Editor Settings -//Caret=(0,0) -//endregion - === removed file 'dwt/include/dwt/Threads.h' --- dwt/include/dwt/Threads.h 2010-02-11 21:44:13 +0000 +++ dwt/include/dwt/Threads.h 1970-01-01 00:00:00 +0000 @@ -1,243 +0,0 @@ -/* - DC++ Widget Toolkit - - Copyright (c) 2007-2010, 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 DWT_Threads_h -#define DWT_Threads_h - -#include "WindowsHeaders.h" -#include <vector> - -namespace dwt { - -namespace Utilities -{ -// begin namespace Utilities - -/// Class to ensure serialized access to resources shared among several threads. -/** Use this class to ensure serialized access to objects shared among multiple - * threads. To use instantiate and call lock which will deny other executing threads - * to be able to return after calling lock before the first thread have called - * unlock. <br> - * Related classes and functions. - * <ul> - * <li>class CriticalSection</li> - * <li>class Thread</li> - * <li>function Widget::getCriticalSection()</li> - * </ul> - */ -class CriticalSection -{ - CRITICAL_SECTION itsCs; - bool itsIsLocked; - - // DENY copying - CriticalSection( const CriticalSection & ); - -public: - /// Initializes critical section thread semantics - CriticalSection() - : itsIsLocked( false ) - { - ::InitializeCriticalSection( & itsCs ); - } - - // Deletes the critical section object - ~CriticalSection() - { - ::DeleteCriticalSection( & itsCs ); - } - - /// Lock the section - /** Only the first thread calling lock will return immediately, all other threads - * calling lock will be HALTED until the first thread have called unlock on the - * object. - */ - void lock() - { - ::EnterCriticalSection( & itsCs ); - itsIsLocked = true; - } - - /// Unlocks the section - /** No other thread will be able to return after calling lock until the thread - * who first called lock on the object have called unlock on the object. - */ - void unlock() - { - ::LeaveCriticalSection( & itsCs ); - itsIsLocked = false; - } - - /// Checks if object is locked - /** Returns true if somebody have aquired a lock on the object - */ - bool isLocked() - { - return itsIsLocked; - } -}; - -/// Helper class for aquiring a lock on a CriticalSection -/** Encapsulates lock in Constructor and unlock in DTOR to have RAII semantics on - * CriticalSection locking Related classes and functions. - * <ul> - * <li>class CriticalSection</li> - * <li>class Thread</li> - * <li>function Widget::getCriticalSection()</li> - * </ul> - */ -class ThreadLock -{ - CriticalSection & itsCs; - - // DENY copying - ThreadLock( const ThreadLock & rhs ); - -public: - /// Instantiate with a CriticalSection and it will automatically be locked and - /// freed in DTOR - ThreadLock( CriticalSection & cs ) - : itsCs( cs ) - { - itsCs.lock(); - } - - ~ThreadLock() - { - itsCs.unlock(); - } -}; - -/// Thread class, encapsulates a thread, its properties and its functions -/** This class encapsulates a thread and its functions. To actually create and start - * a thread use the fork function of the Widget you wish to create the thread - * within... - * <ul> - * <li>class CriticalSection</li> - * <li>class ThreadLock</li> - * <li>function Widget::getCriticalSection</li> - * <li>function Widgetxxx::fork</li> - * </ul> - */ -class Thread -{ - HANDLE itsThreadHandle; - -public: - /// Constructor taking a thread handle - explicit Thread( HANDLE thread ) - : itsThreadHandle( thread ) - {} - - /// Empty Constructor, doesn't alloc any resources or anything... - Thread() - : itsThreadHandle( 0 ) - {} - - /// Wait for multiple threads to finish - /** If you have for instance 3 different threads that must finish their current - * work before you can continue execution in another thread then call this - * function with the threads to wait for as the contents of the vector. Note! - * <br> - * If the thread you are waiting for is manipulating GUI in some way then you - * are likely to experience a deadlock here if you call this one on the main - * thread since the message handling will then be halted (since you called it on - * the main thread) - */ - static void waitForObjects( const std::vector< Thread > & threads ) - { - HANDLE * handles = new HANDLE[threads.size()]; - try - { - int idx = 0; - for ( std::vector< Thread >::const_iterator iter = threads.begin(); - iter != threads.end(); - ++iter ) - { - handles[idx++] = iter->itsThreadHandle; - } - ::WaitForMultipleObjects( static_cast< DWORD >( threads.size() ), handles, TRUE, INFINITE ); - delete [] handles; - } - catch ( ... ) - { - delete [] handles; - } - } - - static void waitForObject( const Thread & thread ) - { - ::WaitForSingleObject( thread.itsThreadHandle, INFINITE ); - } - - /// Suspends the thread until resume is called on the thread again. - /** Basically pauses the thread until resume is called on the thread - */ - void suspend() - { - ::SuspendThread( itsThreadHandle ); - } - - /// Resumes a thread again after suspend - /** Call suspend to stop the thread from executing and call resume to get it - * running again - */ - void resume() - { - ::ResumeThread( itsThreadHandle ); - } - - /// Terminates the thread !! (CAUTION) - /** WARNING!!! <br> - * This function will IMMEDIATELY terminate the thread, this means that the - * thread will NOT get to do ANY house cleaning at ALL. The thread will - * IMMEDIATELY be terminated and it will not get to do anything at all, for - * instance it will not be able to delete its heaped memory or finish its - * current line of execution etc... This is a LAST RESORT function only meant in - * very critical situations where you really need to terminate the thread and - * kill its execution! - */ - void terminate( unsigned long exitCode ) - { - ::TerminateThread( itsThreadHandle, exitCode ); - } -}; - -// end namespace Utilities -} - -} - -#endif === modified file 'dwt/include/dwt/dwt.hpp' --- dwt/include/dwt/dwt.hpp 2010-04-20 17:37:50 +0000 +++ dwt/include/dwt/dwt.hpp 2010-11-13 16:49:19 +0000 @@ -38,14 +38,12 @@ #include "WindowsHeaders.h" -#include "Anchors.h" #include "Application.h" #include "ClipBoard.h" #include "Cursor.h" #include "LibraryLoader.h" #include "Point.h" #include "Rectangle.h" -#include "Threads.h" #include "resources/Accelerator.h" #include "resources/Bitmap.h" #include "resources/Brush.h"
_______________________________________________ Mailing list: https://launchpad.net/~linuxdcpp-team Post to : [email protected] Unsubscribe : https://launchpad.net/~linuxdcpp-team More help : https://help.launchpad.net/ListHelp

