mirror of
https://github.com/clangen/musikcube.git
synced 2025-03-29 19:20:28 +00:00
Proof of concept MessageQueue implementation for raw Win32 with
PlaybackService integration. Visualizers work too.
This commit is contained in:
parent
138766e8ff
commit
49abe0526d
@ -1,27 +1,50 @@
|
||||
#include <pch.h>
|
||||
|
||||
#include <win32cpp/Application.hpp>
|
||||
#include <win32cpp/TopLevelWindow.hpp>
|
||||
|
||||
#include <core/library/LibraryFactory.h>
|
||||
#include <core/audio/PlaybackService.h>
|
||||
#include <core/audio/Visualizer.h>
|
||||
|
||||
#include <glue/audio/MasterTransport.h>
|
||||
#include <glue/query/SearchTrackListQuery.h>
|
||||
|
||||
#include <app/view/MainWindow.h>
|
||||
|
||||
#include <chrono>
|
||||
|
||||
using namespace musik::core;
|
||||
using namespace musik::core::audio;
|
||||
using namespace musik::glue;
|
||||
using namespace musik::glue::audio;
|
||||
using namespace musik::win;
|
||||
using namespace win32cpp;
|
||||
|
||||
int APIENTRY _tWinMain(HINSTANCE instance, HINSTANCE previousInstance, LPTSTR commandLine, int showCommand) {
|
||||
LibraryPtr library = LibraryFactory::Libraries().at(0);
|
||||
MasterTransport transport;
|
||||
|
||||
transport.Start("c:\\test.ogg");
|
||||
|
||||
Application::Initialize(instance, previousInstance, commandLine, showCommand);
|
||||
Application& app = Application::Instance();
|
||||
|
||||
TopLevelWindow mainWindow(_TT("musikwin").c_str());
|
||||
mainWindow.Resize(800, 600);
|
||||
mainWindow.MoveTo(10, 10);
|
||||
MainWindow mainWindow(_TT("musikwin").c_str());
|
||||
mainWindow.Initialize();
|
||||
mainWindow.Resize(640, 400);
|
||||
mainWindow.MoveTo(200, 200);
|
||||
|
||||
LibraryPtr library = LibraryFactory::Libraries().at(0);
|
||||
MasterTransport transport;
|
||||
PlaybackService playback(mainWindow.Queue(), library, transport);
|
||||
|
||||
std::shared_ptr<SearchTrackListQuery> query =
|
||||
std::shared_ptr<SearchTrackListQuery>(new SearchTrackListQuery(library, "o'o"));
|
||||
|
||||
library->Enqueue(query, ILibrary::QuerySynchronous);
|
||||
|
||||
playback.Play(*query->GetResult(), 0);
|
||||
|
||||
//size_t count = vis::VisualizerCount();
|
||||
//if (count) {
|
||||
// vis::SetSelectedVisualizer(vis::GetVisualizer(1));
|
||||
// vis::SelectedVisualizer()->Show();
|
||||
//}
|
||||
|
||||
app.Run(mainWindow);
|
||||
|
||||
|
139
src/musikwin/app/view/MainWindow.cpp
Normal file
139
src/musikwin/app/view/MainWindow.cpp
Normal file
@ -0,0 +1,139 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2007-2016 musikcube team
|
||||
//
|
||||
// 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 "MainWindow.h"
|
||||
|
||||
#include <core/config.h>
|
||||
#include <core/runtime/MessageQueue.h>
|
||||
|
||||
#include <chrono>
|
||||
|
||||
static const DWORD WM_SCHEDULE_CORE_DISPATCH = WM_USER + 1;
|
||||
static const UINT_PTR DISPATCH_TIMER_ID = 1;
|
||||
|
||||
using namespace musik::core::runtime;
|
||||
using namespace musik::win;
|
||||
using namespace std::chrono;
|
||||
|
||||
class MainWindow::Win32MessageQueue : public MessageQueue {
|
||||
public:
|
||||
Win32MessageQueue(HWND hwnd) : hwnd(hwnd) {
|
||||
MessageQueue();
|
||||
this->nextTimerTime = -1;
|
||||
}
|
||||
|
||||
virtual void Post(IMessagePtr message, int64 delayMs = 0) {
|
||||
MessageQueue::Post(message, delayMs);
|
||||
::PostMessage(hwnd, WM_SCHEDULE_CORE_DISPATCH, 0, 0);
|
||||
}
|
||||
|
||||
void Reset() {
|
||||
::KillTimer(hwnd, DISPATCH_TIMER_ID);
|
||||
this->nextTimerTime = -1;
|
||||
}
|
||||
|
||||
void ScheduleNext() {
|
||||
int64 now = duration_cast<milliseconds>(
|
||||
system_clock::now().time_since_epoch()).count();
|
||||
|
||||
int64 next = this->GetNextMessageTime();
|
||||
|
||||
bool dispatch =
|
||||
(nextTimerTime > 0 && next < this->nextTimerTime) ||
|
||||
(next > 0 && nextTimerTime <= 0);
|
||||
|
||||
if (dispatch) {
|
||||
int64 delayMs = next - now;
|
||||
if (delayMs > 0) {
|
||||
::SetTimer(hwnd, DISPATCH_TIMER_ID, (UINT)delayMs, nullptr);
|
||||
this->nextTimerTime = next;
|
||||
}
|
||||
else {
|
||||
::PostMessage(this->hwnd, WM_TIMER, DISPATCH_TIMER_ID, 0);
|
||||
::KillTimer(this->hwnd, DISPATCH_TIMER_ID);
|
||||
this->nextTimerTime = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
int64 nextTimerTime;
|
||||
HWND hwnd;
|
||||
};
|
||||
|
||||
MainWindow::MainWindow(const win32cpp::uichar* windowTitle)
|
||||
: TopLevelWindow(windowTitle) {
|
||||
this->queue = nullptr;
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow() {
|
||||
delete this->queue;
|
||||
}
|
||||
|
||||
LRESULT MainWindow::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) {
|
||||
if (message == WM_TIMER) {
|
||||
if (wParam == DISPATCH_TIMER_ID) {
|
||||
if (!this->queue) {
|
||||
this->queue = new Win32MessageQueue(this->Handle());
|
||||
}
|
||||
|
||||
this->queue->Dispatch();
|
||||
this->queue->Reset();
|
||||
this->queue->ScheduleNext();
|
||||
|
||||
return 0L;
|
||||
}
|
||||
}
|
||||
else if (message == WM_SCHEDULE_CORE_DISPATCH) {
|
||||
if (!this->queue) {
|
||||
this->queue = new Win32MessageQueue(this->Handle());
|
||||
}
|
||||
|
||||
if (this->queue) {
|
||||
this->queue->ScheduleNext();
|
||||
}
|
||||
|
||||
return 0L;
|
||||
}
|
||||
|
||||
return TopLevelWindow::WindowProc(message, wParam, lParam);
|
||||
}
|
||||
|
||||
musik::core::runtime::IMessageQueue& MainWindow::Queue() {
|
||||
if (!this->queue && this->Handle()) {
|
||||
this->queue = new Win32MessageQueue(this->Handle());
|
||||
}
|
||||
|
||||
return *(this->queue);
|
||||
}
|
55
src/musikwin/app/view/MainWindow.h
Normal file
55
src/musikwin/app/view/MainWindow.h
Normal file
@ -0,0 +1,55 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2007-2016 musikcube team
|
||||
//
|
||||
// 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/TopLevelWindow.hpp>
|
||||
#include <core/runtime/IMessageQueue.h>
|
||||
|
||||
namespace musik { namespace win {
|
||||
class MainWindow : public win32cpp::TopLevelWindow {
|
||||
private:
|
||||
class Win32MessageQueue;
|
||||
|
||||
public:
|
||||
MainWindow(const win32cpp::uichar* windowTitle);
|
||||
virtual ~MainWindow();
|
||||
|
||||
virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam);
|
||||
musik::core::runtime::IMessageQueue& Queue();
|
||||
|
||||
private:
|
||||
Win32MessageQueue* queue;
|
||||
};
|
||||
} }
|
@ -161,6 +161,7 @@
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="app\view\MainWindow.h" />
|
||||
<ClInclude Include="pch.h" />
|
||||
<ClInclude Include="win32cpp\Application.hpp" />
|
||||
<ClInclude Include="win32cpp\ApplicationThread.hpp" />
|
||||
@ -206,6 +207,7 @@
|
||||
<ClInclude Include="win32cpp\WindowPadding.hpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="app\view\MainWindow.cpp" />
|
||||
<ClCompile Include="Main.cpp" />
|
||||
<ClCompile Include="pch.cpp" />
|
||||
<ClCompile Include="win32cpp\Application.cpp" />
|
||||
|
@ -4,10 +4,13 @@
|
||||
<Filter Include="win32cpp">
|
||||
<UniqueIdentifier>{01f8691c-a7bb-4dd7-822e-0747f9f1631c}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="musikwin">
|
||||
<Filter Include="app">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="app\view">
|
||||
<UniqueIdentifier>{94c9ba27-fe20-4cf8-ab88-c592d44a291e}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="win32cpp\Button.hpp">
|
||||
@ -137,6 +140,9 @@
|
||||
<Filter>win32cpp</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="pch.h" />
|
||||
<ClInclude Include="app\view\MainWindow.h">
|
||||
<Filter>app\view</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="win32cpp\CheckBox.cpp">
|
||||
@ -249,7 +255,10 @@
|
||||
</ClCompile>
|
||||
<ClCompile Include="pch.cpp" />
|
||||
<ClCompile Include="Main.cpp">
|
||||
<Filter>musikwin</Filter>
|
||||
<Filter>app</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="app\view\MainWindow.cpp">
|
||||
<Filter>app\view</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
@ -8,31 +8,31 @@
|
||||
//
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// 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
|
||||
// * 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.
|
||||
// * 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.
|
||||
// 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.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
@ -8,31 +8,31 @@
|
||||
//
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// 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
|
||||
// * 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.
|
||||
// * 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.
|
||||
// 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.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@ -174,16 +174,16 @@ LRESULT TopLevelWindow::WindowProc(UINT message, WPARAM wParam, LPARAM lPara
|
||||
// Close handler is used together with ShowModal
|
||||
// According to http://msdn.microsoft.com/en-us/library/ms646291.aspx
|
||||
// we need to do:
|
||||
// "A window must be enabled before it can be activated. For example,
|
||||
// if an application is displaying a modeless dialog box and has disabled
|
||||
// its main window, the application must enable the main window before
|
||||
// destroying the dialog box. Otherwise, another window will receive the
|
||||
// "A window must be enabled before it can be activated. For example,
|
||||
// if an application is displaying a modeless dialog box and has disabled
|
||||
// its main window, the application must enable the main window before
|
||||
// destroying the dialog box. Otherwise, another window will receive the
|
||||
// keyboard focus and be activated."
|
||||
if(this->parentWindow) {
|
||||
this->parentWindow->Enable(true);
|
||||
this->parentWindow->Enable(true);
|
||||
SetForegroundWindow(this->parentWindow->Handle());
|
||||
BringWindowToTop(this->parentWindow->Handle());
|
||||
|
||||
|
||||
this->parentWindow = NULL;
|
||||
}
|
||||
|
||||
@ -233,7 +233,7 @@ void TopLevelWindow::OnRequestFocusNext()
|
||||
}
|
||||
|
||||
void TopLevelWindow::OnRequestFocusPrev()
|
||||
{
|
||||
{
|
||||
bool focusChildSuccess = false;
|
||||
|
||||
// if we're on the first focused item, jump to the last.
|
||||
@ -289,7 +289,7 @@ void TopLevelWindow::ShowModal(TopLevelWindow* parent)
|
||||
if (parent)
|
||||
{
|
||||
parent->modalChild = this;
|
||||
|
||||
|
||||
// Disable keyboard/mouse input on the parent window,
|
||||
// this also means it gets deactivated (NOT in foreground)
|
||||
parent->Enable(false);
|
||||
@ -340,7 +340,7 @@ void TopLevelWindow::ShowModal(TopLevelWindow* parent)
|
||||
// TODO: log me
|
||||
}
|
||||
|
||||
if (parent)
|
||||
if (parent)
|
||||
{
|
||||
parent->modalChild = NULL;
|
||||
}
|
||||
|
@ -8,31 +8,31 @@
|
||||
//
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// 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
|
||||
// * 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.
|
||||
// * 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.
|
||||
// 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.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@ -64,7 +64,7 @@ TrayIconManager::TrayIconManager()
|
||||
TrayIconManager::~TrayIconManager()
|
||||
{
|
||||
// iterate through list and delete icons
|
||||
for(IconList::iterator i = TrayIconManager::iconList.begin(); i != TrayIconManager::iconList.end(); ++i) {
|
||||
for(IconList::iterator i = TrayIconManager::iconList.begin(); i != TrayIconManager::iconList.end(); ++i) {
|
||||
::Shell_NotifyIcon(NIM_DELETE, &i->second);
|
||||
}
|
||||
}
|
||||
@ -109,7 +109,7 @@ bool TrayIconManager::DeleteIcon(UINT uid)
|
||||
///
|
||||
///\param timeout
|
||||
///Time to show the balloon in seconds. There are special restrictions defined
|
||||
///by the Windows-API. Look here:
|
||||
///by the Windows-API. Look here:
|
||||
///http://msdn.microsoft.com/en-us/library/bb773352(VS.85).aspx
|
||||
///
|
||||
///\param text
|
||||
@ -122,10 +122,10 @@ bool TrayIconManager::ShowBalloon(UINT uid, const uistring& title, const uistrin
|
||||
TrayIconManager::iconList[uid].uFlags |= NIF_INFO;
|
||||
TrayIconManager::iconList[uid].uTimeout = timeout * 1000;
|
||||
TrayIconManager::iconList[uid].dwInfoFlags = icon;
|
||||
|
||||
|
||||
::wcsncpy_s(TrayIconManager::iconList[uid].szInfoTitle, 64, title.c_str(), 64);
|
||||
::wcsncpy_s(TrayIconManager::iconList[uid].szInfo, 256, text.c_str(), 256);
|
||||
|
||||
|
||||
return (::Shell_NotifyIcon(NIM_MODIFY, &TrayIconManager::iconList[uid]) != 0);
|
||||
}
|
||||
|
||||
@ -192,7 +192,7 @@ bool TrayIconManager::SetPopupMenu(UINT uid, MenuRef menu)
|
||||
if(menu) {
|
||||
TrayIconManager::menuList[uid] = menu;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
@ -217,7 +217,7 @@ LRESULT TrayIconManager::WindowProc(HWND window, UINT message, WPARAM wParam, LP
|
||||
{
|
||||
if(TrayIconManager::menuList.find(message - WM_W32CPP_SYSTRAY) != TrayIconManager::menuList.end()) {
|
||||
UINT uid = message - WM_W32CPP_SYSTRAY;
|
||||
|
||||
|
||||
switch(LOWORD(lParam)) {
|
||||
case WM_RBUTTONDOWN:
|
||||
{
|
||||
@ -255,7 +255,7 @@ LRESULT TrayIconManager::WindowProc(HWND window, UINT message, WPARAM wParam, LP
|
||||
// handle minimize to tray
|
||||
if(message == WM_SIZE && wParam == SIZE_MINIMIZED) {
|
||||
// iterate through list with icon options and look, if the assigned icon/window pair wants that
|
||||
for(IconList::iterator i = TrayIconManager::iconList.begin(); i != TrayIconManager::iconList.end(); ++i) {
|
||||
for(IconList::iterator i = TrayIconManager::iconList.begin(); i != TrayIconManager::iconList.end(); ++i) {
|
||||
// look if there is a corresponding window
|
||||
if(i->second.hWnd == window) {
|
||||
if(TrayIconManager::optionsList[i->second.uID] & TrayIconManager::MINIMIZE_TO_TRAY) {
|
||||
@ -322,12 +322,12 @@ int TrayIconManager::AddIcon(Window* window, HICON icon, const uistring& tooltip
|
||||
if(!::Shell_NotifyIcon(NIM_ADD, &nid)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
nid.uVersion = NOTIFYICON_VERSION;
|
||||
if(!::Shell_NotifyIcon(NIM_SETVERSION, &nid)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
// add to icon list
|
||||
TrayIconManager::iconList[uid] = nid;
|
||||
|
||||
|
@ -49,4 +49,5 @@
|
||||
#include <windows.h>
|
||||
#include <windowsx.h>
|
||||
#include <commctrl.h>
|
||||
#include <shellapi.h>
|
||||
#include <shellapi.h>
|
||||
#include <memory>
|
Loading…
x
Reference in New Issue
Block a user