2009-10-05 19:26:54 -07:00
|
|
|
/* vim: se cin sw=2 ts=2 et : */
|
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
*
|
|
|
|
* ***** BEGIN LICENSE BLOCK *****
|
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
|
|
|
*
|
|
|
|
* The contents of this file are subject to the Mozilla Public License Version
|
|
|
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
|
|
|
* the License. You may obtain a copy of the License at
|
|
|
|
* http://www.mozilla.org/MPL/
|
|
|
|
*
|
|
|
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* License.
|
|
|
|
*
|
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is
|
|
|
|
* Mozilla Foundation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 2009
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
|
|
|
* Rob Arnold <tellrob@gmail.com>
|
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
|
|
|
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
|
|
|
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
|
|
|
|
|
|
|
#if MOZ_WINSDK_TARGETVER >= MOZ_NTDDI_WIN7
|
|
|
|
|
|
|
|
#include <windows.h>
|
|
|
|
#include <strsafe.h>
|
|
|
|
|
|
|
|
#include "TaskbarWindowPreview.h"
|
|
|
|
#include "TaskbarPreviewButton.h"
|
|
|
|
#include "nsWindowGfx.h"
|
|
|
|
#include <imgIContainer.h>
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace widget {
|
|
|
|
|
|
|
|
NS_IMPL_ISUPPORTS2(TaskbarPreviewButton, nsITaskbarPreviewButton, nsISupportsWeakReference)
|
|
|
|
|
|
|
|
TaskbarPreviewButton::TaskbarPreviewButton(TaskbarWindowPreview* preview, PRUint32 index)
|
|
|
|
: mPreview(preview), mIndex(index)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
TaskbarPreviewButton::~TaskbarPreviewButton() {
|
|
|
|
SetVisible(PR_FALSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
TaskbarPreviewButton::GetTooltip(nsAString &aTooltip) {
|
|
|
|
aTooltip = mTooltip;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
TaskbarPreviewButton::SetTooltip(const nsAString &aTooltip) {
|
|
|
|
mTooltip = aTooltip;
|
|
|
|
size_t destLength = sizeof Button().szTip / (sizeof Button().szTip[0]);
|
|
|
|
wchar_t *tooltip = &(Button().szTip[0]);
|
|
|
|
StringCchCopyNW(tooltip,
|
|
|
|
destLength,
|
|
|
|
mTooltip.get(),
|
|
|
|
mTooltip.Length());
|
|
|
|
return Update();
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2011-09-28 23:19:26 -07:00
|
|
|
TaskbarPreviewButton::GetDismissOnClick(bool *dismiss) {
|
2009-10-05 19:26:54 -07:00
|
|
|
*dismiss = (Button().dwFlags & THBF_DISMISSONCLICK) == THBF_DISMISSONCLICK;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2011-09-28 23:19:26 -07:00
|
|
|
TaskbarPreviewButton::SetDismissOnClick(bool dismiss) {
|
2009-10-05 19:26:54 -07:00
|
|
|
if (dismiss)
|
|
|
|
Button().dwFlags |= THBF_DISMISSONCLICK;
|
|
|
|
else
|
|
|
|
Button().dwFlags &= ~THBF_DISMISSONCLICK;
|
|
|
|
return Update();
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2011-09-28 23:19:26 -07:00
|
|
|
TaskbarPreviewButton::GetHasBorder(bool *hasBorder) {
|
2009-10-05 19:26:54 -07:00
|
|
|
*hasBorder = (Button().dwFlags & THBF_NOBACKGROUND) != THBF_NOBACKGROUND;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2011-09-28 23:19:26 -07:00
|
|
|
TaskbarPreviewButton::SetHasBorder(bool hasBorder) {
|
2009-10-05 19:26:54 -07:00
|
|
|
if (hasBorder)
|
|
|
|
Button().dwFlags &= ~THBF_NOBACKGROUND;
|
|
|
|
else
|
|
|
|
Button().dwFlags |= THBF_NOBACKGROUND;
|
|
|
|
return Update();
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2011-09-28 23:19:26 -07:00
|
|
|
TaskbarPreviewButton::GetDisabled(bool *disabled) {
|
2009-10-05 19:26:54 -07:00
|
|
|
*disabled = (Button().dwFlags & THBF_DISABLED) == THBF_DISABLED;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2011-09-28 23:19:26 -07:00
|
|
|
TaskbarPreviewButton::SetDisabled(bool disabled) {
|
2009-10-05 19:26:54 -07:00
|
|
|
if (disabled)
|
|
|
|
Button().dwFlags |= THBF_DISABLED;
|
|
|
|
else
|
|
|
|
Button().dwFlags &= ~THBF_DISABLED;
|
|
|
|
return Update();
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
TaskbarPreviewButton::GetImage(imgIContainer **img) {
|
|
|
|
if (mImage)
|
|
|
|
NS_ADDREF(*img = mImage);
|
|
|
|
else
|
|
|
|
*img = NULL;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
TaskbarPreviewButton::SetImage(imgIContainer *img) {
|
|
|
|
if (Button().hIcon)
|
|
|
|
::DestroyIcon(Button().hIcon);
|
|
|
|
if (img) {
|
|
|
|
nsresult rv;
|
2011-09-28 11:36:43 -07:00
|
|
|
rv = nsWindowGfx::CreateIcon(img, PR_FALSE, 0, 0,
|
|
|
|
nsWindowGfx::GetIconMetrics(nsWindowGfx::kRegularIcon),
|
|
|
|
&Button().hIcon);
|
2009-10-05 19:26:54 -07:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
} else {
|
|
|
|
Button().hIcon = NULL;
|
|
|
|
}
|
|
|
|
return Update();
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2011-09-28 23:19:26 -07:00
|
|
|
TaskbarPreviewButton::GetVisible(bool *visible) {
|
2010-04-01 04:29:09 -07:00
|
|
|
*visible = (Button().dwFlags & THBF_HIDDEN) != THBF_HIDDEN;
|
2009-10-05 19:26:54 -07:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2011-09-28 23:19:26 -07:00
|
|
|
TaskbarPreviewButton::SetVisible(bool visible) {
|
2009-10-05 19:26:54 -07:00
|
|
|
if (visible)
|
|
|
|
Button().dwFlags &= ~THBF_HIDDEN;
|
|
|
|
else
|
|
|
|
Button().dwFlags |= THBF_HIDDEN;
|
|
|
|
return Update();
|
|
|
|
}
|
|
|
|
|
|
|
|
THUMBBUTTON&
|
|
|
|
TaskbarPreviewButton::Button() {
|
|
|
|
return mPreview->mThumbButtons[mIndex];
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
TaskbarPreviewButton::Update() {
|
|
|
|
return mPreview->UpdateButton(mIndex);
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace widget
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // MOZ_WINSDK_TARGETVER >= MOZ_NTDDI_WIN7
|
|
|
|
|