mirror of
https://github.com/clangen/musikcube.git
synced 2025-03-02 22:13:32 +00:00
Added menu option "File/Add Library".
Fixed some small issues in db::Connection. Upgraded some win32cpp for making dialogs. Started on a musikServer project.
This commit is contained in:
parent
ef37f59767
commit
3d416915c9
@ -2,8 +2,8 @@ Microsoft Visual Studio Solution File, Format Version 9.00
|
||||
# Visual Studio 2005
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mC2", "src\cube\cube.vcproj", "{1CA67D31-E7D4-4377-93F2-FD15BF95D21F}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{B2165720-B4B2-4F4B-9634-8C390C3CB4DB} = {B2165720-B4B2-4F4B-9634-8C390C3CB4DB}
|
||||
{E618F29F-BF28-441A-B039-9E10A631D881} = {E618F29F-BF28-441A-B039-9E10A631D881}
|
||||
{B2165720-B4B2-4F4B-9634-8C390C3CB4DB} = {B2165720-B4B2-4F4B-9634-8C390C3CB4DB}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "win32cpp", "src\win32cpp\win32cpp.vcproj", "{E618F29F-BF28-441A-B039-9E10A631D881}"
|
||||
@ -36,10 +36,11 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "square", "src\square\player
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "waveout", "src\contrib\waveout\waveout.vcproj", "{4F10C17A-8AF7-4FAC-A4E2-087AE6E8F9D8}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "daemon", "src\daemon\daemon.vcproj", "{6513DC84-3758-4A2F-B568-7AAF29DD7DA9}"
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "musikServer", "src\server\musikServer.vcproj", "{1A81F4B3-303D-4591-9029-5F3368EE15D7}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{B2165720-B4B2-4F4B-9634-8C390C3CB4DB} = {B2165720-B4B2-4F4B-9634-8C390C3CB4DB}
|
||||
{B2165720-B4B2-4F4B-8888-8C390C3CB4DB} = {B2165720-B4B2-4F4B-8888-8C390C3CB4DB}
|
||||
{B2165720-B4B2-4F4B-9634-8C390C3CB4DB} = {B2165720-B4B2-4F4B-9634-8C390C3CB4DB}
|
||||
{E618F29F-BF28-441A-B039-9E10A631D881} = {E618F29F-BF28-441A-B039-9E10A631D881}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Global
|
||||
@ -96,10 +97,10 @@ Global
|
||||
{4F10C17A-8AF7-4FAC-A4E2-087AE6E8F9D8}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{4F10C17A-8AF7-4FAC-A4E2-087AE6E8F9D8}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{4F10C17A-8AF7-4FAC-A4E2-087AE6E8F9D8}.Release|Win32.Build.0 = Release|Win32
|
||||
{6513DC84-3758-4A2F-B568-7AAF29DD7DA9}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{6513DC84-3758-4A2F-B568-7AAF29DD7DA9}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{6513DC84-3758-4A2F-B568-7AAF29DD7DA9}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{6513DC84-3758-4A2F-B568-7AAF29DD7DA9}.Release|Win32.Build.0 = Release|Win32
|
||||
{1A81F4B3-303D-4591-9029-5F3368EE15D7}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{1A81F4B3-303D-4591-9029-5F3368EE15D7}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{1A81F4B3-303D-4591-9029-5F3368EE15D7}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{1A81F4B3-303D-4591-9029-5F3368EE15D7}.Release|Win32.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
@ -71,7 +71,7 @@ LibraryFactory::LibraryFactory(void){
|
||||
LibraryFactory::~LibraryFactory(void){
|
||||
}
|
||||
|
||||
void LibraryFactory::AddLibrary(utfstring name,int type){
|
||||
bool LibraryFactory::AddLibrary(utfstring name,int type,bool sendEvent){
|
||||
LibraryPtr lib;
|
||||
switch(type){
|
||||
case Types::Remote:
|
||||
@ -84,9 +84,14 @@ void LibraryFactory::AddLibrary(utfstring name,int type){
|
||||
if(lib){
|
||||
this->libraries.push_back(lib);
|
||||
|
||||
if(sendEvent){
|
||||
this->LibrariesUpdated();
|
||||
}
|
||||
|
||||
// Start the library
|
||||
lib->Startup();
|
||||
return lib->Startup();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void LibraryFactory::RemoveLibrary(utfstring name){
|
||||
@ -103,8 +108,7 @@ bool LibraryFactory::CreateLibrary(utfstring name,int type){
|
||||
stmtInsert.BindTextUTF(0,name);
|
||||
stmtInsert.BindInt(1,type);
|
||||
if(stmtInsert.Step()==db::Done){
|
||||
this->AddLibrary(name,type);
|
||||
return true;
|
||||
return this->AddLibrary(name,type,true);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -63,6 +63,9 @@ class LibraryFactory{
|
||||
bool CreateLibrary(utfstring name,int type);
|
||||
void DeleteLibrary(utfstring name);
|
||||
|
||||
typedef sigslot::signal0<> LibrariesUpdatedEvent;
|
||||
LibrariesUpdatedEvent LibrariesUpdated;
|
||||
|
||||
private:
|
||||
|
||||
LibraryVector libraries;
|
||||
@ -70,7 +73,7 @@ class LibraryFactory{
|
||||
LibraryFactory(void);
|
||||
~LibraryFactory(void);
|
||||
|
||||
void AddLibrary(utfstring name,int type);
|
||||
bool AddLibrary(utfstring name,int type,bool sendEvent=false);
|
||||
void RemoveLibrary(utfstring name);
|
||||
|
||||
};
|
||||
|
@ -44,6 +44,7 @@
|
||||
#include <boost/asio.hpp>
|
||||
#include <boost/thread/thread.hpp>
|
||||
#include <boost/thread/mutex.hpp>
|
||||
#include <boost/shared_ptr.hpp>
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@ -85,6 +86,8 @@ class Server{
|
||||
|
||||
};
|
||||
|
||||
typedef boost::shared_ptr<Server> ServerPtr;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
} }
|
||||
|
||||
|
@ -60,7 +60,6 @@
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLibrarianTool"
|
||||
AdditionalDependencies="shlwapi.lib"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
@ -123,7 +122,6 @@
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLibrarianTool"
|
||||
AdditionalDependencies="shlwapi.lib"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
|
@ -345,6 +345,10 @@ void Connection::Interrupt(){
|
||||
|
||||
void Connection::Maintenance(bool init){
|
||||
|
||||
// Need to be locked throuout all Connections
|
||||
static boost::mutex tempMutex;
|
||||
boost::mutex::scoped_lock lock(tempMutex);
|
||||
|
||||
static int counter(0);
|
||||
|
||||
if(init){
|
||||
|
@ -40,7 +40,6 @@
|
||||
#include <boost/utility.hpp>
|
||||
#include <set>
|
||||
|
||||
using namespace musik::core::xml;
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
namespace musik{ namespace core{ namespace xml{
|
||||
|
@ -39,7 +39,6 @@
|
||||
#include <core/xml/Node.h>
|
||||
#include <boost/utility.hpp>
|
||||
|
||||
using namespace musik::core::xml;
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
namespace musik{ namespace core{ namespace xml{
|
||||
|
@ -74,22 +74,41 @@ LibraryWindowController::~LibraryWindowController()
|
||||
void LibraryWindowController::OnViewCreated(Window* window)
|
||||
{
|
||||
|
||||
using namespace musik::core;
|
||||
using namespace musik::core;
|
||||
// Get libraries from LibraryFactory
|
||||
LibraryFactory::LibraryVector& libraries = LibraryFactory::Libraries();
|
||||
|
||||
// Loop through the libraries
|
||||
for(LibraryFactory::LibraryVector::iterator library=libraries.begin();library!=libraries.end();++library){
|
||||
|
||||
SourcesView* sourcesView = new SourcesView();
|
||||
this->libraries.push_back(SourcesControllerPtr(new SourcesController(*sourcesView,*library)));
|
||||
this->view.AddTab( (*library)->Identifier() ,sourcesView);
|
||||
|
||||
}
|
||||
this->UpdateLibraryTabs();
|
||||
LibraryFactory::Instance().LibrariesUpdated.connect(this,&LibraryWindowController::UpdateLibraryTabs);
|
||||
|
||||
}
|
||||
|
||||
void LibraryWindowController::OnResize(Window* window, Size size)
|
||||
void LibraryWindowController::UpdateLibraryTabs(){
|
||||
using namespace musik::core;
|
||||
|
||||
LibraryFactory::LibraryVector& libraries = LibraryFactory::Libraries();
|
||||
|
||||
// Loop through the libraries
|
||||
for(LibraryFactory::LibraryVector::iterator library=libraries.begin();library!=libraries.end();++library){
|
||||
|
||||
const utfstring libraryId( (*library)->Identifier() );
|
||||
|
||||
// check if library already exist
|
||||
bool found(false);
|
||||
for(LibraryWindowVector::iterator libraryWindow=this->libraries.begin();libraryWindow!=this->libraries.end() && !found;++libraryWindow){
|
||||
if( (*libraryWindow)->library->Identifier()==libraryId ){
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
|
||||
if(!found){
|
||||
SourcesView* sourcesView = new SourcesView();
|
||||
this->libraries.push_back(SourcesControllerPtr(new SourcesController(*sourcesView,*library)));
|
||||
this->view.AddTab( (*library)->Identifier() ,sourcesView);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void LibraryWindowController::OnResize(Window* window, Size size)
|
||||
{
|
||||
RedrawLock redrawLock(&this->view);
|
||||
// this->clientView->Resize(this->mainWindow.ClientSize());
|
||||
|
@ -51,6 +51,7 @@ namespace musik { namespace cube {
|
||||
} }
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <core/Library/Base.h>
|
||||
#include <cube/SourcesController.hpp>
|
||||
#include <win32cpp/Timer.hpp>
|
||||
#include <win32cpp/Types.hpp>
|
||||
@ -72,8 +73,10 @@ public: /*ctor*/ LibraryWindowController(LibraryWindowView& view);
|
||||
public: /*dtor*/ ~LibraryWindowController();
|
||||
|
||||
protected:
|
||||
void OnViewCreated(Window* window);
|
||||
void OnResize(Window* window, Size size);
|
||||
void OnViewCreated(Window* window);
|
||||
void OnResize(Window* window, Size size);
|
||||
|
||||
void UpdateLibraryTabs();
|
||||
|
||||
LibraryWindowView& view;
|
||||
// SourcesController* sourcesController;
|
||||
|
@ -37,9 +37,9 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "pch.hpp"
|
||||
#include <core/LibraryFactory.h>
|
||||
#include <cube/MainMenuController.hpp>
|
||||
//#include <cube/dialog/AddLibraryController.hpp>
|
||||
//#include <cube/dialog/AddLibraryView.hpp>
|
||||
#include <cube/dialog/AddLibraryController.hpp>
|
||||
#include <win32cpp/Application.hpp>
|
||||
#include <win32cpp/TopLevelWindow.hpp>
|
||||
#include <boost/format.hpp>
|
||||
@ -52,14 +52,12 @@ using namespace musik::cube;
|
||||
|
||||
/*ctor*/ MainMenuController::MainMenuController(TopLevelWindow& mainWindow)
|
||||
: mainWindow(mainWindow)
|
||||
//,addLibraryController(NULL)
|
||||
{
|
||||
this->mainWindow.Created.connect(
|
||||
this, &MainMenuController::OnMainWindowCreated);
|
||||
}
|
||||
|
||||
MainMenuController::~MainMenuController(){
|
||||
// delete this->addLibraryController;
|
||||
}
|
||||
|
||||
void MainMenuController::OnMainWindowCreated(Window* window)
|
||||
@ -71,7 +69,8 @@ void MainMenuController::ConnectMenuHandlers()
|
||||
{
|
||||
this->fileExit->Activated.connect(this, &MainMenuController::OnFileExit);
|
||||
this->helpAbout->Activated.connect(this, &MainMenuController::OnHelpAbout);
|
||||
this->fileAddLibrary->Activated.connect(this,&MainMenuController::OnAddLibrary);
|
||||
this->fileAddLibraryLocal->Activated.connect(this,&MainMenuController::OnAddLibraryLocal);
|
||||
this->fileAddLibraryRemote->Activated.connect(this,&MainMenuController::OnAddLibraryRemote);
|
||||
}
|
||||
|
||||
void MainMenuController::OnFileExit(MenuItemRef menuItem)
|
||||
@ -79,10 +78,25 @@ void MainMenuController::OnFileExit(MenuItemRef menuItem)
|
||||
Application::Instance().Terminate();
|
||||
}
|
||||
|
||||
void MainMenuController::OnAddLibrary(MenuItemRef menuItem)
|
||||
void MainMenuController::OnAddLibraryLocal(MenuItemRef menuItem)
|
||||
{
|
||||
/* dialog::AddLibraryView* addLibraryView = new dialog::AddLibraryView();
|
||||
this->addLibraryController = new dialog::AddLibraryController(*addLibraryView);*/
|
||||
win32cpp::TopLevelWindow popupDialog(_T("Add local library"));
|
||||
popupDialog.SetMinimumSize(Size(300, 150));
|
||||
|
||||
dialog::AddLibraryController addLibrary(popupDialog,musik::core::LibraryFactory::LocalDB);
|
||||
|
||||
popupDialog.ShowModal(&this->mainWindow);
|
||||
|
||||
}
|
||||
void MainMenuController::OnAddLibraryRemote(MenuItemRef menuItem)
|
||||
{
|
||||
win32cpp::TopLevelWindow popupDialog(_T("Add remote library"));
|
||||
popupDialog.SetMinimumSize(Size(300, 150));
|
||||
|
||||
dialog::AddLibraryController addLibrary(popupDialog,musik::core::LibraryFactory::Remote);
|
||||
|
||||
popupDialog.ShowModal(&this->mainWindow);
|
||||
|
||||
}
|
||||
|
||||
void MainMenuController::OnHelpAbout(MenuItemRef menuItem)
|
||||
@ -142,8 +156,14 @@ MenuRef MainMenuController::CreateMenu()
|
||||
//
|
||||
this->file->SetSubMenu(this->fileMenu);
|
||||
|
||||
this->fileAddLibrary = fileItems.Append(MenuItem::Create(_T("&Add Library")));
|
||||
this->fileExit = fileItems.Append(MenuItem::Create(_T("E&xit")));
|
||||
MenuRef addLibrarySubmenu = Menu::Create();
|
||||
this->fileAddLibraryLocal = addLibrarySubmenu->Items().Append(MenuItem::Create(_T("&Local library")));
|
||||
this->fileAddLibraryRemote = addLibrarySubmenu->Items().Append(MenuItem::Create(_T("&Remote library")));
|
||||
|
||||
MenuItemRef addLibraryMenu = fileItems.Append(MenuItem::Create(_T("&Add Library")));
|
||||
addLibraryMenu->SetSubMenu(addLibrarySubmenu);
|
||||
|
||||
this->fileExit = fileItems.Append(MenuItem::Create(_T("E&xit")));
|
||||
|
||||
// help menu
|
||||
this->helpMenu = Menu::Create();
|
||||
|
@ -40,9 +40,6 @@
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// Forward declare
|
||||
/*namespace musik { namespace cube { namespace dialog {
|
||||
class AddLibraryController;
|
||||
} } }*/
|
||||
namespace win32cpp {
|
||||
class Window;
|
||||
class TopLevelWindow;
|
||||
@ -73,15 +70,15 @@ class MainMenuController: public EventHandler
|
||||
//
|
||||
void OnFileExit(MenuItemRef menuItem);
|
||||
void OnHelpAbout(MenuItemRef menuItem);
|
||||
void OnAddLibrary(MenuItemRef menuItem);
|
||||
void OnAddLibraryLocal(MenuItemRef menuItem);
|
||||
void OnAddLibraryRemote(MenuItemRef menuItem);
|
||||
|
||||
|
||||
private:
|
||||
TopLevelWindow& mainWindow;
|
||||
MenuRef mainMenu, fileMenu, helpMenu;
|
||||
MenuItemRef file, view, audio, tags, help;
|
||||
MenuItemRef fileExit, helpAbout, fileAddLibrary;
|
||||
// dialog::AddLibraryController *addLibraryController;
|
||||
MenuItemRef fileExit, helpAbout, fileAddLibraryRemote, fileAddLibraryLocal;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -108,7 +108,6 @@ void TracklistController::OnViewCreated(Window* window)
|
||||
// Enqueue menu
|
||||
win32cpp::MenuItemRef enqueueMenu = this->contextMenu->Items().Append(win32cpp::MenuItem::Create(_T("Enqueue")));
|
||||
enqueueMenu->Activated.connect(this,&TracklistController::OnEnqueue);
|
||||
|
||||
//
|
||||
listView->SetContextMenu(contextMenu);
|
||||
|
||||
|
@ -41,7 +41,8 @@
|
||||
#include <cube/dialog/AddLibraryView.hpp>
|
||||
|
||||
#include <win32cpp/Window.hpp>
|
||||
#include <win32cpp/Label.hpp>
|
||||
#include <win32cpp/Button.hpp>
|
||||
#include <win32cpp/EditView.hpp>
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@ -50,22 +51,38 @@ using namespace win32cpp;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
AddLibraryController::AddLibraryController(AddLibraryView& addLibraryView)
|
||||
:addLibraryView(addLibraryView)
|
||||
AddLibraryController::AddLibraryController(win32cpp::TopLevelWindow &mainWindow,int type)
|
||||
:mainWindow(mainWindow)
|
||||
,view(NULL)
|
||||
,libraryType(type)
|
||||
{
|
||||
this->addLibraryView.Created.connect(
|
||||
this, &AddLibraryController::OnViewCreated);
|
||||
this->view = new AddLibraryView();
|
||||
this->mainWindow.AddChild(this->view);
|
||||
|
||||
this->addLibraryView.Resized.connect(
|
||||
this, &AddLibraryController::OnViewResized);
|
||||
this->view->Handle()
|
||||
? this->OnViewCreated(this->view)
|
||||
: this->view->Created.connect(this, &AddLibraryController::OnViewCreated);
|
||||
|
||||
}
|
||||
|
||||
AddLibraryController::~AddLibraryController(){
|
||||
}
|
||||
|
||||
void AddLibraryController::OnViewCreated(Window* window)
|
||||
{
|
||||
|
||||
this->view->cancelButton->Pressed.connect(this,&AddLibraryController::OnCancel);
|
||||
this->view->okButton->Pressed.connect(this,&AddLibraryController::OnOK);
|
||||
}
|
||||
|
||||
void AddLibraryController::OnViewResized(Window* window, Size size)
|
||||
{
|
||||
void AddLibraryController::OnCancel(win32cpp::Button* button){
|
||||
this->mainWindow.Close();
|
||||
}
|
||||
|
||||
void AddLibraryController::OnOK(win32cpp::Button* button){
|
||||
if(musik::core::LibraryFactory::Instance().CreateLibrary(this->view->name->Caption(),this->libraryType)){
|
||||
this->mainWindow.Close();
|
||||
}else{
|
||||
// Show some error that it didn't work
|
||||
this->mainWindow.Close();
|
||||
}
|
||||
}
|
||||
|
@ -40,11 +40,9 @@
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// Forward declare
|
||||
namespace musik { namespace cube { namespace dialog{
|
||||
class AddLibraryView;
|
||||
} } }
|
||||
namespace win32cpp{
|
||||
class Window;
|
||||
class Button;
|
||||
}
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@ -56,18 +54,25 @@ namespace win32cpp{
|
||||
|
||||
namespace musik { namespace cube { namespace dialog{
|
||||
|
||||
class AddLibraryView; // forward
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class AddLibraryController : public win32cpp::EventHandler{
|
||||
|
||||
public:
|
||||
AddLibraryController(AddLibraryView& addLibraryView);
|
||||
AddLibraryController(win32cpp::TopLevelWindow &mainWindow,int type);
|
||||
~AddLibraryController();
|
||||
|
||||
private:
|
||||
void OnViewCreated(win32cpp::Window* window);
|
||||
void OnViewResized(win32cpp::Window* window, win32cpp::Size size);
|
||||
void OnCancel(win32cpp::Button* button);
|
||||
void OnOK(win32cpp::Button* button);
|
||||
|
||||
AddLibraryView& addLibraryView;
|
||||
AddLibraryView* view;
|
||||
|
||||
win32cpp::TopLevelWindow &mainWindow;
|
||||
|
||||
int libraryType;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -38,6 +38,10 @@
|
||||
|
||||
#include "pch.hpp"
|
||||
#include <cube/dialog/AddLibraryView.hpp>
|
||||
#include <win32cpp/Label.hpp>
|
||||
#include <win32cpp/Button.hpp>
|
||||
#include <win32cpp/LinearLayout.hpp>
|
||||
#include <win32cpp/EditView.hpp>
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@ -47,10 +51,50 @@ using namespace win32cpp;
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
AddLibraryView::AddLibraryView()
|
||||
: Frame(NULL,FramePadding(6))
|
||||
{
|
||||
}
|
||||
|
||||
void AddLibraryView::OnCreated()
|
||||
{
|
||||
FontRef boldFont(Font::Create());
|
||||
boldFont->SetBold(true);
|
||||
|
||||
// Top Row layout
|
||||
LinearLayout* topRowLayout = new LinearLayout(LinearRowLayout);
|
||||
topRowLayout->SetDefaultChildFill(false);
|
||||
topRowLayout->SetDefaultChildAlignment(win32cpp::ChildAlignMiddle);
|
||||
|
||||
// First rows column layout
|
||||
LinearLayout* firstColumnLayout = new LinearLayout(LinearColumnLayout);
|
||||
firstColumnLayout->SetDefaultChildFill(false);
|
||||
firstColumnLayout->SetDefaultChildAlignment(win32cpp::ChildAlignCenter);
|
||||
|
||||
Label* title = firstColumnLayout->AddChild(new Label(_T("Add Library")));
|
||||
title->SetFont(boldFont);
|
||||
|
||||
// Second rows column layout
|
||||
LinearLayout* secondColumnLayout = new LinearLayout(LinearColumnLayout);
|
||||
|
||||
win32cpp::Label* nameLabel = secondColumnLayout->AddChild(new Label(_T("Library name:") ));
|
||||
this->name = secondColumnLayout->AddChild(new EditView(160,20 ));
|
||||
|
||||
// Last rows column layout
|
||||
LinearLayout* bottomButtonLayout = new LinearLayout(LinearColumnLayout);
|
||||
bottomButtonLayout->SetDefaultChildFill(false);
|
||||
|
||||
this->cancelButton = bottomButtonLayout->AddChild(new Button(_T("Cancel")));
|
||||
this->okButton = bottomButtonLayout->AddChild(new Button(_T("OK")));
|
||||
this->cancelButton->Resize(60,20);
|
||||
this->okButton->Resize(60,20);
|
||||
|
||||
|
||||
|
||||
topRowLayout->AddChild(firstColumnLayout);
|
||||
topRowLayout->AddChild(secondColumnLayout);
|
||||
topRowLayout->AddChild(bottomButtonLayout);
|
||||
topRowLayout->SetChildAlignment(bottomButtonLayout,ChildAlignRight);
|
||||
|
||||
this->AddChild(topRowLayout);
|
||||
|
||||
}
|
||||
|
@ -40,7 +40,8 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// Forward declare
|
||||
namespace win32cpp{
|
||||
class Window;
|
||||
class Button;
|
||||
class EditView;
|
||||
}
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@ -59,8 +60,9 @@ class AddLibraryView: public win32cpp::Frame{
|
||||
public:
|
||||
AddLibraryView();
|
||||
|
||||
protected:
|
||||
virtual void OnCreated();
|
||||
win32cpp::Button *okButton, *cancelButton;
|
||||
win32cpp::EditView *name;
|
||||
|
||||
};
|
||||
|
||||
|
67
src/server/main.cpp
Normal file
67
src/server/main.cpp
Normal file
@ -0,0 +1,67 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// License Agreement:
|
||||
//
|
||||
// The following are Copyright © 2007, Daniel Önnerby
|
||||
//
|
||||
// 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/Application.hpp>
|
||||
#include <win32cpp/TopLevelWindow.hpp>
|
||||
#include <core/config.h>
|
||||
#include <core/Server.h>
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//using namespace musik::server;
|
||||
using namespace win32cpp;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
int WINAPI wWinMain(HINSTANCE instance, HINSTANCE prevInstance, LPTSTR commandLine, int showCommand)
|
||||
{
|
||||
|
||||
musik::core::ServerPtr server(new musik::core::Server(10543,10544));
|
||||
server->Startup();
|
||||
|
||||
// Initialize the main application (mC2.exe)
|
||||
Application::Initialize(instance, prevInstance, commandLine, showCommand);
|
||||
|
||||
// Create the main window and its controller
|
||||
TopLevelWindow mainWindow(_T("musikServer"));
|
||||
// MainWindowController mainController(mainWindow);
|
||||
|
||||
// Initialize and show the main window, and run the event loop.
|
||||
Application::Instance().Run(mainWindow);
|
||||
|
||||
return 0;
|
||||
}
|
241
src/server/musikServer.vcproj
Normal file
241
src/server/musikServer.vcproj
Normal file
@ -0,0 +1,241 @@
|
||||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="8,00"
|
||||
Name="musikServer"
|
||||
ProjectGUID="{1A81F4B3-303D-4591-9029-5F3368EE15D7}"
|
||||
RootNamespace="musikServer"
|
||||
Keyword="Win32Proj"
|
||||
>
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"
|
||||
/>
|
||||
</Platforms>
|
||||
<ToolFiles>
|
||||
</ToolFiles>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory="../../bin/$(ConfigurationName)"
|
||||
IntermediateDirectory="obj/$(ConfigurationName)"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="1"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="./;../;../3rdparty/include/"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_SCL_SECURE_NO_WARNINGS;XML_STATIC"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="1"
|
||||
UsePrecompiledHeader="2"
|
||||
PrecompiledHeaderThrough="pch.hpp"
|
||||
PrecompiledHeaderFile="obj/$(ConfigurationName)/$(TargetName).pch"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="true"
|
||||
DebugInformationFormat="4"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="gdiplus.lib comctl32.lib"
|
||||
LinkIncremental="2"
|
||||
AdditionalLibraryDirectories="../3rdparty/lib"
|
||||
IgnoreDefaultLibraryNames=""
|
||||
ModuleDefinitionFile=""
|
||||
GenerateDebugInformation="true"
|
||||
GenerateMapFile="true"
|
||||
MapFileName="$(TargetDir)$(TargetName).map"
|
||||
MapExports="true"
|
||||
SubSystem="2"
|
||||
EntryPointSymbol="wWinMainCRTStartup"
|
||||
ImportLibrary=""
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
AdditionalManifestFiles="$(ProjectDir)\resources\musikServer.exe.manifest"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
CommandLine="copy "$(SolutionDir)\src\3rdparty\vld\*.*" "$(TargetDir)""
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory="../../bin/$(ConfigurationName)"
|
||||
IntermediateDirectory="obj/$(ConfigurationName)"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="1"
|
||||
WholeProgramOptimization="1"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories="./;../;../3rdparty/include/"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_SCL_SECURE_NO_WARNINGS;XML_STATIC"
|
||||
RuntimeLibrary="0"
|
||||
UsePrecompiledHeader="2"
|
||||
PrecompiledHeaderThrough="pch.hpp"
|
||||
PrecompiledHeaderFile="obj/$(ConfigurationName)/$(TargetName).pch"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="true"
|
||||
DebugInformationFormat="3"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="gdiplus.lib comctl32.lib"
|
||||
LinkIncremental="1"
|
||||
AdditionalLibraryDirectories="../3rdparty/lib"
|
||||
ModuleDefinitionFile=""
|
||||
GenerateDebugInformation="false"
|
||||
SubSystem="2"
|
||||
OptimizeReferences="2"
|
||||
EnableCOMDATFolding="2"
|
||||
EntryPointSymbol="wWinMainCRTStartup"
|
||||
ImportLibrary=""
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
AdditionalManifestFiles="$(ProjectDir)\resources\musikServer.exe.manifest"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<File
|
||||
RelativePath=".\main.cpp"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\pch.cpp"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
UsePrecompiledHeader="1"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
UsePrecompiledHeader="1"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\pch.hpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\resources\resource.rc"
|
||||
>
|
||||
</File>
|
||||
</Files>
|
||||
<Globals>
|
||||
<Global
|
||||
Name="RESOURCE_FILE"
|
||||
Value=".\resources\resource.rc"
|
||||
/>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
38
src/server/pch.cpp
Normal file
38
src/server/pch.cpp
Normal file
@ -0,0 +1,38 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// License Agreement:
|
||||
//
|
||||
// The following are Copyright © 2007, Daniel Önnerby
|
||||
//
|
||||
// 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 "pch.hpp"
|
65
src/server/pch.hpp
Normal file
65
src/server/pch.hpp
Normal file
@ -0,0 +1,65 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// License Agreement:
|
||||
//
|
||||
// The following are Copyright © 2007, Daniel Önnerby
|
||||
//
|
||||
// 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
|
||||
|
||||
#ifndef _DEBUG
|
||||
// To be able to UPX the released executable
|
||||
extern "C" void tss_cleanup_implemented(void){}
|
||||
#endif
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// dependencies
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
#pragma warning (disable : 4996 4018 4482)
|
||||
|
||||
#include "vld/vld.h"
|
||||
|
||||
#include <core/config.h>
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
#include <win32cpp/Win32Config.hpp>
|
||||
/*#include <win32cpp/Types.hpp>
|
||||
#include <win32cpp/WindowGeometry.hpp>
|
||||
#include <win32cpp/Exception.hpp>
|
||||
#include <win32cpp/Container.hpp>
|
||||
#include <win32cpp/Font.hpp>
|
||||
#include <win32cpp/Menu.hpp>
|
||||
#include <win32cpp/Window.hpp>
|
||||
#include <win32cpp/Application.hpp>
|
||||
#include <win32cpp/TopLevelWindow.hpp>
|
||||
*/
|
||||
//////////////////////////////////////////////////////////////////////////////
|
22
src/server/resources/musikServer.exe.manifest
Normal file
22
src/server/resources/musikServer.exe.manifest
Normal file
@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
|
||||
<assemblyIdentity
|
||||
version="1.0.0.0"
|
||||
processorArchitecture="X86"
|
||||
name="Microsoft.Windows.mC2"
|
||||
type="win32"
|
||||
/>
|
||||
<description>Your app description here</description>
|
||||
<dependency>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity
|
||||
type="win32"
|
||||
name="Microsoft.Windows.Common-Controls"
|
||||
version="6.0.0.0"
|
||||
processorArchitecture="X86"
|
||||
publicKeyToken="6595b64144ccf1df"
|
||||
language="*"
|
||||
/>
|
||||
</dependentAssembly>
|
||||
</dependency>
|
||||
</assembly>
|
5
src/server/resources/resource.h
Normal file
5
src/server/resources/resource.h
Normal file
@ -0,0 +1,5 @@
|
||||
//{{NO_DEPENDENCIES}}
|
||||
// Microsoft Visual C++ generated include file.
|
||||
// Used by resource.rc
|
||||
//
|
||||
#define IDI_MAINFRAME 100
|
15
src/server/resources/resource.rc
Normal file
15
src/server/resources/resource.rc
Normal file
@ -0,0 +1,15 @@
|
||||
// Microsoft Visual C++ generated resource script.
|
||||
//
|
||||
#include "resource.h"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Icon
|
||||
//
|
||||
|
||||
// Icon with lowest ID value placed first to ensure application icon
|
||||
// remains consistent on all systems.
|
||||
IDI_MAINFRAME ICON "../../cube/resources/mC2.ico"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -50,40 +50,59 @@ using namespace win32cpp;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#define CLASS_NAME _T("win32cpp TopLevelWindow")
|
||||
|
||||
///\brief Constructor.
|
||||
///
|
||||
///\param windowTitle
|
||||
///The title that will be displayed in the title bar..
|
||||
/*ctor*/ TopLevelWindow::TopLevelWindow(const uichar* windowTitle)
|
||||
: base()
|
||||
, className(uistring(windowTitle) + _T(" TopLevelWindow"))
|
||||
, windowTitle(windowTitle)
|
||||
, minSize(0, 0)
|
||||
, closed(false)
|
||||
, modalChild(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
/*dtor*/ TopLevelWindow::~TopLevelWindow()
|
||||
{
|
||||
}
|
||||
|
||||
bool TopLevelWindow::RegisterWindowClass()
|
||||
{
|
||||
static bool registered = false;
|
||||
|
||||
if ( ! registered)
|
||||
{
|
||||
WNDCLASSEX wc = { 0 };
|
||||
|
||||
// register the window class
|
||||
wc.cbSize = sizeof(WNDCLASSEX);
|
||||
wc.style = 0;
|
||||
wc.lpfnWndProc = Window::StaticWindowProc;
|
||||
wc.cbClsExtra = 0;
|
||||
wc.cbWndExtra = 0;
|
||||
wc.hInstance = Application::Instance();
|
||||
wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
|
||||
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
|
||||
wc.hbrBackground = (HBRUSH) (COLOR_WINDOW+1);
|
||||
wc.lpszMenuName = NULL;
|
||||
wc.lpszClassName = CLASS_NAME;
|
||||
wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
|
||||
|
||||
registered = (::RegisterClassEx(&wc) != 0);
|
||||
}
|
||||
|
||||
return registered;
|
||||
}
|
||||
|
||||
HWND TopLevelWindow::Create(Window* parent)
|
||||
{
|
||||
// parent is ignored here! top level windows don't have parents!
|
||||
|
||||
HINSTANCE hInstance = Application::Instance();
|
||||
WNDCLASSEX wc;
|
||||
HWND parentHWND = (parent ? parent->Handle() : NULL);
|
||||
|
||||
// register the window class
|
||||
wc.cbSize = sizeof(WNDCLASSEX);
|
||||
wc.style = 0;
|
||||
wc.lpfnWndProc = Window::StaticWindowProc;
|
||||
wc.cbClsExtra = 0;
|
||||
wc.cbWndExtra = 0;
|
||||
wc.hInstance = hInstance;
|
||||
wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
|
||||
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
|
||||
wc.hbrBackground = (HBRUSH) (COLOR_WINDOW+1);
|
||||
wc.lpszMenuName = NULL;
|
||||
wc.lpszClassName = this->className.c_str();
|
||||
wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
|
||||
|
||||
if( ! ::RegisterClassEx(&wc))
|
||||
if ( ! TopLevelWindow::RegisterWindowClass())
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
@ -94,14 +113,14 @@ HWND TopLevelWindow::Create(Window* parent)
|
||||
//
|
||||
HWND hwnd = ::CreateWindowEx(
|
||||
styleEx, // ExStyle
|
||||
this->className.c_str(), // Class name
|
||||
CLASS_NAME, // Class name
|
||||
this->windowTitle.c_str(), // Window name
|
||||
style, // Style
|
||||
CW_USEDEFAULT, // X
|
||||
CW_USEDEFAULT, // Y
|
||||
240, // Width
|
||||
120, // Height
|
||||
NULL, // Parent
|
||||
parentHWND, // Parent
|
||||
NULL, // Menu
|
||||
hInstance, // Instance
|
||||
NULL); // lParam
|
||||
@ -128,6 +147,12 @@ Size TopLevelWindow::MinimumSize() const
|
||||
return this->minSize;
|
||||
}
|
||||
|
||||
///\brief Closes the TopLevelWindow
|
||||
void TopLevelWindow::Close()
|
||||
{
|
||||
this->SendMessage(WM_CLOSE, NULL, NULL);
|
||||
}
|
||||
|
||||
LRESULT TopLevelWindow::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
switch (message)
|
||||
@ -139,6 +164,12 @@ LRESULT TopLevelWindow::WindowProc(UINT message, WPARAM wParam, LPARAM lPara
|
||||
}
|
||||
return 0;
|
||||
|
||||
case WM_CLOSE:
|
||||
{
|
||||
this->closed = true;
|
||||
}
|
||||
break;
|
||||
|
||||
case WM_PRINTCLIENT:
|
||||
{
|
||||
HDC hdc = (HDC) wParam;
|
||||
@ -221,3 +252,90 @@ void TopLevelWindow::OnPaint()
|
||||
//
|
||||
::EndPaint(this->Handle(), &paintStruct);
|
||||
}
|
||||
|
||||
void TopLevelWindow::ShowModal(TopLevelWindow* parent)
|
||||
{
|
||||
if (this->closed)
|
||||
{
|
||||
throw WindowAlreadyClosedException();
|
||||
}
|
||||
|
||||
if ( ! this->Handle())
|
||||
{
|
||||
this->Initialize(parent);
|
||||
}
|
||||
|
||||
if (parent)
|
||||
{
|
||||
parent->modalChild = this;
|
||||
parent->Enable(false);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
// center the child dialog over the parent
|
||||
if (parent)
|
||||
{
|
||||
Point location(0, 0);
|
||||
RECT parentRect;
|
||||
::GetWindowRect(parent->windowHandle, &parentRect);
|
||||
|
||||
Size thisSize = this->WindowSize();
|
||||
location.x = (parentRect.left + parentRect.right) / 2 - thisSize.width / 2;
|
||||
location.y = (parentRect.top + parentRect.bottom) / 2 - thisSize.height / 2;
|
||||
|
||||
this->MoveTo(location);
|
||||
}
|
||||
|
||||
// removes the dialog from the titlebar
|
||||
::SetWindowLong(this->Handle(), GWL_STYLE, WS_CAPTION | WS_SYSMENU | WS_THICKFRAME);
|
||||
this->Show(SW_SHOW);
|
||||
|
||||
bool shouldQuit = false;
|
||||
MSG msg;
|
||||
while (( ! shouldQuit) && (::GetMessage(&msg, NULL, 0, 0) > 0))
|
||||
{
|
||||
if (msg.message == WM_QUIT)
|
||||
{
|
||||
shouldQuit = true;
|
||||
::PostQuitMessage(0);
|
||||
break;
|
||||
}
|
||||
|
||||
::TranslateMessage(&msg);
|
||||
::DispatchMessage(&msg);
|
||||
|
||||
shouldQuit |= this->closed;
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
// TODO: log me
|
||||
}
|
||||
|
||||
if (parent)
|
||||
{
|
||||
parent->modalChild = NULL;
|
||||
parent->Enable(true);
|
||||
parent->SetFocus();
|
||||
}
|
||||
}
|
||||
|
||||
void TopLevelWindow::OnGainedFocus()
|
||||
{
|
||||
if (this->modalChild)
|
||||
{
|
||||
this->modalChild->SetFocus();
|
||||
}
|
||||
}
|
||||
|
||||
TopLevelWindow* TopLevelWindow::FindFromAncestor(Window* window)
|
||||
{
|
||||
Window* topLevelWindow = window->Parent(), *scratch = NULL;
|
||||
while ((topLevelWindow) && (scratch = topLevelWindow->Parent()))
|
||||
{
|
||||
topLevelWindow = scratch;
|
||||
}
|
||||
|
||||
return dynamic_cast<TopLevelWindow*>(topLevelWindow);
|
||||
}
|
||||
|
@ -58,13 +58,19 @@ class TopLevelWindow: public Container
|
||||
{
|
||||
private: // types
|
||||
typedef Container base;
|
||||
class WindowAlreadyClosedException : public Exception { };
|
||||
|
||||
public: // ctor, dtor
|
||||
/*ctor*/ TopLevelWindow(const uichar* windowTitle);
|
||||
/*dtor*/ virtual ~TopLevelWindow();
|
||||
|
||||
public: // methods
|
||||
void SetMinimumSize(const Size& minSize);
|
||||
Size MinimumSize() const;
|
||||
void ShowModal(TopLevelWindow* parent);
|
||||
void Close();
|
||||
|
||||
static TopLevelWindow* FindFromAncestor(Window* window);
|
||||
|
||||
protected: // methods
|
||||
virtual HWND Create(Window* parent);
|
||||
@ -74,10 +80,15 @@ protected: // methods
|
||||
virtual void OnRequestFocusPrev();
|
||||
virtual void OnEraseBackground(HDC hdc);
|
||||
virtual void OnPaint();
|
||||
virtual void OnGainedFocus();
|
||||
|
||||
static bool RegisterWindowClass();
|
||||
|
||||
private: // instance data
|
||||
uistring className, windowTitle;
|
||||
uistring windowTitle;
|
||||
bool closed;
|
||||
Size minSize;
|
||||
TopLevelWindow* modalChild;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -55,6 +55,8 @@ Window::HandleToWindowMap Window::sHandleToWindowMap;
|
||||
FontRef Window::sDefaultFont(Font::Create());
|
||||
Window::FocusDirection Window::sFocusDirection = Window::FocusForward;
|
||||
|
||||
static Window* sLastWindowUnderMouse = NULL;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// Window::Window
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
@ -135,6 +137,7 @@ bool Window::Show(int showCommand)
|
||||
///Container
|
||||
bool Window::Destroy()
|
||||
{
|
||||
bool returnVal = false;
|
||||
HWND windowHandle = this->Handle();
|
||||
//
|
||||
if (windowHandle)
|
||||
@ -147,10 +150,16 @@ bool Window::Destroy()
|
||||
this->windowHandle = NULL;
|
||||
}
|
||||
|
||||
return (result == TRUE);
|
||||
returnVal = (result == TRUE);
|
||||
}
|
||||
|
||||
return false;
|
||||
// annoying hack for mouse events.
|
||||
if (sLastWindowUnderMouse == this)
|
||||
{
|
||||
sLastWindowUnderMouse = NULL;
|
||||
}
|
||||
|
||||
return returnVal;
|
||||
}
|
||||
|
||||
bool Window::WindowHasParent(Window* window)
|
||||
@ -210,8 +219,6 @@ Window* Window::WindowUnderCursor(HWND* targetHwnd)
|
||||
// HACK 1/2: necessary to generate reliable OnMouseEnter/Leave() events.
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static Window* sLastWindowUnderMouse = NULL;
|
||||
//
|
||||
void Window::BeginCapture(Window* window)
|
||||
{
|
||||
if ((window) && (window->Handle() != ::GetCapture()))
|
||||
@ -239,10 +246,18 @@ void Window::EndCapture(Window* window)
|
||||
}
|
||||
}
|
||||
|
||||
bool Window::WindowIsValid(Window* window)
|
||||
{
|
||||
WindowList& allChildren = Window::sAllChildWindows;
|
||||
return (std::find(allChildren.begin(), allChildren.end(), window) != allChildren.end());
|
||||
}
|
||||
|
||||
#define DISPATCH_MOUSE_EVENT(eventName) \
|
||||
{ \
|
||||
Point mousePos = Point(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)); \
|
||||
Window* windowToNotify = Window::Capture(); \
|
||||
bool lastUnderValid = Window::WindowIsValid(sLastWindowUnderMouse); \
|
||||
if ( ! lastUnderValid) sLastWindowUnderMouse = NULL; \
|
||||
if ( ! windowToNotify) windowToNotify = sLastWindowUnderMouse; \
|
||||
if ( ! windowToNotify) windowToNotify = Window::WindowUnderCursor(); \
|
||||
if (windowToNotify) \
|
||||
|
@ -311,6 +311,7 @@ protected: // methods
|
||||
virtual void PaintToHDC(HDC hdc, const Rect& rect);
|
||||
void SuppressSignal(SignalBase& signal);
|
||||
static bool WindowHasParent(Window* window);
|
||||
static bool WindowIsValid(Window* window);
|
||||
|
||||
protected: // instance data
|
||||
WindowProcFunc defaultWindowProc;
|
||||
|
Loading…
x
Reference in New Issue
Block a user