mirror of
https://github.com/clangen/musikcube.git
synced 2025-01-01 17:58:29 +00:00
Upgraded win32cpp to fix speed issue that made a double redraw.
This commit is contained in:
parent
f07dc09dda
commit
3578510479
@ -35,6 +35,7 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
#include "pch.hpp"
|
||||
#include <core/filestreams/Factory.h>
|
||||
#include <core/config_filesystem.h>
|
||||
#include <core/PluginFactory.h>
|
||||
#include <core/filestreams/LocalFileStream.h>
|
||||
|
||||
@ -55,13 +56,13 @@ Factory::Factory(){
|
||||
}
|
||||
|
||||
|
||||
FileStreamPtr Factory::OpenFile(const utfchar *filename){
|
||||
FileStreamPtr Factory::OpenFile(const utfchar *uri){
|
||||
typedef musik::core::PluginFactory::DestroyDeleter<IFileStream> 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<IFileStream> 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;
|
||||
}
|
||||
|
@ -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);
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ using namespace win32cpp;
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
AddLibraryView::AddLibraryView(int type)
|
||||
: Frame(NULL,FramePadding(6))
|
||||
: Frame(NULL,WindowPadding(6))
|
||||
, type(type)
|
||||
{
|
||||
}
|
||||
|
@ -72,7 +72,7 @@ const int anim_h = 300;
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
HelpAboutView::HelpAboutView()
|
||||
: Frame(NULL, FramePadding(6))
|
||||
: Frame(NULL, WindowPadding(6))
|
||||
, drawingThread(NULL)
|
||||
{
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ using namespace win32cpp;
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
NewPlaylistView::NewPlaylistView()
|
||||
: Frame(NULL,FramePadding(6))
|
||||
: Frame(NULL,WindowPadding(6))
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ using namespace win32cpp;
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
EditUserView::EditUserView()
|
||||
: Frame(NULL,FramePadding(6))
|
||||
: Frame(NULL,WindowPadding(6))
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
||||
}
|
||||
|
@ -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()
|
||||
|
@ -42,75 +42,17 @@
|
||||
|
||||
#include <win32cpp/Win32Config.hpp>
|
||||
#include <win32cpp/Panel.hpp>
|
||||
#include <win32cpp/WindowPadding.hpp>
|
||||
|
||||
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;
|
||||
};
|
||||
|
@ -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
|
||||
|
@ -115,7 +115,7 @@ private: // instance data
|
||||
LayoutOrientation orientation;
|
||||
int spacing;
|
||||
ChildSizeMap childSizeMap;
|
||||
bool childIsResizing;
|
||||
bool childIsResizing, isResizing;
|
||||
};
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -64,7 +64,7 @@ private: // types
|
||||
typedef std::map<Window*, int> WindowToTabIndexMap;
|
||||
|
||||
public: // constructors
|
||||
/*ctor*/ TabView();
|
||||
/*ctor*/ TabView(LayoutFlags layoutFlags = LayoutWrapWrap);
|
||||
|
||||
public: // methods
|
||||
template <typename WindowType>
|
||||
|
197
src/win32cpp/VirtualWindow.cpp
Normal file
197
src/win32cpp/VirtualWindow.cpp
Normal file
@ -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 <pch.hpp>
|
||||
#include <win32cpp/VirtualWindow.hpp>
|
||||
#include <win32cpp/Color.hpp>
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
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<NCCALCSIZE_PARAMS*>(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;
|
||||
}
|
79
src/win32cpp/VirtualWindow.hpp
Normal file
79
src/win32cpp/VirtualWindow.hpp
Normal file
@ -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 <win32cpp/Win32Config.hpp>
|
||||
#include <win32cpp/Panel.hpp>
|
||||
|
||||
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
|
@ -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))
|
||||
{
|
||||
|
@ -51,6 +51,7 @@ namespace win32cpp {
|
||||
#include <win32cpp/Exception.hpp>
|
||||
#include <win32cpp/Font.hpp>
|
||||
#include <win32cpp/Menu.hpp>
|
||||
#include <win32cpp/WindowPadding.hpp>
|
||||
|
||||
#include <vector>
|
||||
#include <map>
|
||||
|
106
src/win32cpp/WindowPadding.hpp
Normal file
106
src/win32cpp/WindowPadding.hpp
Normal file
@ -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
|
@ -300,6 +300,10 @@
|
||||
RelativePath=".\WindowGeometry.hpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\WindowPadding.hpp"
|
||||
>
|
||||
</File>
|
||||
<Filter
|
||||
Name="to document"
|
||||
>
|
||||
@ -388,6 +392,14 @@
|
||||
RelativePath=".\RadioButton.hpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\VirtualWindow.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\VirtualWindow.hpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Window.cpp"
|
||||
>
|
||||
|
Loading…
Reference in New Issue
Block a user