diff --git a/src/core/filestreams/Factory.cpp b/src/core/filestreams/Factory.cpp index 307b6dd11..b90ba76d9 100644 --- a/src/core/filestreams/Factory.cpp +++ b/src/core/filestreams/Factory.cpp @@ -35,6 +35,7 @@ ////////////////////////////////////////////////////////////////////////////// #include "pch.hpp" #include +#include #include #include @@ -55,13 +56,13 @@ Factory::Factory(){ } -FileStreamPtr Factory::OpenFile(const utfchar *filename){ +FileStreamPtr Factory::OpenFile(const utfchar *uri){ typedef musik::core::PluginFactory::DestroyDeleter StreamDeleter; - if(filename){ + if(uri){ for(FileStreamFactoryVector::iterator factory=sInstance.fileStreamFactories.begin();factory!=sInstance.fileStreamFactories.end();++factory){ - if( (*factory)->CanReadFile(filename) ){ - IFileStream* fileStream( (*factory)->OpenFile(filename) ); + if( (*factory)->CanReadFile(uri) ){ + IFileStream* fileStream( (*factory)->OpenFile(uri) ); if(fileStream){ return FileStreamPtr(fileStream,StreamDeleter()); }else{ @@ -72,9 +73,33 @@ FileStreamPtr Factory::OpenFile(const utfchar *filename){ // If non of the plugins match, lets create a regular file stream FileStreamPtr regularFile( new LocalFileStream(),StreamDeleter() ); - if(regularFile->Open(filename)){ + if(regularFile->Open(uri)){ return regularFile; } } return FileStreamPtr(); } + +bool Factory::IsLocalFileStream(const utfchar *uri){ + typedef musik::core::PluginFactory::DestroyDeleter StreamDeleter; + + if(uri){ + for(FileStreamFactoryVector::iterator factory=sInstance.fileStreamFactories.begin();factory!=sInstance.fileStreamFactories.end();++factory){ + if( (*factory)->CanReadFile(uri) ){ + return false; + } + } + + //Check for local file + boost::filesystem::utfpath filename(uri); + try{ + if(boost::filesystem::exists(filename)){ + return true; + } + } + catch(...){ + } + } + + return false; +} diff --git a/src/core/filestreams/Factory.h b/src/core/filestreams/Factory.h index 091991d46..9d56f6a31 100644 --- a/src/core/filestreams/Factory.h +++ b/src/core/filestreams/Factory.h @@ -56,7 +56,8 @@ class Factory { FileStreamFactoryVector fileStreamFactories; public: - static FileStreamPtr OpenFile(const utfchar *filename); + static FileStreamPtr OpenFile(const utfchar *uri); + static bool IsLocalFileStream(const utfchar *uri); }; ////////////////////////////////////////////////////////////////////////////// diff --git a/src/cube/MainWindowController.cpp b/src/cube/MainWindowController.cpp index 1f3383aea..caf91e218 100644 --- a/src/cube/MainWindowController.cpp +++ b/src/cube/MainWindowController.cpp @@ -122,7 +122,7 @@ void MainWindowController::OnMainWindowCreated(Window* window) // create transport view/controller TransportView* transportView = new TransportView(); - transportView->SetPadding(FramePadding(2, 4, 0, 0)); + transportView->SetPadding(WindowPadding(2, 4, 0, 0)); this->transportController = new TransportController(*transportView); // create library view/controller diff --git a/src/cube/SettingsView.cpp b/src/cube/SettingsView.cpp index 2f4a8a79c..713a56d43 100644 --- a/src/cube/SettingsView.cpp +++ b/src/cube/SettingsView.cpp @@ -169,8 +169,8 @@ void SettingsView::OnCreated() pathLayout->AddChild(pathButtonsLayout); // Add to the layout - win32cpp::Frame *statusFrame = mainLayout->AddChild(new Frame(libraryStatusLayout,FramePadding(20,20,20,0))); - win32cpp::Frame *syncpathFrame = mainLayout->AddChild(new Frame(pathLayout,FramePadding(20,20,0,20))); + win32cpp::Frame *statusFrame = mainLayout->AddChild(new Frame(libraryStatusLayout,WindowPadding(20,20,20,0))); + win32cpp::Frame *syncpathFrame = mainLayout->AddChild(new Frame(pathLayout,WindowPadding(20,20,0,20))); syncpathFrame->SetLayoutFlags(win32cpp::LayoutFillFill); // test CheckBox diff --git a/src/cube/TransportView.cpp b/src/cube/TransportView.cpp index bde94bdde..2586a7ef9 100644 --- a/src/cube/TransportView.cpp +++ b/src/cube/TransportView.cpp @@ -97,7 +97,7 @@ void TransportView::OnCreated() nowPlayingLayout->SetSpacing(0); // Frame* nowPlayingFrame = topRowLayout->AddChild( - new Frame(nowPlayingLayout, FramePadding(6, 0, 0, 0))); + new Frame(nowPlayingLayout, WindowPadding(6, 0, 0, 0))); nowPlayingFrame->SetLayoutFlags(win32cpp::LayoutFillFill); @@ -114,9 +114,9 @@ void TransportView::OnCreated() // put it all together! - win32cpp::Frame *topRowFrame = mainLayout->AddChild(new Frame(topRowLayout, FramePadding(4, 0, 2, 0))); + win32cpp::Frame *topRowFrame = mainLayout->AddChild(new Frame(topRowLayout, WindowPadding(4, 0, 2, 0))); topRowFrame->SetLayoutFlags(win32cpp::LayoutFillFill); - win32cpp::Frame *bottomRowFrame = mainLayout->AddChild(new Frame(bottomRowLayout, FramePadding(6, 6, 0, 0))); + win32cpp::Frame *bottomRowFrame = mainLayout->AddChild(new Frame(bottomRowLayout, WindowPadding(6, 6, 0, 0))); bottomRowFrame->SetLayoutFlags(win32cpp::LayoutFillFill); this->AddChild(mainLayout); } diff --git a/src/cube/dialog/AddLibraryView.cpp b/src/cube/dialog/AddLibraryView.cpp index d897bee7f..42bdab325 100644 --- a/src/cube/dialog/AddLibraryView.cpp +++ b/src/cube/dialog/AddLibraryView.cpp @@ -52,7 +52,7 @@ using namespace win32cpp; ////////////////////////////////////////////////////////////////////////////// AddLibraryView::AddLibraryView(int type) -: Frame(NULL,FramePadding(6)) +: Frame(NULL,WindowPadding(6)) , type(type) { } diff --git a/src/cube/dialog/HelpAboutView.cpp b/src/cube/dialog/HelpAboutView.cpp index d967021a8..e7497b06d 100644 --- a/src/cube/dialog/HelpAboutView.cpp +++ b/src/cube/dialog/HelpAboutView.cpp @@ -72,7 +72,7 @@ const int anim_h = 300; ////////////////////////////////////////////////////////////////////////////// HelpAboutView::HelpAboutView() -: Frame(NULL, FramePadding(6)) +: Frame(NULL, WindowPadding(6)) , drawingThread(NULL) { } diff --git a/src/cube/dialog/NewPlaylistView.cpp b/src/cube/dialog/NewPlaylistView.cpp index f6691f268..8c6253a5d 100644 --- a/src/cube/dialog/NewPlaylistView.cpp +++ b/src/cube/dialog/NewPlaylistView.cpp @@ -52,7 +52,7 @@ using namespace win32cpp; ////////////////////////////////////////////////////////////////////////////// NewPlaylistView::NewPlaylistView() -: Frame(NULL,FramePadding(6)) +: Frame(NULL,WindowPadding(6)) { } diff --git a/src/server/ConnectedUsersController.cpp b/src/server/ConnectedUsersController.cpp index 8ab302ece..91a07ebf5 100644 --- a/src/server/ConnectedUsersController.cpp +++ b/src/server/ConnectedUsersController.cpp @@ -121,7 +121,7 @@ void ConnectedUsersController::OnMainWindowCreated(Window* window) // Create the layout - this->mainFrame = new win32cpp::Frame(NULL,win32cpp::FramePadding(10)); + this->mainFrame = new win32cpp::Frame(NULL,win32cpp::WindowPadding(10)); this->mainFrame->SetLayoutFlags(win32cpp::LayoutFillFill); win32cpp::LinearLayout *mainRowLayout = new win32cpp::LinearLayout(win32cpp::VerticalLayout,win32cpp::LayoutFillFill); mainRowLayout->SetSpacing(10); diff --git a/src/server/MainWindowController.cpp b/src/server/MainWindowController.cpp index cc57f3950..afc2429e3 100644 --- a/src/server/MainWindowController.cpp +++ b/src/server/MainWindowController.cpp @@ -98,7 +98,7 @@ void MainWindowController::OnMainWindowCreated(Window* window) // Create the layout - this->mainFrame = new win32cpp::Frame(NULL,win32cpp::FramePadding(4)); + this->mainFrame = new win32cpp::Frame(NULL,win32cpp::WindowPadding(4)); this->mainFrame->SetLayoutFlags(win32cpp::LayoutFillFill); // Second a TabView for the settings diff --git a/src/server/SyncpathView.cpp b/src/server/SyncpathView.cpp index 77da75c01..b19ad8ed7 100644 --- a/src/server/SyncpathView.cpp +++ b/src/server/SyncpathView.cpp @@ -77,7 +77,7 @@ void SyncpathView::OnCreated() pathLayout->AddChild(pathButtonsLayout); // Add to the layout - win32cpp::Frame *paddingFrame = this->AddChild(new Frame(pathLayout,FramePadding(20))); + win32cpp::Frame *paddingFrame = this->AddChild(new Frame(pathLayout,WindowPadding(20))); paddingFrame->SetLayoutFlags(win32cpp::LayoutFillFill); } diff --git a/src/server/users/EditUserView.cpp b/src/server/users/EditUserView.cpp index 5ccd5a8e6..50f65ac7a 100644 --- a/src/server/users/EditUserView.cpp +++ b/src/server/users/EditUserView.cpp @@ -53,7 +53,7 @@ using namespace win32cpp; ////////////////////////////////////////////////////////////////////////////// EditUserView::EditUserView() -: Frame(NULL,FramePadding(6)) +: Frame(NULL,WindowPadding(6)) { } diff --git a/src/server/users/UsersView.cpp b/src/server/users/UsersView.cpp index d6896e31b..422549a8a 100644 --- a/src/server/users/UsersView.cpp +++ b/src/server/users/UsersView.cpp @@ -76,7 +76,7 @@ void UsersView::OnCreated() // Add to the layout - win32cpp::Frame *paddingFrame = this->AddChild(new Frame(pathLayout,FramePadding(20))); + win32cpp::Frame *paddingFrame = this->AddChild(new Frame(pathLayout,WindowPadding(20))); paddingFrame->SetLayoutFlags(win32cpp::LayoutFillFill); } diff --git a/src/win32cpp/Frame.cpp b/src/win32cpp/Frame.cpp index 1e8313d54..22df9d9cc 100644 --- a/src/win32cpp/Frame.cpp +++ b/src/win32cpp/Frame.cpp @@ -78,7 +78,7 @@ using namespace win32cpp; /// ///\param padding ///The padding parameters to use. -/*ctor*/ Frame::Frame(Window* child, const FramePadding& padding) +/*ctor*/ Frame::Frame(Window* child, const WindowPadding& padding) : base() , padding(padding) , child(child) @@ -90,7 +90,7 @@ using namespace win32cpp; /// ///\param padding ///The new padding parameters to use. -void Frame::SetPadding(const FramePadding& padding) +void Frame::SetPadding(const WindowPadding& padding) { this->padding = padding; this->OnResized(this->WindowSize()); @@ -102,7 +102,7 @@ void Frame::SetPadding(const FramePadding& padding) ///The amount of padding, in pixels, for all edges. void Frame::SetPadding(int padding) { - this->SetPadding(FramePadding(padding, padding, padding, padding)); + this->SetPadding(WindowPadding(padding, padding, padding, padding)); } void Frame::OnCreated() diff --git a/src/win32cpp/Frame.hpp b/src/win32cpp/Frame.hpp index 9ce62e080..313ff1865 100644 --- a/src/win32cpp/Frame.hpp +++ b/src/win32cpp/Frame.hpp @@ -42,75 +42,17 @@ #include #include +#include namespace win32cpp { ////////////////////////////////////////////////////////////////////////////// -///\brief -///FramePadding is used by Frame to specify the padding around the child control. -/// -///\see -///Frame. -struct FramePadding -{ - ///\brief Constructor. - /*ctor*/ FramePadding(int padding = 0) - : left(padding) - , right(padding) - , top(padding) - , bottom(padding) - { - } - - ///\brief Constructor. - /*ctor*/ FramePadding(int left, int right, int top, int bottom) - : left(left) - , right(right) - , top(top) - , bottom(bottom) - { - } - - ///\brief Copy constructor. - /*ctor*/ FramePadding(const FramePadding& padding) - : left(padding.left) - , right(padding.right) - , top(padding.top) - , bottom(padding.bottom) - { - } - - ///\brief Equality operator - bool operator==(const FramePadding& padding) const - { - return ((padding.left == this->left) && (padding.right == this->right) - && (padding.top == this->top) && (padding.bottom == this->bottom)); - } - - ///\brief Inequality operator - bool operator!=(const FramePadding& padding) const - { - return ! (padding == *this); - } - - ///\brief Left padding, in pixels - int left; - ///\brief Right padding, in pixels - int right; - ///\brief Top padding, in pixels - int top; - ///\brief Bottom padding, in pixels - int bottom; -}; - -////////////////////////////////////////////////////////////////////////////// - ///\brief ///Frame is a Container that adds a padding (border) to a single child Window. /// ///If the child is resized, Frame will automatically resize itself -///to accomidate the child and respect the the specified FramePadding. +///to accomidate the child and respect the the specified WindowPadding. ///If the Frame is resized, it will automatically resize the child window ///to fit its new ClientSize. /// @@ -126,10 +68,10 @@ private: //types public: // constructors /*ctor*/ Frame(Window* child = NULL, int padding = 0); - /*ctor*/ Frame(Window* child, const FramePadding& padding); + /*ctor*/ Frame(Window* child, const WindowPadding& padding); public: // methods - void SetPadding(const FramePadding& padding); + void SetPadding(const WindowPadding& padding); void SetPadding(int padding); protected: // methods @@ -146,7 +88,7 @@ protected: // methods static bool RegisterWindowClass(); private: // instance data - FramePadding padding; + WindowPadding padding; Window* child; bool isResizingHACK; }; diff --git a/src/win32cpp/LinearLayout.cpp b/src/win32cpp/LinearLayout.cpp index 49f9df073..5cb8e7691 100644 --- a/src/win32cpp/LinearLayout.cpp +++ b/src/win32cpp/LinearLayout.cpp @@ -63,6 +63,7 @@ using namespace win32cpp; , orientation(orientation) , spacing(4) , childIsResizing(false) +, isResizing(false) { } @@ -140,7 +141,10 @@ inline void LinearLayout::ThrowIfNotChild(Window* child) void LinearLayout::OnResized(const Size& newSize) { - this->Layout(); + if ( ! this->isResizing) + { + this->Layout(); + } } void LinearLayout::ResizeWrapContent() @@ -195,7 +199,9 @@ void LinearLayout::ResizeWrapContent() if ( ! wrapWidth) wrappedWidth = size.width; if ( ! wrapHeight) wrappedHeight = size.height; + this->isResizing = true; this->Resize(wrappedWidth, wrappedHeight); + this->isResizing = false; } Point LinearLayout::AlignChildInRect(LayoutAlignFlag alignment, Size childSize, Rect alignmentRect) @@ -400,8 +406,17 @@ void LinearLayout::Layout() Rect(Point(x, y), alignSize)); this->childIsResizing = true; - child->Resize(size); - child->MoveTo(location); + { + if (child->WindowSize() != size) + { + child->Resize(size); + } + + if (child->Location() != location) + { + child->MoveTo(location); + } + } this->childIsResizing = false; isVertical diff --git a/src/win32cpp/LinearLayout.hpp b/src/win32cpp/LinearLayout.hpp index bac355877..4f8a804ac 100644 --- a/src/win32cpp/LinearLayout.hpp +++ b/src/win32cpp/LinearLayout.hpp @@ -115,7 +115,7 @@ private: // instance data LayoutOrientation orientation; int spacing; ChildSizeMap childSizeMap; - bool childIsResizing; + bool childIsResizing, isResizing; }; ///////////////////////////////////////////////////////////////////////////// diff --git a/src/win32cpp/TabView.cpp b/src/win32cpp/TabView.cpp index 838e2f86d..df15fefb8 100644 --- a/src/win32cpp/TabView.cpp +++ b/src/win32cpp/TabView.cpp @@ -50,8 +50,8 @@ using namespace win32cpp; ///\brief ///Default constructor. -/*ctor*/ TabView::TabView() -: base() +/*ctor*/ TabView::TabView(LayoutFlags layoutFlags) +: base(layoutFlags) , visibleChild(NULL) , padding(4) { diff --git a/src/win32cpp/TabView.hpp b/src/win32cpp/TabView.hpp index 64739ea68..5d979f9a3 100644 --- a/src/win32cpp/TabView.hpp +++ b/src/win32cpp/TabView.hpp @@ -64,7 +64,7 @@ private: // types typedef std::map WindowToTabIndexMap; public: // constructors - /*ctor*/ TabView(); + /*ctor*/ TabView(LayoutFlags layoutFlags = LayoutWrapWrap); public: // methods template diff --git a/src/win32cpp/VirtualWindow.cpp b/src/win32cpp/VirtualWindow.cpp new file mode 100644 index 000000000..bb3dfb912 --- /dev/null +++ b/src/win32cpp/VirtualWindow.cpp @@ -0,0 +1,197 @@ +////////////////////////////////////////////////////////////////////////////// +// +// License Agreement: +// +// The following are Copyright © 2007, Casey Langen +// +// Sources and Binaries of: win32cpp +// +// 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 author nor the names of other 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. +// +////////////////////////////////////////////////////////////////////////////// + +#include +#include +#include + +////////////////////////////////////////////////////////////////////////////// + +using namespace win32cpp; + +////////////////////////////////////////////////////////////////////////////// + +#define CLASS_NAME _T("VirtualWindow") + +/*ctor*/ VirtualWindow::VirtualWindow(HWND handle, int padding, LayoutFlags flags) +: base() +, padding(padding, padding, padding, padding) +, realHWND(handle) +{ + this->SetLayoutFlags(flags); + this->SetBackgroundColor(Color(255, 0, 255)); +} + +///\brief Set the Child's padding. +/// +///\param padding +///The new padding parameters to use. +void VirtualWindow::SetPadding(const WindowPadding& padding) +{ + this->padding = padding; + this->OnResized(this->WindowSize()); +} + +///\brief Set the Child's padding. +/// +///\param padding +///The amount of padding, in pixels, for all edges. +void VirtualWindow::SetPadding(int padding) +{ + this->SetPadding(WindowPadding(padding, padding, padding, padding)); +} + +void VirtualWindow::OnCreated() +{ + if (this->realHWND) + { + ::SetParent(this->realHWND, this->Handle()); + } +} + +bool VirtualWindow::AddChildWindow(Window* window) +{ + throw TooManyChildWindowsException(); +} + +void VirtualWindow::OnResized(const Size& newSize) +{ + if (realHWND) + { + Size clientSize = this->ClientSize(); + + ::SetWindowPos( + this->realHWND, + HWND_TOP, + 0, 0, + clientSize.width, clientSize.height, + NULL); + } +} + +LRESULT VirtualWindow::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) +{ + switch (message) + { + case WM_NCCALCSIZE: + { + if (wParam && lParam) + { + NCCALCSIZE_PARAMS* params = + reinterpret_cast(lParam); + + (*params->rgrc).left += this->padding.left; + (*params->rgrc).right -= this->padding.right; + (*params->rgrc).top += this->padding.top; + (*params->rgrc).bottom -= this->padding.bottom; + } + } + return 0; + + case WM_NCPAINT: + { + HDC hdc = ::GetWindowDC(this->Handle()); + + RECT windowRect = Rect(Point(0, 0), this->WindowSize()); + Point clientLoc(this->padding.left, this->padding.top); + RECT clientRect = Rect(clientLoc, this->ClientSize()); + + ::ExcludeClipRect( + hdc, + clientRect.left, clientRect.top, + clientRect.right, clientRect.bottom); + + HBRUSH backBrush = ::CreateSolidBrush(Color::SystemColor(COLOR_BTNFACE)); + ::FillRect(hdc, &windowRect, backBrush); + ::DeleteObject(backBrush); + + ReleaseDC(this->Handle(), hdc); + } + return 0; + } + + return base::WindowProc(message, wParam, lParam); +} + +HWND VirtualWindow::Create(Window* parent) +{ + HINSTANCE hInstance = Application::Instance(); + + if ( ! VirtualWindow::RegisterWindowClass()) + { + return NULL; + } + + // create the window + DWORD style = WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN | WS_CLIPSIBLINGS; + // + HWND hwnd = CreateWindowEx( + NULL, // ExStyle + CLASS_NAME, // Class name + _T(""), // Window name + style, // Style + 0, // X + 0, // Y + 120, // Width + 36, // Height + parent->Handle(), // Parent + NULL, // Menu + hInstance, // Instance + NULL); // lParam + + return hwnd; +} + +bool VirtualWindow::RegisterWindowClass() +{ + static bool registered = false; + + if ( ! registered) + { + WNDCLASSEX wc = { 0 }; + + // use STATIC window class as our base + ::GetClassInfoEx(NULL, _T("STATIC"), &wc); + wc.cbSize = sizeof(WNDCLASSEX); + wc.lpszClassName = CLASS_NAME; + + registered = (::RegisterClassEx(&wc) != 0); + } + + return registered; +} \ No newline at end of file diff --git a/src/win32cpp/VirtualWindow.hpp b/src/win32cpp/VirtualWindow.hpp new file mode 100644 index 000000000..36ba51117 --- /dev/null +++ b/src/win32cpp/VirtualWindow.hpp @@ -0,0 +1,79 @@ +////////////////////////////////////////////////////////////////////////////// +// +// License Agreement: +// +// The following are Copyright © 2007, Casey Langen +// +// Sources and Binaries of: win32cpp +// +// 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 author nor the names of other 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. +// +////////////////////////////////////////////////////////////////////////////// + +#pragma once + +////////////////////////////////////////////////////////////////////////////// + +#include +#include + +namespace win32cpp { + +////////////////////////////////////////////////////////////////////////////// + +class VirtualWindow: public Panel +{ +private: //types + typedef Panel base; + +public: // constructors + /*ctor*/ VirtualWindow(HWND handle, int padding = 0, LayoutFlags flags = LayoutWrapWrap); + +public: // methods + void SetPadding(const WindowPadding& padding); + void SetPadding(int padding); + +protected: // methods + + virtual bool AddChildWindow(Window* window); + virtual void OnCreated(); + virtual void OnResized(const Size& newSize); + virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam); + virtual HWND Create(Window* parent); + + static bool RegisterWindowClass(); + +private: // instance data + WindowPadding padding; + HWND realHWND; +}; + +////////////////////////////////////////////////////////////////////////////// + +} // win32cpp diff --git a/src/win32cpp/Window.cpp b/src/win32cpp/Window.cpp index 9e09ec4b3..4fafa31f9 100644 --- a/src/win32cpp/Window.cpp +++ b/src/win32cpp/Window.cpp @@ -696,6 +696,11 @@ bool Window::MoveTo(int x, int y) ///true if succesful, false otherwise. bool Window::MoveTo(const Point& location) { + if (this->Location() == location) + { + return true; + } + RECT windowRect; if (::GetWindowRect(this->windowHandle, &windowRect)) { @@ -783,6 +788,11 @@ bool Window::Resize(int width, int height) ///true on success, false otherwise. bool Window::Resize(const Size& size) { + if (this->WindowSize() == size) + { + return true; + } + RECT windowRect; if (::GetWindowRect(this->windowHandle, &windowRect)) { diff --git a/src/win32cpp/Window.hpp b/src/win32cpp/Window.hpp index 4a165f773..6bcda93c4 100644 --- a/src/win32cpp/Window.hpp +++ b/src/win32cpp/Window.hpp @@ -51,6 +51,7 @@ namespace win32cpp { #include #include #include +#include #include #include diff --git a/src/win32cpp/WindowPadding.hpp b/src/win32cpp/WindowPadding.hpp new file mode 100644 index 000000000..1918f5ab3 --- /dev/null +++ b/src/win32cpp/WindowPadding.hpp @@ -0,0 +1,106 @@ +////////////////////////////////////////////////////////////////////////////// +// +// License Agreement: +// +// The following are Copyright © 2007, Casey Langen +// +// Sources and Binaries of: win32cpp +// +// 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 author nor the names of other 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. +// +////////////////////////////////////////////////////////////////////////////// + +#pragma once + +////////////////////////////////////////////////////////////////////////////// + +namespace win32cpp { + +////////////////////////////////////////////////////////////////////////////// + +///\brief +///WindowPadding is used by Frame to specify the padding around the child control. +/// +///\see +///Frame. +struct WindowPadding +{ + ///\brief Constructor. + /*ctor*/ WindowPadding(int padding = 0) + : left(padding) + , right(padding) + , top(padding) + , bottom(padding) + { + } + + ///\brief Constructor. + /*ctor*/ WindowPadding(int left, int right, int top, int bottom) + : left(left) + , right(right) + , top(top) + , bottom(bottom) + { + } + + ///\brief Copy constructor. + /*ctor*/ WindowPadding(const WindowPadding& padding) + : left(padding.left) + , right(padding.right) + , top(padding.top) + , bottom(padding.bottom) + { + } + + ///\brief Equality operator + bool operator==(const WindowPadding& padding) const + { + return ((padding.left == this->left) && (padding.right == this->right) + && (padding.top == this->top) && (padding.bottom == this->bottom)); + } + + ///\brief Inequality operator + bool operator!=(const WindowPadding& padding) const + { + return ! (padding == *this); + } + + ///\brief Left padding, in pixels + int left; + ///\brief Right padding, in pixels + int right; + ///\brief Top padding, in pixels + int top; + ///\brief Bottom padding, in pixels + int bottom; +}; + +///////////////////////////////////////////////////////////////////////////// + +} // win32cpp diff --git a/src/win32cpp/win32cpp.vcproj b/src/win32cpp/win32cpp.vcproj index f1d25501f..937edf0ab 100644 --- a/src/win32cpp/win32cpp.vcproj +++ b/src/win32cpp/win32cpp.vcproj @@ -300,6 +300,10 @@ RelativePath=".\WindowGeometry.hpp" > + + @@ -388,6 +392,14 @@ RelativePath=".\RadioButton.hpp" > + + + +