2009-10-06 02:26:54 +00:00
|
|
|
/* vim: se cin sw=2 ts=2 et : */
|
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
*
|
2012-05-21 11:12:37 +00:00
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2009-10-06 02:26:54 +00:00
|
|
|
|
|
|
|
#include <windows.h>
|
|
|
|
#include <strsafe.h>
|
|
|
|
|
|
|
|
#include "TaskbarWindowPreview.h"
|
|
|
|
#include "TaskbarPreviewButton.h"
|
|
|
|
#include "nsWindowGfx.h"
|
|
|
|
#include <imgIContainer.h>
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace widget {
|
|
|
|
|
2014-04-27 07:06:00 +00:00
|
|
|
NS_IMPL_ISUPPORTS(TaskbarPreviewButton, nsITaskbarPreviewButton,
|
|
|
|
nsISupportsWeakReference)
|
2009-10-06 02:26:54 +00:00
|
|
|
|
2019-05-01 08:47:10 +00:00
|
|
|
TaskbarPreviewButton::TaskbarPreviewButton(TaskbarWindowPreview* preview,
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t index)
|
2009-10-06 02:26:54 +00:00
|
|
|
: mPreview(preview), mIndex(index) {}
|
|
|
|
|
|
|
|
TaskbarPreviewButton::~TaskbarPreviewButton() { SetVisible(false); }
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2019-05-01 08:47:10 +00:00
|
|
|
TaskbarPreviewButton::GetTooltip(nsAString& aTooltip) {
|
2009-10-06 02:26:54 +00:00
|
|
|
aTooltip = mTooltip;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2019-05-01 08:47:10 +00:00
|
|
|
TaskbarPreviewButton::SetTooltip(const nsAString& aTooltip) {
|
2009-10-06 02:26:54 +00:00
|
|
|
mTooltip = aTooltip;
|
|
|
|
size_t destLength = sizeof Button().szTip / (sizeof Button().szTip[0]);
|
2019-05-01 08:47:10 +00:00
|
|
|
wchar_t* tooltip = &(Button().szTip[0]);
|
2009-10-06 02:26:54 +00:00
|
|
|
StringCchCopyNW(tooltip, destLength, mTooltip.get(), mTooltip.Length());
|
|
|
|
return Update();
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2019-05-01 08:47:10 +00:00
|
|
|
TaskbarPreviewButton::GetDismissOnClick(bool* dismiss) {
|
2009-10-06 02:26:54 +00:00
|
|
|
*dismiss = (Button().dwFlags & THBF_DISMISSONCLICK) == THBF_DISMISSONCLICK;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2011-09-29 06:19:26 +00:00
|
|
|
TaskbarPreviewButton::SetDismissOnClick(bool dismiss) {
|
2009-10-06 02:26:54 +00:00
|
|
|
if (dismiss)
|
|
|
|
Button().dwFlags |= THBF_DISMISSONCLICK;
|
|
|
|
else
|
|
|
|
Button().dwFlags &= ~THBF_DISMISSONCLICK;
|
|
|
|
return Update();
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2019-05-01 08:47:10 +00:00
|
|
|
TaskbarPreviewButton::GetHasBorder(bool* hasBorder) {
|
2009-10-06 02:26:54 +00:00
|
|
|
*hasBorder = (Button().dwFlags & THBF_NOBACKGROUND) != THBF_NOBACKGROUND;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2011-09-29 06:19:26 +00:00
|
|
|
TaskbarPreviewButton::SetHasBorder(bool hasBorder) {
|
2009-10-06 02:26:54 +00:00
|
|
|
if (hasBorder)
|
|
|
|
Button().dwFlags &= ~THBF_NOBACKGROUND;
|
|
|
|
else
|
|
|
|
Button().dwFlags |= THBF_NOBACKGROUND;
|
|
|
|
return Update();
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2019-05-01 08:47:10 +00:00
|
|
|
TaskbarPreviewButton::GetDisabled(bool* disabled) {
|
2009-10-06 02:26:54 +00:00
|
|
|
*disabled = (Button().dwFlags & THBF_DISABLED) == THBF_DISABLED;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2011-09-29 06:19:26 +00:00
|
|
|
TaskbarPreviewButton::SetDisabled(bool disabled) {
|
2009-10-06 02:26:54 +00:00
|
|
|
if (disabled)
|
|
|
|
Button().dwFlags |= THBF_DISABLED;
|
|
|
|
else
|
|
|
|
Button().dwFlags &= ~THBF_DISABLED;
|
|
|
|
return Update();
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2019-05-01 08:47:10 +00:00
|
|
|
TaskbarPreviewButton::GetImage(imgIContainer** img) {
|
2009-10-06 02:26:54 +00:00
|
|
|
if (mImage)
|
|
|
|
NS_ADDREF(*img = mImage);
|
|
|
|
else
|
2013-10-08 18:48:20 +00:00
|
|
|
*img = nullptr;
|
2009-10-06 02:26:54 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2019-05-01 08:47:10 +00:00
|
|
|
TaskbarPreviewButton::SetImage(imgIContainer* img) {
|
2009-10-06 02:26:54 +00:00
|
|
|
if (Button().hIcon) ::DestroyIcon(Button().hIcon);
|
|
|
|
if (img) {
|
|
|
|
nsresult rv;
|
2011-10-02 02:16:19 +00:00
|
|
|
rv = nsWindowGfx::CreateIcon(
|
2019-06-20 20:00:24 +00:00
|
|
|
img, false, LayoutDeviceIntPoint(),
|
2011-09-28 18:36:43 +00:00
|
|
|
nsWindowGfx::GetIconMetrics(nsWindowGfx::kRegularIcon),
|
|
|
|
&Button().hIcon);
|
2009-10-06 02:26:54 +00:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
} else {
|
2013-10-08 18:48:20 +00:00
|
|
|
Button().hIcon = nullptr;
|
2009-10-06 02:26:54 +00:00
|
|
|
}
|
|
|
|
return Update();
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2019-05-01 08:47:10 +00:00
|
|
|
TaskbarPreviewButton::GetVisible(bool* visible) {
|
2010-04-01 11:29:09 +00:00
|
|
|
*visible = (Button().dwFlags & THBF_HIDDEN) != THBF_HIDDEN;
|
2009-10-06 02:26:54 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2011-09-29 06:19:26 +00:00
|
|
|
TaskbarPreviewButton::SetVisible(bool visible) {
|
2009-10-06 02:26:54 +00:00
|
|
|
if (visible)
|
|
|
|
Button().dwFlags &= ~THBF_HIDDEN;
|
|
|
|
else
|
|
|
|
Button().dwFlags |= THBF_HIDDEN;
|
|
|
|
return Update();
|
|
|
|
}
|
|
|
|
|
2019-05-01 08:47:10 +00:00
|
|
|
THUMBBUTTON& TaskbarPreviewButton::Button() {
|
2009-10-06 02:26:54 +00:00
|
|
|
return mPreview->mThumbButtons[mIndex];
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult TaskbarPreviewButton::Update() {
|
|
|
|
return mPreview->UpdateButton(mIndex);
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace widget
|
|
|
|
} // namespace mozilla
|