|
From: <arn...@us...> - 2008-03-18 20:03:47
|
Revision: 1045
http://dcplusplus.svn.sourceforge.net/dcplusplus/?rev=1045&view=rev
Author: arnetheduck
Date: 2008-03-18 13:03:39 -0700 (Tue, 18 Mar 2008)
Log Message:
-----------
patch + split out rectangle
Modified Paths:
--------------
dcplusplus/trunk/changelog.txt
dcplusplus/trunk/dcpp/DCPlusPlus.cpp
dcplusplus/trunk/smartwin/include/smartwin/BasicTypes.h
dcplusplus/trunk/smartwin/include/smartwin/CanvasClasses.h
dcplusplus/trunk/smartwin/include/smartwin/Place.h
dcplusplus/trunk/smartwin/include/smartwin/Widget.h
dcplusplus/trunk/smartwin/include/smartwin/aspects/AspectSizable.h
dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetCoolbar.h
dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetListViewEditBox.h
dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetStatusBar.h
dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetWindowBase.h
dcplusplus/trunk/smartwin/source/BasicTypes.cpp
dcplusplus/trunk/smartwin/source/CanvasClasses.cpp
dcplusplus/trunk/smartwin/source/Widget.cpp
dcplusplus/trunk/smartwin/source/widgets/WidgetMDIChild.cpp
dcplusplus/trunk/smartwin/source/widgets/WidgetMDIParent.cpp
dcplusplus/trunk/smartwin/source/widgets/WidgetMenu.cpp
dcplusplus/trunk/smartwin/source/widgets/WidgetTabSheet.cpp
dcplusplus/trunk/smartwin/source/widgets/WidgetTabView.cpp
dcplusplus/trunk/win32/CommandDlg.cpp
dcplusplus/trunk/win32/CommandDlg.h
dcplusplus/trunk/win32/DCPlusPlus.rc
dcplusplus/trunk/win32/HubFrame.cpp
dcplusplus/trunk/win32/MainWindow.cpp
dcplusplus/trunk/win32/MainWindow.h
dcplusplus/trunk/win32/PrivateFrame.cpp
dcplusplus/trunk/win32/PropPage.cpp
dcplusplus/trunk/win32/PropPage.h
dcplusplus/trunk/win32/PublicHubsFrame.cpp
dcplusplus/trunk/win32/SearchFrame.cpp
dcplusplus/trunk/win32/SettingsDialog.cpp
dcplusplus/trunk/win32/SettingsDialog.h
dcplusplus/trunk/win32/StatsFrame.cpp
dcplusplus/trunk/win32/WidgetPaned.h
Added Paths:
-----------
dcplusplus/trunk/smartwin/include/smartwin/Rectangle.h
dcplusplus/trunk/smartwin/include/smartwin/aspects/AspectHelp.h
dcplusplus/trunk/smartwin/source/Rectangle.cpp
Modified: dcplusplus/trunk/changelog.txt
===================================================================
--- dcplusplus/trunk/changelog.txt 2008-03-18 19:30:28 UTC (rev 1044)
+++ dcplusplus/trunk/changelog.txt 2008-03-18 20:03:39 UTC (rev 1045)
@@ -1,4 +1,9 @@
--- 0.705 2008-03-14 --
+-- 0.706 --
+* [L#202563] Fixed some missing translations
+* Fixed help links (thanks poy)
+* Use setenv on unix (thanks yakov suraev)
+
+-- 0.705 2008-03-14 --
* Several patches for better *nix compatibility of the core (thanks steven sheehy et al)
* Improve segmented download implementation
* Fix search request ip when using multiple ip's (thanks stanislav maslovski)
Modified: dcplusplus/trunk/dcpp/DCPlusPlus.cpp
===================================================================
--- dcplusplus/trunk/dcpp/DCPlusPlus.cpp 2008-03-18 19:30:28 UTC (rev 1044)
+++ dcplusplus/trunk/dcpp/DCPlusPlus.cpp 2008-03-18 20:03:39 UTC (rev 1045)
@@ -84,8 +84,12 @@
SettingsManager::getInstance()->load();
if(!SETTING(LANGUAGE).empty()) {
+#ifdef _WIN32
string language = "LANGUAGE=" + SETTING(LANGUAGE);
putenv(language.c_str());
+#else
+ setenv("LANGUAGE", SETTING(LANGUAGE).c_str(), true);
+#endif
// Apparently this is supposted to make gettext reload the message catalog...
_nl_msg_cat_cntr++;
}
Modified: dcplusplus/trunk/smartwin/include/smartwin/BasicTypes.h
===================================================================
--- dcplusplus/trunk/smartwin/include/smartwin/BasicTypes.h 2008-03-18 19:30:28 UTC (rev 1044)
+++ dcplusplus/trunk/smartwin/include/smartwin/BasicTypes.h 2008-03-18 20:03:39 UTC (rev 1045)
@@ -29,7 +29,6 @@
#define BasicTypes_h
#include "WindowsHeaders.h"
-#include "../../SmartUtil/tstring.h"
namespace SmartWin
{
@@ -38,7 +37,7 @@
/// POD structure for defining a point
/** Used in e.g. functions that take a mouse position etc...
*/
-struct Point : POINT
+struct Point : ::POINT
{
/// Constructor initializing the point with the given arguments.
/** Constructor initializing the structure with the given arguments. Takes x and
@@ -147,296 +146,6 @@
*/
bool operator != ( const Point & lhs, const Point & rhs );
-/// Data structure for defining a rectangle
-/** \ingroup WidgetLayout
- * The two Point data members, pos and size, define a rectangle. <br>
- * pos has the x,y position of the upper-left rectangle coordinate. <br>
- * size defines the x and y distance between the upper left and the lower right
- * coordinate. <br>
- * (pos + size) defines the lower right coordinate. <br>
- * Many window functions takes or returns a Rectangle. <br>
- * See the Layout module documentation for the use of Rectangle in positioning
- * widgets. <br>
- * The member functions are helpful in dividing large rectangles into smaller ones,
- * which is exactly what is needed to layout widgets in windows.
- */
-struct Rectangle
-{
- /// Position of the upper left corner of the Rectangle
- Point pos;
-
- /// Size of the Rectangle
- Point size;
-
- /// Constructor initializing the rectangle to (0, 0, 0, 0).
- /** Default constructor initializing everything to zero (0)
- */
- Rectangle();
-
- Rectangle(const RECT& rc);
-
- /// Constructor initializing the rectangle with a position and size.
- /** Note that the pSize is actually a size and NOT the lower right Point.
- */
- Rectangle( const Point & pPos, const Point & pSize );
-
- /// Constructor initializing the rectangle with a size.
- /** Note that the pSize is actually a size and NOT the lower right Point,
- * position is defaulted to 0,0.
- */
- explicit Rectangle( const Point & pSize );
-
- /// Constructor initializing the rectangle with longs instead of Points.
- /** ( x,y ) defines the upper right corner, ( x+width, y+height ) defines the
- * lower left corner.
- */
- Rectangle( long x, long y, long width, long height );
-
- /// Constructor creates a new rectangle with a fractional position and size of
- /// the old rect.
- /** It computes the new rectangle by using subrect(): <br>
- * (xFraction * size.x) is the amount to add to pos.x <br>
- * size.x *= widthFraction <br>
- * <br>
- * <pre>
- * Examples :
- * upper half is r2( r1, 0, 0, 1, 0.5 ) (Same position, same width, 0.5 height )
- * lower half is r2( r1, 0, 0.5, 1, 0.5 ) (y half down, same width, 0.5 height )
- * left half is r2( r1, 0, 0, 0.5, 1 ) (Same position, 0.5 width, same height )
- * right half is r2( r1, 0.5, 0, 0.5, 1 )
- * Lower right quarter is r2( r1, .5, .5, .5, .5)
- * center r2 inside r1 is r2( r1, .334, .334, .334, .334)
- * </pre>
- */
- Rectangle( const Rectangle & rect,
- double xFraction, double yFraction,
- double widthFraction, double heightFraction );
-
- operator RECT() const;
-
- /// Return the lower right point of the rectangle.
- /** Note that the rectangle is defined with pos, and a size, so we need this
- * function. <br>
- * Example: <br>
- * Rectangle r1( 10, 10, 100, 200 ); <br>
- * Point lr = r1.LowRight() <br>
- * gives lr.x = 110, lr.y = 210
- */
- Point lowRight() const;
-
- /// Creates a sub rectangle from an old rectangle.
- /** The pos is adjusted by the xFraction and yFraction of the
- * width and height of r. The size is also shrunk.
- * r1.SubRect( 0, 0, 1, 0.5 ) gives the upper half of r1 <br>
- * r1.SubRect( 0.5, 0, 0.5, 1 ) gives the right half of r1 <br>
- * r1.SubRect( .334, .334, .334, .334 ) centers r2 inside r1 <br>
- * r1.SubRect( .2, .2, .6, .6 ) also centers r2 inside r1 <br>
- * <pre>
- * OOOOOOOOOO is given by subRect( 0.3, 0.5, 0.4, 0.5 );
- * OOOOOOOOOO (x moved 30%, y moved 50% )
- * OOO++++OOO (x resized to 40%, y resized to 50% )
- * OOO++++OOO
- * </pre>
- */
- Rectangle subRect( double xFraction, double yFraction,
- double widthFraction, double heightFraction ) const;
-
- /// Size of the rectangle will be * factor, Position adjusted for the same center.
- /** Creates a smaller rectangle from the old rectangle. <br>
- * size.x *= factor, and pos.x is adjusted inwards to compensate. <br>
- * <pre>
- * ####
- * #### -> ##
- * #### ##
- * ####
- * </pre>
- * shows the effect of shrink( 0.5 ) <br>
- * shrink( long border ) is similar, but removes a constant border amount of
- * pixels on all sides.
- */
- Rectangle shrink( double factor ) const;
-
- /// Move inwards by xBorder and shrink the size by 2*xBorder
- /** A rectangle of #### changes to ##.<br>
- * The rectangle becomes smaller at the left and right, but has the same center.
- */
- Rectangle shrinkWidth( long xBorder ) const;
-
- /// Move inwards by yBorder and shrink the size by 2*yBorder
- /** <pre>
- * ####
- * #### -> ####
- * #### ####
- * ####
- *
- * </pre>
- * The rectangle becomes smaller at the top and bottom, but has the same center.
- */
- Rectangle shrinkHeight( long yBorder ) const;
-
- /// Move inwards by both xBorder and yBorder and shrink the size by 2*yBorder
- /// and 2*xBorder
- /** <pre>
- * ####
- * #### -> ##
- * #### ##
- * ####
- * </pre>
- * The rectangle shrinks, but has the same center.
- */
- Rectangle shrink( long xBorder, long yBorder ) const;
-
- /// For both dimensions, move inwards by Border and shrink the size by 2*Border
- /** We add border to the position, and subtract it twice from the size. Same as
- * shrink( long xBorder, long yBorder ); except the x and y border are the same.
- * shrink( double factor ) is similar, but expresses the new rectangle as a
- * fraction of the old.
- */
- Rectangle shrink( long border ) const;
-
- /// Return the upper rectangle of height y
- /** We return the upper rectangle of height y.<br>
- * Example: <br>
- * Rectangle rect( 0,0, 100, 100 );<br>
- * Rectangle t = rect.getTop( 10 );
- * Now: t.pos = 0,0 t.size = 100,10<br>
- */
- Rectangle getTop( long y ) const;
-
- /// Return the lower rectangle starting from y
- /** We return the lower rectangle of height y<br>
- * Example: <br>
- * Rectangle rect( 0,0, 100, 100 );<br>
- * Rectangle t = rect.getBottom( 10 );
- * Now: t.pos = 0,90 t.size = 100,10<br>
- */
- Rectangle getBottom( long y ) const;
-
- /// Return the left rectangle of widght x.
- /** We return the left rectangle of width x<br>
- * Example: <br>
- * Rectangle rect( 0, 0, 100, 100 );<br>
- * Rectangle t = rect.getLeft( 10 );
- * Now: t.pos= 0,0 t.size= 10,100<br>
- */
- Rectangle getLeft( long x ) const;
-
- /// Return the right rectangle of widght x.
- /** We return the right rectangle of width x<br>
- * Example: <br>
- * Rectangle rect( 0, 0, 100, 100 );<br>
- * Rectangle t = rect.getRight( 10 );
- * Now: t.pos= 90,0 t.size= 10,100<br>
- */
- Rectangle getRight( long x ) const;
-
- /// Move the Upper Left position by adjust, and keep the same Lower Right corner.
- /** <pre>
- * OOOOOO
- * OOOO++
- * OOOO++
- * </pre>
- * upperLeftAdjust( Point( 4, 1 ) ); will give the + rectangle afterwards.
- */
- Rectangle upperLeftAdjust( const Point & adjust ) const;
-
- /// Move the Lower Right position by adjust, and keep the same Upper Left corner.
- /** <pre>
- * ++++O
- * ++++O
- * OOOOO
- * </pre>
- * lowerRightAdjust( Point( -1, -1 ) ); will give the + rectangle afterwards.
- */
- Rectangle lowerRightAdjust( const Point & adjust ) const;
-
- /// Produce the Left portion of a Rectangle with portion width, same height,
- /// same position.
- /** If the original rectangle is as below: <br>
- * <pre>
- * XXXOOOOOOO
- * XXXOOOOOOO
- * XXXOOOOOOO
- * XXXOOOOOOO
- * </pre>
- * left( 0.3 )returns the X rectangle. <br>
- */
- Rectangle left( double portion = 0.5 ) const;
-
- /// Produce a Rectangle with the portion % width, same height, position moved to right.
- /** Produce a Rectangle with the portion % width, same height, position moved to right. <br>
- * <pre>
- * OOOOOOO###
- * OOOOOOO###
- * OOOOOOO###
- * OOOOOOO###
- * </pre>
- * right( 0.3 )returns the # rectangle. <br>
- */
- Rectangle right( double portion = 0.5 ) const;
-
- /// Produce a Rectangle with the portion % height, same width, same position.
- /** Produce a Rectangle with the portion % height, same width, same position. <br>
- * <pre>
- * ##########
- * ##########
- * OOOOOOOOOO
- * OOOOOOOOOO
- * </pre>
- * top( 0.5 ) or Top() returns the # rectangle. <br>
- */
- Rectangle top( double portion = 0.5 ) const;
-
- /// Produce a Rectangle with the portion % height, same width, position moved downwards.
- /** Produce a Rectangle with the portion % height, same width, position moved downwards. <br>
- * <pre>
- * OOOOOOOOOO
- * ##########
- * ##########
- * ##########
- * </pre>
- * Bottom( 0.75 ) returns the # rectangle. <br>
- */
- Rectangle bottom( double portion = 0.5 ) const;
-
- /// Produce a Rectangle with the 1/rows % height, same width, rowth position.
- /** Produce a Rectangle with the 1/rows % height, same width, rowth position. <br>
- * row0 <br>
- * row1 <-- Row( 1, 3 ) will return the "row1" rectangle.<br>
- * row2 <br>
- */
- Rectangle row( int row, int rows ) const;
-
- /// Produce a Rectangle with the 1/cols % width, same height, colth position.
- /** Produce a Rectangle with the 1/cols % width, same height, colth position. <br>
- *<br>
- * col0 col1 col2 col3 <br>
- *<br>
- *Col( 2, 4 ) will return the "col2" rectangle.<br>
- */
- Rectangle col( int column, int columns ) const;
-
- /// Produce a Rectangle with the top portion removed
- Rectangle cropTop( const int a_ToRemove ) const;
-
- /// Produce a Rectangle with the bottom portion removed
- Rectangle cropBottom( const int a_ToRemove ) const;
-
- /// Produce a Rectangle with the left portion removed
- Rectangle cropLeft( const int a_ToRemove ) const;
-
- /// Produce a Rectangle with the right portion removed
- Rectangle cropRight( const int a_ToRemove ) const;
-};
-
-bool operator==(const Rectangle& lhs, const Rectangle& rhs);
-
-/// \ingroup GlobalStuff
-/// "Default" Rectangle for window creation
-/** The system selects the default position/size for the window.
- */
-extern const Rectangle letTheSystemDecide;
-
// end namespace SmartWin
}
Modified: dcplusplus/trunk/smartwin/include/smartwin/CanvasClasses.h
===================================================================
--- dcplusplus/trunk/smartwin/include/smartwin/CanvasClasses.h 2008-03-18 19:30:28 UTC (rev 1044)
+++ dcplusplus/trunk/smartwin/include/smartwin/CanvasClasses.h 2008-03-18 20:03:39 UTC (rev 1045)
@@ -160,7 +160,7 @@
/// BitBlasts buffer into specified rectangle of source
void blast( const Rectangle & rectangle )
{
- if ( ::BitBlt( itsSource, rectangle.pos.x, rectangle.pos.y, rectangle.size.x, rectangle.size.y, this->CanvasType::itsHdc, rectangle.pos.x, rectangle.pos.y, SRCCOPY ) == FALSE )
+ if ( ::BitBlt( itsSource, rectangle.x(), rectangle.y(), rectangle.width(), rectangle.height(), this->CanvasType::itsHdc, rectangle.x(), rectangle.y(), SRCCOPY ) == FALSE )
throw xCeption( _T( "Couldn't bit blast in blast()" ) );
}
@@ -171,8 +171,8 @@
void drawBitmap( HBITMAP bitmap, const Rectangle & imageRectangle, COLORREF bitmapBackgroundColor, bool drawDisabled )
{
// bitmap size
- int width = imageRectangle.size.x;
- int height = imageRectangle.size.y;
+ int width = imageRectangle.width();
+ int height = imageRectangle.height();
// memory buffer for bitmap
HDC memoryDC = ::CreateCompatibleDC( this->CanvasType::itsHdc );
@@ -196,12 +196,12 @@
// bits in the destination DC. The magic ROP comes from the Charles
// Petzold's book
HGDIOBJ oldBrush = ::SelectObject( this->CanvasType::itsHdc, ::CreateSolidBrush( ::GetSysColor( COLOR_3DHILIGHT ) ) );
- ::BitBlt( this->CanvasType::itsHdc, imageRectangle.pos.x, imageRectangle.pos.y, width, height, maskDC, 0, 0, 0xB8074A );
+ ::BitBlt( this->CanvasType::itsHdc, imageRectangle.left(), imageRectangle.top(), width, height, maskDC, 0, 0, 0xB8074A );
// BitBlt the black bits in the monochrome bitmap into COLOR_3DSHADOW
// bits in the destination DC
::DeleteObject( ::SelectObject( this->CanvasType::itsHdc, ::CreateSolidBrush( ::GetSysColor( COLOR_3DSHADOW ) ) ) );
- ::BitBlt( this->CanvasType::itsHdc, imageRectangle.pos.x, imageRectangle.pos.y, width, height, maskDC, 0, 0, 0xB8074A );
+ ::BitBlt( this->CanvasType::itsHdc, imageRectangle.left(), imageRectangle.top(), width, height, maskDC, 0, 0, 0xB8074A );
::DeleteObject( ::SelectObject( this->CanvasType::itsHdc, oldBrush ) );
}
else // draw bitmap with transparency
@@ -217,8 +217,8 @@
// set bitmap background to black
::BitBlt( memoryDC, 0, 0, width, height, backMaskDC, 0, 0, SRCAND );
- ::BitBlt( this->CanvasType::itsHdc, imageRectangle.pos.x, imageRectangle.pos.y, width, height, maskDC, 0, 0, SRCAND );
- ::BitBlt( this->CanvasType::itsHdc, imageRectangle.pos.x, imageRectangle.pos.y, width, height, memoryDC, 0, 0, SRCPAINT );
+ ::BitBlt( this->CanvasType::itsHdc, imageRectangle.left(), imageRectangle.top(), width, height, maskDC, 0, 0, SRCAND );
+ ::BitBlt( this->CanvasType::itsHdc, imageRectangle.left(), imageRectangle.top(), width, height, memoryDC, 0, 0, SRCPAINT );
// clear
::DeleteObject( ::SelectObject( backMaskDC, oldBackMaskBitmap ) );
Modified: dcplusplus/trunk/smartwin/include/smartwin/Place.h
===================================================================
--- dcplusplus/trunk/smartwin/include/smartwin/Place.h 2008-03-18 19:30:28 UTC (rev 1044)
+++ dcplusplus/trunk/smartwin/include/smartwin/Place.h 2008-03-18 20:03:39 UTC (rev 1045)
@@ -26,9 +26,11 @@
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 Place_h
-#define Place_h
+#ifndef SMARTWIN_Place_h
+#define SMARTWIN_Place_h
+#include "Rectangle.h"
+
namespace SmartWin
{
// begin namespace SmartWin
@@ -77,10 +79,10 @@
/** This is suitable for cases in which you want place objects inside a rect
* that does NOT have to start at 0,0.
*/
- void setBoundsBorders( const SmartWin::Rectangle & rect, const int borderX = 0,
+ void setBoundsBorders( const Rectangle & rect, const int borderX = 0,
const int borderY = 0 )
{
- setBoundsBorders( rect.pos, rect.lowRight(), borderX, borderY );
+ setBoundsBorders( rect.upperLeft(), rect.lowRight(), borderX, borderY );
}
/// Set the bounds and borders from a size. (implied 0,0 position)
@@ -134,10 +136,10 @@
obj.pos = itsPos; // Return current position
- itsPos.x += obj.size.x + itsBorder.x; // Update next position.
- if ( itsMaxYInLine < obj.size.y )
+ itsPos.x += obj.width() + itsBorder.x; // Update next position.
+ if ( itsMaxYInLine < obj.height() )
{
- itsMaxYInLine = obj.size.y; // Update max y
+ itsMaxYInLine = obj.height(); // Update max y
}
}
@@ -173,17 +175,17 @@
*/
void positionBelow( struct Rectangle & obj )
{
- if ( obj.size.y <= itsLowRight.y )
+ if ( obj.height() <= itsLowRight.y )
{
newColIfNeeded( obj );
}
obj.pos = itsPos; // Return current position
- itsPos.y += obj.size.y + itsBorder.y; // Update next position.
- if ( itsMaxXInCol < obj.size.x )
+ itsPos.y += obj.height() + itsBorder.y; // Update next position.
+ if ( itsMaxXInCol < obj.width() )
{
- itsMaxXInCol = obj.size.x; // Update max x
+ itsMaxXInCol = obj.width(); // Update max x
}
}
@@ -236,10 +238,10 @@
void newRowIfNeeded( struct Rectangle & obj )
{
// If the obj's size is larger than the area's size, then skip the new row.
- if ( obj.size.x > ( itsLowRight.x - itsUpLeft.x ) ) return;
+ if ( obj.width() > ( itsLowRight.x - itsUpLeft.x ) ) return;
// If the object would extend past the area, then do a new row.
- if ( ( itsPos.x + obj.size.x + itsBorder.x ) > itsLowRight.x )
+ if ( ( itsPos.x + obj.width() + itsBorder.x ) > itsLowRight.x )
{
newRow();
}
@@ -247,7 +249,7 @@
void newColIfNeeded( struct Rectangle & obj )
{
- if ( ( itsPos.y + obj.size.y + itsBorder.y ) > itsLowRight.y )
+ if ( ( itsPos.y + obj.height() + itsBorder.y ) > itsLowRight.y )
{
newCol();
}
Added: dcplusplus/trunk/smartwin/include/smartwin/Rectangle.h
===================================================================
--- dcplusplus/trunk/smartwin/include/smartwin/Rectangle.h (rev 0)
+++ dcplusplus/trunk/smartwin/include/smartwin/Rectangle.h 2008-03-18 20:03:39 UTC (rev 1045)
@@ -0,0 +1,282 @@
+#ifndef SMARTWIN_RECTANGLE_H_
+#define SMARTWIN_RECTANGLE_H_
+
+#include "BasicTypes.h"
+
+namespace SmartWin {
+/// Data structure for defining a rectangle
+/** \ingroup WidgetLayout
+ * The member functions are helpful in dividing large rectangles into smaller ones,
+ * which is exactly what is needed to layout widgets in windows.
+ */
+struct Rectangle {
+ Point pos;
+
+ Point size;
+
+ /// Constructor initializing the rectangle to (0, 0, 0, 0).
+ /** Default constructor initializing everything to zero (0)
+ */
+ Rectangle() { };
+
+ Rectangle(const ::RECT& rc) : pos(rc.left, rc.top), size(rc.right - rc.left, rc.bottom - rc.top) { }
+
+ /// Constructor initializing the rectangle with a position and size.
+ /** Note that the pSize is actually a size and NOT the lower right Point.
+ */
+ Rectangle( const Point & pPos, const Point & pSize ) : pos(pPos), size(pSize) { }
+
+ /// Constructor initializing the rectangle with a size.
+ /** Top-left becomes (0, 0), while bottom-right is set to pSize.
+ */
+ explicit Rectangle( const Point & pSize ) : pos(0, 0), size(pSize) { }
+
+ operator ::RECT() const;
+
+ /// Constructor initializing the rectangle with longs instead of Points.
+ /** ( x,y ) defines the upper right corner, ( x+width, y+height ) defines the
+ * lower left corner.
+ */
+ Rectangle( long x, long y, long width, long height );
+
+ long left() const { return pos.x; }
+ long x() const { return left(); }
+
+ long top() const { return pos.y; }
+ long y() const {return top(); }
+
+ long right() const { return left() + width(); }
+
+ long bottom() const { return top() + height(); }
+
+ long width() const { return size.x; }
+
+ long height() const { return size.y; }
+
+ const Point& upperLeft() const { return pos; }
+
+ /// Return the lower right point of the rectangle.
+ /**
+ * Example: <br>
+ * Rectangle r1( 10, 10, 100, 200 ); <br>
+ * Point lr = r1.LowRight() <br>
+ * gives lr.x = 110, lr.y = 210
+ */
+ Point lowRight() const { return Point(x() + width(), y() + height()); }
+
+ /// Creates a sub rectangle from an old rectangle.
+ /** The pos is adjusted by the xFraction and yFraction of the
+ * width and height of r. The size is also shrunk.
+ * r1.SubRect( 0, 0, 1, 0.5 ) gives the upper half of r1 <br>
+ * r1.SubRect( 0.5, 0, 0.5, 1 ) gives the right half of r1 <br>
+ * r1.SubRect( .334, .334, .334, .334 ) centers r2 inside r1 <br>
+ * r1.SubRect( .2, .2, .6, .6 ) also centers r2 inside r1 <br>
+ * <pre>
+ * OOOOOOOOOO is given by subRect( 0.3, 0.5, 0.4, 0.5 );
+ * OOOOOOOOOO (x moved 30%, y moved 50% )
+ * OOO++++OOO (x resized to 40%, y resized to 50% )
+ * OOO++++OOO
+ * </pre>
+ */
+ Rectangle subRect( double xFraction, double yFraction,
+ double widthFraction, double heightFraction ) const;
+
+ /// Size of the rectangle will be * factor, Position adjusted for the same center.
+ /** Creates a smaller rectangle from the old rectangle. <br>
+ * size.x *= factor, and pos.x is adjusted inwards to compensate. <br>
+ * <pre>
+ * ####
+ * #### -> ##
+ * #### ##
+ * ####
+ * </pre>
+ * shows the effect of shrink( 0.5 ) <br>
+ * shrink( long border ) is similar, but removes a constant border amount of
+ * pixels on all sides.
+ */
+ Rectangle shrink( double factor ) const;
+
+ /// Move inwards by xBorder and shrink the size by 2*xBorder
+ /** A rectangle of #### changes to ##.<br>
+ * The rectangle becomes smaller at the left and right, but has the same center.
+ */
+ Rectangle shrinkWidth( long xBorder ) const;
+
+ /// Move inwards by yBorder and shrink the size by 2*yBorder
+ /** <pre>
+ * ####
+ * #### -> ####
+ * #### ####
+ * ####
+ *
+ * </pre>
+ * The rectangle becomes smaller at the top and bottom, but has the same center.
+ */
+ Rectangle shrinkHeight( long yBorder ) const;
+
+ /// Move inwards by both xBorder and yBorder and shrink the size by 2*yBorder
+ /// and 2*xBorder
+ /** <pre>
+ * ####
+ * #### -> ##
+ * #### ##
+ * ####
+ * </pre>
+ * The rectangle shrinks, but has the same center.
+ */
+ Rectangle shrink( long xBorder, long yBorder ) const;
+
+ /// For both dimensions, move inwards by Border and shrink the size by 2*Border
+ /** We add border to the position, and subtract it twice from the size. Same as
+ * shrink( long xBorder, long yBorder ); except the x and y border are the same.
+ * shrink( double factor ) is similar, but expresses the new rectangle as a
+ * fraction of the old.
+ */
+ Rectangle shrink( long border ) const;
+
+ /// Return the upper rectangle of height y
+ /** We return the upper rectangle of height y.<br>
+ * Example: <br>
+ * Rectangle rect( 0,0, 100, 100 );<br>
+ * Rectangle t = rect.getTop( 10 );
+ * Now: t.pos = 0,0 t.size = 100,10<br>
+ */
+ Rectangle getTop( long y ) const;
+
+ /// Return the lower rectangle starting from y
+ /** We return the lower rectangle of height y<br>
+ * Example: <br>
+ * Rectangle rect( 0,0, 100, 100 );<br>
+ * Rectangle t = rect.getBottom( 10 );
+ * Now: t.pos = 0,90 t.size = 100,10<br>
+ */
+ Rectangle getBottom( long y ) const;
+
+ /// Return the left rectangle of widght x.
+ /** We return the left rectangle of width x<br>
+ * Example: <br>
+ * Rectangle rect( 0, 0, 100, 100 );<br>
+ * Rectangle t = rect.getLeft( 10 );
+ * Now: t.pos= 0,0 t.size= 10,100<br>
+ */
+ Rectangle getLeft( long x ) const;
+
+ /// Return the right rectangle of widght x.
+ /** We return the right rectangle of width x<br>
+ * Example: <br>
+ * Rectangle rect( 0, 0, 100, 100 );<br>
+ * Rectangle t = rect.getRight( 10 );
+ * Now: t.pos= 90,0 t.size= 10,100<br>
+ */
+ Rectangle getRight( long x ) const;
+
+ /// Move the Upper Left position by adjust, and keep the same Lower Right corner.
+ /** <pre>
+ * OOOOOO
+ * OOOO++
+ * OOOO++
+ * </pre>
+ * upperLeftAdjust( Point( 4, 1 ) ); will give the + rectangle afterwards.
+ */
+ Rectangle upperLeftAdjust( const Point & adjust ) const;
+
+ /// Move the Lower Right position by adjust, and keep the same Upper Left corner.
+ /** <pre>
+ * ++++O
+ * ++++O
+ * OOOOO
+ * </pre>
+ * lowerRightAdjust( Point( -1, -1 ) ); will give the + rectangle afterwards.
+ */
+ Rectangle lowerRightAdjust( const Point & adjust ) const;
+
+ /// Produce the Left portion of a Rectangle with portion width, same height,
+ /// same position.
+ /** If the original rectangle is as below: <br>
+ * <pre>
+ * XXXOOOOOOO
+ * XXXOOOOOOO
+ * XXXOOOOOOO
+ * XXXOOOOOOO
+ * </pre>
+ * left( 0.3 )returns the X rectangle. <br>
+ */
+ Rectangle toleft( double portion = 0.5 ) const;
+
+ /// Produce a Rectangle with the portion % width, same height, position moved to right.
+ /** Produce a Rectangle with the portion % width, same height, position moved to right. <br>
+ * <pre>
+ * OOOOOOO###
+ * OOOOOOO###
+ * OOOOOOO###
+ * OOOOOOO###
+ * </pre>
+ * right( 0.3 )returns the # rectangle. <br>
+ */
+ Rectangle toright( double portion = 0.5 ) const;
+
+ /// Produce a Rectangle with the portion % height, same width, same position.
+ /** Produce a Rectangle with the portion % height, same width, same position. <br>
+ * <pre>
+ * ##########
+ * ##########
+ * OOOOOOOOOO
+ * OOOOOOOOOO
+ * </pre>
+ * top( 0.5 ) or Top() returns the # rectangle. <br>
+ */
+ Rectangle upper( double portion = 0.5 ) const;
+
+ /// Produce a Rectangle with the portion % height, same width, position moved downwards.
+ /** Produce a Rectangle with the portion % height, same width, position moved downwards. <br>
+ * <pre>
+ * OOOOOOOOOO
+ * ##########
+ * ##########
+ * ##########
+ * </pre>
+ * Bottom( 0.75 ) returns the # rectangle. <br>
+ */
+ Rectangle lower( double portion = 0.5 ) const;
+
+ /// Produce a Rectangle with the 1/rows % height, same width, rowth position.
+ /** Produce a Rectangle with the 1/rows % height, same width, rowth position. <br>
+ * row0 <br>
+ * row1 <-- Row( 1, 3 ) will return the "row1" rectangle.<br>
+ * row2 <br>
+ */
+ Rectangle row( int row, int rows ) const;
+
+ /// Produce a Rectangle with the 1/cols % width, same height, colth position.
+ /** Produce a Rectangle with the 1/cols % width, same height, colth position. <br>
+ *<br>
+ * col0 col1 col2 col3 <br>
+ *<br>
+ *Col( 2, 4 ) will return the "col2" rectangle.<br>
+ */
+ Rectangle col( int column, int columns ) const;
+
+ /// Produce a Rectangle with the top portion removed
+ Rectangle cropTop( const int a_ToRemove ) const;
+
+ /// Produce a Rectangle with the bottom portion removed
+ Rectangle cropBottom( const int a_ToRemove ) const;
+
+ /// Produce a Rectangle with the left portion removed
+ Rectangle cropLeft( const int a_ToRemove ) const;
+
+ /// Produce a Rectangle with the right portion removed
+ Rectangle cropRight( const int a_ToRemove ) const;
+};
+
+bool operator==(const Rectangle& lhs, const Rectangle& rhs);
+
+/// \ingroup GlobalStuff
+/// "Default" Rectangle for window creation
+/** The system selects the default position/size for the window.
+ */
+extern const Rectangle letTheSystemDecide;
+
+}
+
+#endif /*RECTANGLE_H_*/
Modified: dcplusplus/trunk/smartwin/include/smartwin/Widget.h
===================================================================
--- dcplusplus/trunk/smartwin/include/smartwin/Widget.h 2008-03-18 19:30:28 UTC (rev 1044)
+++ dcplusplus/trunk/smartwin/include/smartwin/Widget.h 2008-03-18 20:03:39 UTC (rev 1045)
@@ -29,8 +29,9 @@
#define Widget_h
#include "Atom.h"
-#include "BasicTypes.h"
+#include "Rectangle.h"
#include "Message.h"
+#include "../../SmartUtil/tstring.h"
#include <boost/noncopyable.hpp>
#include <memory>
Added: dcplusplus/trunk/smartwin/include/smartwin/aspects/AspectHelp.h
===================================================================
--- dcplusplus/trunk/smartwin/include/smartwin/aspects/AspectHelp.h (rev 0)
+++ dcplusplus/trunk/smartwin/include/smartwin/aspects/AspectHelp.h 2008-03-18 20:03:39 UTC (rev 1045)
@@ -0,0 +1,20 @@
+#ifndef ASPECTHELP_H_
+#define ASPECTHELP_H_
+
+namespace SmartWin {
+
+template<typename WidgetType>
+class AspectHelp {
+ typedef Dispatchers::VoidVoid<TRUE> Dispatcher;
+
+public:
+ void onHelp(const typename Dispatcher::F& f) {
+ static_cast<WidgetType*>(this)->setCallback(
+ Message( WM_HELP ), Dispatcher(f)
+ );
+ }
+};
+
+}
+
+#endif /*ASPECTHELP_H_*/
Modified: dcplusplus/trunk/smartwin/include/smartwin/aspects/AspectSizable.h
===================================================================
--- dcplusplus/trunk/smartwin/include/smartwin/aspects/AspectSizable.h 2008-03-18 19:30:28 UTC (rev 1044)
+++ dcplusplus/trunk/smartwin/include/smartwin/aspects/AspectSizable.h 2008-03-18 20:03:39 UTC (rev 1045)
@@ -323,7 +323,7 @@
void AspectSizable< WidgetType >::setBounds( const Rectangle & rect, bool updateWindow )
{
if ( ::MoveWindow( static_cast< WidgetType * >( this )->handle(),
- rect.pos.x, rect.pos.y, rect.size.x, rect.size.y, updateWindow ? TRUE : FALSE ) == 0 )
+ rect.x(), rect.y(), rect.width(), rect.height(), updateWindow ? TRUE : FALSE ) == 0 )
{
xCeption err( _T( "Couldn't reposition windows" ) );
throw err;
@@ -371,8 +371,8 @@
int yPos = rect.pos.y + border; // Start with current y and first border.
yPos += rownum * ( border + ySize ); // Accumulate other rows and borders
- ::MoveWindow( static_cast< WidgetType * >( this )->handle(), rect.pos.x, yPos,
- rect.size.x, ySize, updateWindow ? TRUE : FALSE );
+ ::MoveWindow( static_cast< WidgetType * >( this )->handle(), rect.x(), yPos,
+ rect.width(), ySize, updateWindow ? TRUE : FALSE );
}
template< class WidgetType >
@@ -380,11 +380,11 @@
int border, bool updateWindow )
{
int totBorder = border * ( cols + 1 );
- int xSize = ( rect.size.x - totBorder ) / cols;
- int xPos = rect.pos.x + border; // Start with current X and first border
+ int xSize = ( rect.width() - totBorder ) / cols;
+ int xPos = rect.x() + border; // Start with current X and first border
xPos += colnum * ( border + xSize ); // Accumulate other columns and borders
- ::MoveWindow( static_cast< WidgetType * >( this )->handle(), xPos, rect.pos.y, xSize, rect.size.y, updateWindow ? TRUE : FALSE );
+ ::MoveWindow( static_cast< WidgetType * >( this )->handle(), xPos, rect.y(), xSize, rect.height(), updateWindow ? TRUE : FALSE );
}
template< class WidgetType >
Modified: dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetCoolbar.h
===================================================================
--- dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetCoolbar.h 2008-03-18 19:30:28 UTC (rev 1044)
+++ dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetCoolbar.h 2008-03-18 20:03:39 UTC (rev 1045)
@@ -155,7 +155,7 @@
{
#ifdef PORT_ME
WidgetRadioButtonPtr retVal ( WidgetCreator< WidgetRadioButton >::create( parent, internal_::getTypedParentOrThrow < EventHandlerClass * >( this ), cs ) );
- retVal->setBounds( 0, 0, cs.location.size.x, cs.location.size.y );
+ retVal->setBounds( 0, 0, cs.location.width(), cs.location.size.y );
parent->addChild( retVal );
return retVal;
#endif
@@ -168,8 +168,8 @@
typename A_Seed::WidgetType::ObjectType sow( const /*typename*/ A_Seed & cs, const SmartUtil::tstring & label = _T("") )
{
typename A_Seed::WidgetType::ObjectType retVal ( WidgetCreator< typename A_Seed::WidgetType >::create( this, cs ) );
- retVal->setBounds( 0, 0, cs.location.size.x, cs.location.size.y );
- this->addChild( retVal, cs.location.size.x, cs.location.size.y, label );
+ retVal->setBounds( 0, 0, cs.location.width(), cs.location.size.y );
+ this->addChild( retVal, cs.location.width(), cs.location.size.y, label );
return retVal;
}
@@ -191,9 +191,9 @@
// ( const typename WidgetCoolbar< EventHandlerClass >::Seed & cs, const SmartUtil::tstring & label = _T("") )
//{
// typename WidgetCoolbar< EventHandlerClass >::ObjectType retVal (WidgetCreator< typename WidgetCoolbar< EventHandlerClass > >::create( this, cs ));
- // retVal->setBounds( 0, 0, cs.rect.size.x, cs.rect.size.y );
+ // retVal->setBounds( 0, 0, cs.rect.width(), cs.rect.size.y );
// //TODO: use something like cs.itsOpenedHeight
- // this->addChild( retVal, cs.rect.size.x, cs.rect.size.y, label );
+ // this->addChild( retVal, cs.rect.width(), cs.rect.size.y, label );
// return retVal;
//}
@@ -241,7 +241,7 @@
// They mess up with my macros to check delimiters ...
SmartWin::Rectangle rect;
if ( ::MoveWindow( this->handle(),
- rect.pos.x, rect.pos.y, rect.size.x, rect.size.y, TRUE ) == 0 )
+ rect.x(), rect.y(), rect.width(), rect.height(), TRUE ) == 0 )
{
xCeption err( _T( "Couldn't reposition windows" ) );
throw err;
Modified: dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetListViewEditBox.h
===================================================================
--- dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetListViewEditBox.h 2008-03-18 19:30:28 UTC (rev 1044)
+++ dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetListViewEditBox.h 2008-03-18 20:03:39 UTC (rev 1045)
@@ -95,7 +95,7 @@
WINDOWPOS * pos = ( WINDOWPOS * ) lPar;
pos->x = itsRect.pos.x;
pos->y = itsRect.pos.y;
- pos->cx = itsRect.size.x - itsRect.pos.x;
+ pos->cx = itsRect.width() - itsRect.pos.x;
pos->cy = itsRect.size.y - itsRect.pos.y;
} break;
#endif
Modified: dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetStatusBar.h
===================================================================
--- dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetStatusBar.h 2008-03-18 19:30:28 UTC (rev 1044)
+++ dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetStatusBar.h 2008-03-18 20:03:39 UTC (rev 1045)
@@ -208,7 +208,7 @@
// size after the main window is being resized.
SmartWin::Rectangle rect;
if ( ::MoveWindow( this->handle(),
- rect.pos.x, rect.pos.y, rect.size.x, rect.size.y, TRUE ) == 0 )
+ rect.x(), rect.y(), rect.width(), rect.height(), TRUE ) == 0 )
{
xCeption err( _T( "Couldn't reposition windows" ) );
throw err;
Modified: dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetWindowBase.h
===================================================================
--- dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetWindowBase.h 2008-03-18 19:30:28 UTC (rev 1044)
+++ dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetWindowBase.h 2008-03-18 20:03:39 UTC (rev 1045)
@@ -40,6 +40,7 @@
#include "../aspects/AspectEraseBackground.h"
#include "../aspects/AspectFocus.h"
#include "../aspects/AspectFont.h"
+#include "../aspects/AspectHelp.h"
#include "../aspects/AspectKeyboard.h"
#include "../aspects/AspectMouse.h"
#include "../aspects/AspectPainting.h"
@@ -93,6 +94,7 @@
public AspectEraseBackground< WidgetWindowBase< Policy > >,
public AspectFocus< WidgetWindowBase< Policy > >,
public AspectFont< WidgetWindowBase< Policy > >,
+ public AspectHelp< WidgetWindowBase< Policy > >,
public AspectKeyboard< WidgetWindowBase< Policy > >,
public AspectMouse< WidgetWindowBase< Policy > >,
public AspectPainting< WidgetWindowBase< Policy > >,
Modified: dcplusplus/trunk/smartwin/source/BasicTypes.cpp
===================================================================
--- dcplusplus/trunk/smartwin/source/BasicTypes.cpp 2008-03-18 19:30:28 UTC (rev 1044)
+++ dcplusplus/trunk/smartwin/source/BasicTypes.cpp 2008-03-18 20:03:39 UTC (rev 1045)
@@ -115,213 +115,5 @@
return pt;
}
-Rectangle::Rectangle()
- : pos( Point() ), size( Point() )
-{}
-
-Rectangle::Rectangle( const RECT & rc ) :
- pos(rc.left, rc.top), size(rc.right - rc.left, rc.bottom - rc.top)
-{
-}
-
-Rectangle::Rectangle( const Point & pPos, const Point & pSize )
- : pos( pPos ), size( pSize )
-{}
-
-Rectangle::Rectangle( const Point & pSize )
- : size( pSize )
-{}
-
-Rectangle::Rectangle( long x, long y, long width, long height )
- : pos( x, y ), size( width, height )
-{}
-
-Rectangle::Rectangle( const Rectangle & rect,
- double xFraction, double yFraction,
- double widthFraction, double heightFraction )
- : pos( rect.pos ), size( rect.size )
-{
- * this = subRect( xFraction, yFraction, widthFraction, heightFraction );
-}
-
-Rectangle::operator RECT() const
-{
- RECT retVal;
- retVal.left = pos.x;
- retVal.top = pos.y;
- retVal.right = pos.x + size.x;
- retVal.bottom = pos.y + size.y;
- return retVal;
-}
-
-Point Rectangle::lowRight() const
-{
- return Point( pos.x + size.x, pos.y + size.y );
-}
-
-Rectangle Rectangle::subRect( double xFraction, double yFraction,
- double widthFraction, double heightFraction ) const
-{
- Rectangle retVal;
- retVal.pos.x = pos.x + ( long )( xFraction * size.x );
- retVal.pos.y = pos.y + ( long )( yFraction * size.y );
-
- retVal.size.x = ( long )( size.x * widthFraction );
- retVal.size.y = ( long )( size.y * heightFraction );
- return retVal;
-}
-
-// Size of the rectangle will be * factor.
-// Position adjusted for the same center.
-Rectangle Rectangle::shrink( double factor ) const
-{
- double posFactor = ( 1.0 - factor ) * 0.5;
- return subRect( posFactor, posFactor, factor, factor );
-}
-
-Rectangle Rectangle::shrinkWidth( long xBorder ) const
-{
- Rectangle retVal = * this;
- retVal.pos.x = pos.x + xBorder;
- retVal.size.x = size.x - ( xBorder + xBorder );
- return retVal;
-}
-
-Rectangle Rectangle::shrinkHeight( long yBorder ) const
-{
- Rectangle retVal = * this;
- retVal.pos.y += yBorder;
- retVal.size.y -= ( yBorder + yBorder );
- return retVal;
-}
-
-Rectangle Rectangle::shrink( long border ) const
-{
- Rectangle retVal = shrinkWidth( border );
- retVal = retVal.shrinkHeight( border );
- return retVal;
-}
-
-Rectangle Rectangle::shrink( long xBorder, long yBorder ) const
-{
- Rectangle retVal = shrinkWidth( xBorder );
- retVal = retVal.shrinkHeight( yBorder );
- return retVal;
-}
-
-Rectangle Rectangle::getTop( long y ) const
-{
- Rectangle top = Rectangle( pos, Point( size.x, y ) );
- return top;
-}
-
-Rectangle Rectangle::getBottom( long y ) const
-{
- Rectangle bottom = Rectangle(
- Point( pos.x, pos.y + size.y - y ),
- Point( size.x, y ) );
- return bottom;
-}
-
-Rectangle Rectangle::getLeft( long x ) const
-{
- Rectangle left = Rectangle( pos, Point( x, size.y ) );
- return left;
-}
-
-Rectangle Rectangle::getRight( long x ) const
-{
- Rectangle bottom = Rectangle(
- Point( pos.x + size.x - x, pos.y ),
- Point( x, size.y ) );
- return bottom;
-}
-
-Rectangle Rectangle::upperLeftAdjust( const Point & adjust ) const
-{
- Rectangle retVal = * this;
- retVal.pos.x += adjust.x;
- retVal.pos.y += adjust.y;
- retVal.size.x -= adjust.x;
- retVal.size.y -= adjust.y;
- return retVal;
-}
-
-Rectangle Rectangle::lowerRightAdjust( const Point & adjust ) const
-{
- Rectangle retVal = * this;
- retVal.size.x += adjust.x;
- retVal.size.y += adjust.y;
- return retVal;
-}
-
-Rectangle Rectangle::left( double portion ) const
-{
- return Rectangle( pos.x, pos.y, ( long ) ( size.x * portion ), size.y );
-}
-
-Rectangle Rectangle::right( double portion ) const
-{
- return Rectangle( pos.x + ( long ) ( ( 1.0 - portion ) * size.x ), pos.y,
- ( long ) ( size.x * portion ), size.y );
-}
-
-Rectangle Rectangle::top( double portion ) const
-{
- return Rectangle( pos.x, pos.y, size.x, ( long ) ( size.y * portion ) );
-}
-
-Rectangle Rectangle::bottom( double portion ) const
-{
- return Rectangle( pos.x, pos.y + ( long ) ( ( 1.0 - portion ) * size.y ),
- size.x, ( long ) ( size.y * portion ) );
-}
-
-Rectangle Rectangle::row( int row, int rows ) const
-{
- int rowheight = size.y / rows;
- return Rectangle( pos.x, pos.y + ( row * rowheight ), size.x, rowheight );
-}
-
-Rectangle Rectangle::col( int column, int columns ) const
-{
- int colwidth = size.x / columns;
- return( Rectangle( pos.x + ( colwidth * column ), pos.y, colwidth, size.y ) );
-}
-
-Rectangle Rectangle::cropTop( const int a_ToRemove ) const
-{
- register int d_NewSize = size.y - a_ToRemove;
-
- return Rectangle( pos.x, pos.y + a_ToRemove, size.x, d_NewSize > 0 ? d_NewSize : 0 );
-}
-
-Rectangle Rectangle::cropBottom( const int a_ToRemove ) const
-{
- register int d_NewSize = size.y - a_ToRemove;
-
- return Rectangle( pos.x, pos.y, size.x, d_NewSize > 0 ? d_NewSize : 0 );
-}
-
-Rectangle Rectangle::cropLeft( const int a_ToRemove ) const
-{
- register int d_NewSize = size.x - a_ToRemove;
-
- return Rectangle( pos.x + a_ToRemove, pos.y, d_NewSize > 0 ? d_NewSize : 0, size.y );
-}
-
-Rectangle Rectangle::cropRight( const int a_ToRemove ) const
-{
- register int d_NewSize = size.x - a_ToRemove;
-
- return Rectangle( pos.x, pos.y, d_NewSize > 0 ? d_NewSize : 0, size.y );
-}
-
-bool operator==(const Rectangle& lhs, const Rectangle& rhs) {
- return lhs.pos == rhs.pos && lhs.size == rhs.size;
-}
-
-const SmartWin::Rectangle letTheSystemDecide( CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT );
-
// end namespace SmartWin
}
Modified: dcplusplus/trunk/smartwin/source/CanvasClasses.cpp
===================================================================
--- dcplusplus/trunk/smartwin/source/CanvasClasses.cpp 2008-03-18 19:30:28 UTC (rev 1044)
+++ dcplusplus/trunk/smartwin/source/CanvasClasses.cpp 2008-03-18 20:03:39 UTC (rev 1045)
@@ -91,7 +91,7 @@
SmartWin::Point lr( rect.lowRight() );
lineTo( lr.x, rect.pos.y );
lineTo( lr.x, lr.y );
- lineTo( rect.pos.x, lr.y );
+ lineTo( rect.x(), lr.y );
lineTo( rect.pos );
}
@@ -133,16 +133,15 @@
void Canvas::rectangle( const SmartWin::Rectangle & rect )
{
- rectangle( rect.pos.x,
- rect.pos.y,
- rect.pos.x + rect.size.x,
- rect.pos.y + rect.size.y );
+ rectangle( rect.left(),
+ rect.top(),
+ rect.right(),
+ rect.bottom() );
}
void Canvas::ellipse( const SmartWin::Rectangle & rect )
{
- if ( ! ::Ellipse( itsHdc, rect.pos.x, rect.pos.y,
- rect.pos.x + rect.size.x, rect.pos.y + rect.size.y ) )
+ if ( ! ::Ellipse( itsHdc, rect.left(), rect.top(), rect.right(), rect.bottom() ) )
{
xCeption x( _T( "Error in CanvasClasses ellipse" ) );
throw x;
@@ -162,10 +161,7 @@
void Canvas::fillRectangle( const SmartWin::Rectangle & rect, Brush & brush )
{
- // FIXED: RECT takes right/bottom for 3rd and 4th args
- RECT rc =
- { rect.pos.x, rect.pos.y, rect.pos.x + rect.size.x, rect.pos.y + rect.size.y
- };
+ RECT rc = rect;
::FillRect( itsHdc, & rc, brush.handle() );
}
@@ -194,9 +190,7 @@
int Canvas::drawText( const SmartUtil::tstring & text, const SmartWin::Rectangle & rect, unsigned format )
{
- RECT rc =
- { rect.pos.x, rect.pos.y, rect.pos.x + rect.size.x, rect.pos.y + rect.size.y
- };
+ RECT rc = rect;
int retVal = ::DrawText( itsHdc, text.c_str(), ( int ) text.length(), & rc, format );
if ( 0 == retVal )
{
Added: dcplusplus/trunk/smartwin/source/Rectangle.cpp
===================================================================
--- dcplusplus/trunk/smartwin/source/Rectangle.cpp (rev 0)
+++ dcplusplus/trunk/smartwin/source/Rectangle.cpp 2008-03-18 20:03:39 UTC (rev 1045)
@@ -0,0 +1,156 @@
+#include "../include/smartwin/Rectangle.h"
+
+namespace SmartWin {
+
+Rectangle::Rectangle( long x, long y, long width, long height )
+ : pos( x, y ), size( width, height )
+{}
+
+Rectangle::operator RECT() const
+{
+ RECT retVal = { left(), top(), right(), bottom() };
+ return retVal;
+}
+
+Rectangle Rectangle::subRect( double xFraction, double yFraction,
+ double widthFraction, double heightFraction ) const
+{
+ Rectangle retVal;
+ retVal.pos.x = pos.x + ( long )( xFraction * size.x );
+ retVal.pos.y = pos.y + ( long )( yFraction * size.y );
+
+ retVal.size.x = ( long )( size.x * widthFraction );
+ retVal.size.y = ( long )( size.y * heightFraction );
+ return retVal;
+}
+
+// Size of the rectangle will be * factor.
+// Position adjusted for the same center.
+Rectangle Rectangle::shrink( double factor ) const
+{
+ double posFactor = ( 1.0 - factor ) * 0.5;
+ return subRect( posFactor, posFactor, factor, factor );
+}
+
+Rectangle Rectangle::shrinkWidth( long xBorder ) const
+{
+ Rectangle retVal = * this;
+ retVal.pos.x = pos.x + xBorder;
+ retVal.size.x = size.x - ( xBorder + xBorder );
+ return retVal;
+}
+
+Rectangle Rectangle::shrinkHeight( long yBorder ) const
+{
+ Rectangle retVal = * this;
+ retVal.pos.y += yBorder;
+ retVal.size.y -= ( yBorder + yBorder );
+ return retVal;
+}
+
+Rectangle Rectangle::shrink( long border ) const
+{
+ Rectangle retVal = shrinkWidth( border );
+ retVal = retVal.shrinkHeight( border );
+ return retVal;
+}
+
+Rectangle Rectangle::shrink( long xBorder, long yBorder ) const
+{
+ Rectangle retVal = shrinkWidth( xBorder );
+ retVal = retVal.shrinkHeight( yBorder );
+ return retVal;
+}
+
+Rectangle Rectangle::getTop( long y ) const
+{
+ Rectangle top = Rectangle( pos, Point( size.x, y ) );
+ return top;
+}
+
+Rectangle Rectangle::getBottom( long y ) const
+{
+ Rectangle bottom = Rectangle(
+ Point( pos.x, pos.y + size.y - y ),
+ Point( size.x, y ) );
+ return bottom;
+}
+
+Rectangle Rectangle::getLeft( long x ) const
+{
+ Rectangle left = Rectangle( pos, Point( x, size.y ) );
+ return left;
+}
+
+Rectangle Rectangle::getRight( long x ) const
+{
+ Rectangle bottom = Rectangle(
+ Point( pos.x + size.x - x, pos.y ),
+ Point( x, size.y ) );
+ return bottom;
+}
+
+Rectangle Rectangle::upperLeftAdjust( const Point & adjust ) const
+{
+ Rectangle retVal = * this;
+ retVal.pos.x += adjust.x;
+ retVal.pos.y += adjust.y;
+ retVal.size.x -= adjust.x;
+ retVal.size.y -= adjust.y;
+ return retVal;
+}
+
+Rectangle Rectangle::lowerRightAdjust( const Point & adjust ) const
+{
+ Rectangle retVal = * this;
+ retVal.size.x += adjust.x;
+ retVal.size.y += adjust.y;
+ return retVal;
+}
+
+Rectangle Rectangle::row( int row, int rows ) const
+{
+ int rowheight = size.y / rows;
+ return Rectangle( pos.x, pos.y + ( row * rowheight ), size.x, rowheight );
+}
+
+Rectangle Rectangle::col( int column, int columns ) const
+{
+ int colwidth = size.x / columns;
+ return( Rectangle( pos.x + ( colwidth * column ), pos.y, colwidth, size.y ) );
+}
+
+Rectangle Rectangle::cropTop( const int a_ToRemove ) const
+{
+ register int d_NewSize = size.y - a_ToRemove;
+
+ return Rectangle( pos.x, pos.y + a_ToRemove, size.x, d_NewSize > 0 ? d_NewSize : 0 );
+}
+
+Rectangle Rectangle::cropBottom( const int a_ToRemove ) const
+{
+ register int d_NewSize = size.y - a_ToRemove;
+
+ return Rectangle( pos.x, pos.y, size.x, d_NewSize > 0 ? d_NewSize : 0 );
+}
+
+Rectangle Rectangle::cropLeft( const int a_ToRemove ) const
+{
+ register int d_NewSize = size.x - a_ToRemove;
+
+ return Rectangle( pos.x + a_ToRemove, pos.y, d_NewSize > 0 ? d_NewSize : 0, size.y );
+}
+
+Rectangle Rectangle::cropRight( const int a_ToRemove ) const
+{
+ register int d_NewSize = size.x - a_ToRemove;
+
+ return Rectangle( pos.x, pos.y, d_NewSize > 0 ? d_NewSize : 0, size.y );
+}
+
+bool operator==(const Rectangle& lhs, const Rectangle& rhs) {
+ return lhs.pos == rhs.pos && lhs.size == rhs.size;
+}
+
+const SmartWin::Rectangle letTheSystemDecide( CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT );
+}
Modified: dcplusplus/trunk/smartwin/source/Widget.cpp
===================================================================
--- dcplusplus/trunk/smartwin/source/Widget.cpp 2008-03-18 19:30:28 UTC (rev 1044)
+++ dcplusplus/trunk/smartwin/source/Widget.cpp 2008-03-18 20:03:39 UTC (rev 1045)
@@ -92,7 +92,7 @@
cs.className,
cs.caption.c_str(),
cs.style,
- cs.location.pos.x, cs.location.pos.y, cs.location.size.x, cs.location.size.y,
+ cs.location.x(), cs.location.y(), cs.location.width(), cs.location.height(),
itsParent ? itsParent->handle() : 0,
cs.menuHandle,
Application::instance().getAppHandle(),
Modified: dcplusplus/trunk/smartwin/source/widgets/WidgetMDIChild.cpp
===================================================================
--- dcplusplus/trunk/smartwin/source/widgets/WidgetMDIChild.cpp 2008-03-18 19:30:28 UTC (rev 1044)
+++ dcplusplus/trunk/smartwin/source/widgets/WidgetMDIChild.cpp 2008-03-18 20:03:39 UTC (rev 1045)
@@ -18,7 +18,7 @@
HWND wnd = ::CreateMDIWindow( windowClass->getClassName(),
cs.caption.c_str(),
cs.style,
- cs.location.pos.x, cs.location.pos.y, cs.location.size.x, cs.location.size.y,
+ cs.location.x(), cs.location.y(), cs.location.width(), cs.location.height(),
getParent()->handle(),
Application::instance().getAppHandle(),
reinterpret_cast< LPARAM >( static_cast< Widget * >( this ) ) );
Modified: dcplusplus/trunk/smartwin/source/widgets/WidgetMDIParent.cpp
===================================================================
--- dcplusplus/trunk/smartwin/source/widgets/WidgetMDIParent.cpp 2008-03-18 19:30:28 UTC (rev 1044)
+++ dcplusplus/trunk/smartwin/source/widgets/WidgetMDIParent.cpp 2008-03-18 20:03:39 UTC (rev 1045)
@@ -20,7 +20,7 @@
cs.className,
cs.caption.c_str(),
cs.style,
- cs.location.pos.x, cs.location.pos.y, cs.location.size.x, cs.location.size.y,
+ cs.location.x(), cs.location.y(), cs.location.width(), cs.location.height(),
this->getParent() ? this->getParent()->handle() : 0,
NULL,
Application::instance().getAppHandle(),
Modified: dcplusplus/trunk/smartwin/source/widgets/WidgetMenu.cpp
===================================================================
--- dcplusplus/trunk/smartwin/source/widgets/WidgetMenu.cpp 2008-03-18 19:30:28 UTC (rev 1044)
+++ dcplusplus/trunk/smartwin/source/widgets/WidgetMenu.cpp 2008-03-18 20:03:39 UTC (rev 1045)
@@ -585,14 +585,14 @@
// center in the item rectangle
rectangle.pos.x += stripWidth + textIconGap;
- rectangle.pos.y += rectangle.size.y / 2 - 1;
+ rectangle.pos.y += rectangle.width() / 2 - 1;
// select color
Canvas::Selector select(canvas, *PenPtr(new Pen(::GetSysColor( COLOR_GRAYTEXT ))));
// draw separator
- canvas.moveTo( rectangle.pos.x, rectangle.pos.y );
- canvas.lineTo( rectangle.size.x, rectangle.pos.y );
+ canvas.moveTo( rectangle.left(), rectangle.top() );
+ canvas.lineTo( rectangle.right(), rectangle.bottom() );
} // end if
else // not a seperator, then draw item text and icon
{
@@ -665,7 +665,7 @@
// adjust icon rectangle
imageRectangle.pos.x += ( stripWidth - imageSize.x ) / 2;
- imageRectangle.pos.y += ( itemRectangle.size.y - imageSize.y ) / 2;
+ imageRectangle.pos.y += ( itemRectangle.width() - imageSize.y ) / 2;
if ( image == NULL ) // drawing item without icon
{
@@ -687,7 +687,7 @@
const int adjustment = 2; // adjustment for mark to be in the center
// bit - blast into out canvas
- ::BitBlt( canvas.handle(), imageRectangle.pos.x + adjustment, imageRectangle.pos.y, imageSize.x, imageSize.y, memoryDC, 0, 0, SRCAND );
+ ::BitBlt( canvas.handle(), imageRectangle.x() + adjustment, imageRectangle.y(), imageSize.x, imageSize.y, memoryDC, 0, 0, SRCAND );
// delete memory dc
::DeleteObject( ::SelectObject( memoryDC, old ) );
Modified: dcplusplus/trunk/smartwin/source/widgets/WidgetTabSheet.cpp
===================================================================
--- dcplusplus/trunk/smartwin/source/widgets/WidgetTabSheet.cpp 2008-03-18 19:30:28 UTC (rev 1044)
+++ dcplusplus/trunk/smartwin/source/widgets/WidgetTabSheet.cpp 2008-03-18 20:03:39 UTC (rev 1045)
@@ -45,9 +45,9 @@
if(cutBorders) {
Rectangle rctabs(getClientAreaSize());
// Get rid of ugly border...assume y border is the same as x border
- long border = (rctabs.size.x - rect.size.x) / 2;
- rect.pos.x = rctabs.pos.x;
- rect.size.x = rctabs.size.x;
+ long border = (rctabs.width() - rect.width()) / 2;
+ rect.pos.x = rctabs.x();
+ rect.size.x = rctabs.width();
rect.size.y += border;
}
return rect;
Modified: dcplusplus/trunk/smartwin/source/widgets/WidgetTabView.cpp
===================================================================
--- dcplusplus/trunk/smartwin/source/widgets/WidgetTabView.cpp 2008-03-18 19:30:28 UTC (rev 1044)
+++ dcplusplus/trunk/smartwin/source/widgets/WidgetTabView.cpp 2008-03-18 20:03:39 UTC (rev 1045)
@@ -126,8 +126,9 @@
oldW->sendMessage(WM_ACTIVATE, WA_INACTIVE, reinterpret_cast<LPARAM>(newW->handle()));
::ShowWindow(oldW->handle(), SW_HIDE);
}
+
::ShowWindow(newW->handle(), SW_SHOW);
- ::MoveWindow(newW->handle(), clientSize.pos.x, clientSize.pos.y, clientSize.size.x, clientSize.size.y, FALSE);
+ ::MoveWindow(newW->handle(), clientSize.x(), clientSize.y(), clientSize.width(), clientSize.height(), FALSE);
newW->sendMessage(WM_ACTIVATE, WA_ACTIVE, oldW ? reinterpret_cast<LPARAM>(oldW->handle()) : 0);
sendMessage(WM_SETREDRAW, TRUE);
@@ -212,7 +213,7 @@
if(!(tmp == clientSize)) {
int i = tab->getSelectedIndex();
if(i != -1) {
- ::MoveWindow(getTabInfo(i)->w->handle(), tmp.pos.x, tmp.pos.y, tmp.size.x, tmp.size.y, TRUE);
+ ::MoveWindow(getTabInfo(i)->w->handle(), tmp.x(), tmp.y(), tmp.width(), tmp.height(), TRUE);
}
clientSize = tmp;
}
Modified: dcplusplus/trunk/win32/CommandDlg.cpp
===================================================================
--- dcplusplus/trunk/win32/CommandDlg.cpp 2008-03-18 19:30:28 UTC (rev 1044)
+++ dcplusplus/trunk/win32/CommandDlg.cpp 2008-03-18 20:03:39 UTC (rev 1045)
@@ -52,7 +52,7 @@
{
onInitDialog(std::tr1::bind(&CommandDlg::handleInitDialog, this));
onFocus(std::tr1::bind(&CommandDlg::handleFocus, this));
- onRaw(std::tr1::bind(&CommandDlg::handleHelp, this), SmartWin::Message(WM_HELP));
+ onHelp(std::tr1::bind(&CommandDlg::handleHelp, this));
}
CommandDlg::~CommandDlg() {
@@ -118,15 +118,23 @@
bool bOpenHelp = BOOLSETTING(OPEN_USER_CMD_HELP);
openHelp->setChecked(bOpenHelp);
- attachButton(IDOK)->onClicked(std::tr1::bind(&CommandDlg::handleOKClicked, this));
+ {
+ WidgetButtonPtr button = attachButton(IDOK);
+ button->setText(T_("OK"));
+ button->onClicked(std::tr1::bind(&CommandDlg::handleOKClicked, this));
- attachButton(IDCANCEL)->onClicked(std::tr1::bind(&CommandDlg::endDialog, this, IDCANCEL));
+ button = attachButton(IDCANCEL);
+ button->setText(T_("Cancel"));
+ button->onClicked(std::tr1::bind(&CommandDlg::endDialog, this, IDCANCEL));
- attachButton(IDHELP)->onClicked(std::tr1::bind(&CommandDlg::handleHelpClicked, this));
+ button = attachButton(IDHELP);
+ button->setText(T_("Help"));
+ button->onClicked(std::tr1::bind(&CommandDlg::handleHelp, this));
+ }
if(bOpenHelp) {
// launch the help file, instead of having the help in the dialog
- HtmlHelp(handle(), WinUtil::getHelpFile().c_str(), HH_HELP_CONTEXT, IDD_UCPAGE);
+ handleHelp();
}
if(type == UserCommand::TYPE_SEPARATOR) {
@@ -191,6 +199,10 @@
nameBox->setFocus();
}
+void CommandDlg::handleHelp() {
+ ::HtmlHelp(handle(), WinUtil::getHelpFile().c_str(), HH_HELP_CONTEXT, IDD_UCPAGE);
+}
+
void CommandDlg::handleTypeChanged() {
updateType();
updateCommand();
@@ -224,10 +236,6 @@
endDialog(IDOK);
}
-void CommandDlg::handleHelpClicked() {
- HtmlHelp(handle(), WinUtil::getHelpFile().c_str(), HH_HELP_CONTEXT, IDD_UCPAGE);
-}
-
void CommandDlg::updateType() {
if(separator->getChecked()) {
type = 0;
@@ -273,8 +281,3 @@
break;
}
}
-
-LRESULT CommandDlg::handleHelp() {
- HtmlHelp(handle(), WinUtil::getHelpFile().c_str(), HH_HELP_CONTEXT, IDD_UCPAGE);
- return 0;
-}
Modified: dcplusplus/trunk/win32/CommandDlg.h
===================================================================
--- dcplusplus/trunk/win32/CommandDlg.h 2008-03-18 19:30:28 UTC (rev 1044)
+++ dcplusplus/trunk/win32/CommandDlg.h 2008-03-18 20:03:39 UTC (rev 1045)
@@ -61,10 +61,9 @@
bool handleInitDialog();
void handleFocus();
- LRESULT handleHelp();
+ void handleHelp();
void handleTypeChanged();
void handleOKClicked();
- void handleHelpClicked();
void updateType();
void updateCommand();
Modified: dcplusplus/trunk/win32/DCPlusPlus.rc
===================================================================
--- dcplusplus/trunk/win32/DCPlusPlus.rc 2008-03-18 19:30:28 UTC (rev 1044)
+++ dcplusplus/trunk/win32/DCPlusPlus.rc 2008-03-18 20:03:39 UTC (rev 1045)
@@ -583,8 +583,9 @@
FONT 8, "MS Shell Dlg", 0, 0, 0x0
BEGIN
CONTROL "",IDC_SETTINGS_PAGES,"SysTreeView32",TVS_HASBUTTONS | TVS_HASLINES | TVS_SHOWSELALWAYS | TVS_FULLROWSELECT | TVS_LINESATROOT | WS_BORDER | WS_TABSTOP,3,3,90,225
- DEFPUSHBUTTON "OK",IDOK,265,255,50,14
- PUSHBUTTON "Cancel",IDCANCEL,318,255,50,14
+ DEFPUSHBUTTON "OK",IDOK,212,255,50,14
+ PUSHBUTTON "Cancel",IDCANCEL,265,255,50,14
+ PUSHBUTTON "Help",IDHELP,318,255,50,14
END
/////////////////////////////////////////////////////////////////////////////
Modified: dcplusplus/trunk/win32/HubFrame.cpp
===================================================================
--- dcplusplus/trunk/win32/HubFrame.cpp 2008-03-18 19:30:28 UTC (rev 1044)
+++ dcplusplus/trunk/win32/HubFrame.cpp 2008-03-18 20:03:39 UTC (rev 1045)
@@ -214,17 +214,17 @@
mapWidget(STATUS_SHOW_USERS, showUsers);
int ymessage = message->getTextSize(_T("A")).y + 10;
- int xfilter = showUsers->getChecked() ? std::min(r.size.x / 4, 200l) : 0;
- SmartWin::Rectangle rm(0, r.size.y - ymessage, r.size.x - xfilter, ymessage);
+ int xfilter = showUsers->getChecked() ? std::min(r.width() / 4, 200l) : 0;
+ SmartWin::Rectangle rm(0, r.size.y - ymessage, r.width() - xfilter, ymessage);
message->setBounds(rm);
r.size.y -= rm.size.y + border;
- rm.pos.x += rm.size.x + border;
+ rm.pos.x += rm.width() + border;
rm.size.x = showUsers->getChecked() ? xfilter * 2 / 3 - border : 0;
filter->setBounds(rm);
- rm.pos.x += rm.size.x + border;
+ rm.pos.x += rm.width() + border;
rm.size.x = showUsers->getChecked() ? xfilter / 3 - borde...
[truncated message content] |