electron/shell/browser/api/electron_api_tray.h

116 lines
3.6 KiB
C
Raw Normal View History

// Copyright (c) 2014 GitHub, Inc.
2014-05-30 15:57:54 +00:00
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
#ifndef SHELL_BROWSER_API_ELECTRON_API_TRAY_H_
#define SHELL_BROWSER_API_ELECTRON_API_TRAY_H_
2014-05-30 15:57:54 +00:00
2016-07-04 06:08:55 +00:00
#include <memory>
#include <string>
#include <vector>
#include "gin/handle.h"
#include "gin/wrappable.h"
#include "shell/browser/event_emitter_mixin.h"
#include "shell/browser/javascript_environment.h"
#include "shell/browser/ui/tray_icon.h"
#include "shell/browser/ui/tray_icon_observer.h"
#include "shell/common/gin_converters/guid_converter.h"
#include "shell/common/gin_helper/cleaned_up_at_exit.h"
#include "shell/common/gin_helper/constructible.h"
#include "shell/common/gin_helper/error_thrower.h"
2014-05-30 15:57:54 +00:00
namespace gfx {
class Image;
2014-05-30 15:57:54 +00:00
}
namespace gin_helper {
2014-11-28 10:39:30 +00:00
class Dictionary;
}
2014-11-28 10:06:51 +00:00
namespace electron {
2014-05-30 15:57:54 +00:00
namespace api {
class Menu;
class NativeImage;
2014-05-30 15:57:54 +00:00
class Tray : public gin::Wrappable<Tray>,
public gin_helper::EventEmitterMixin<Tray>,
public gin_helper::Constructible<Tray>,
public gin_helper::CleanedUpAtExit,
public TrayIconObserver {
2014-05-30 15:57:54 +00:00
public:
// gin_helper::Constructible
static gin::Handle<Tray> New(gin_helper::ErrorThrower thrower,
gin::Handle<NativeImage> image,
base::Optional<UUID> guid,
gin::Arguments* args);
static v8::Local<v8::ObjectTemplate> FillObjectTemplate(
v8::Isolate*,
v8::Local<v8::ObjectTemplate>);
// gin::Wrappable
static gin::WrapperInfo kWrapperInfo;
2014-05-30 15:57:54 +00:00
private:
Tray(gin::Handle<NativeImage> image,
base::Optional<UUID> guid,
gin::Arguments* args);
~Tray() override;
2014-05-30 15:57:54 +00:00
// TrayIconObserver:
2017-10-05 02:49:26 +00:00
void OnClicked(const gfx::Rect& bounds,
const gfx::Point& location,
int modifiers) override;
void OnDoubleClicked(const gfx::Rect& bounds, int modifiers) override;
2015-07-29 06:25:12 +00:00
void OnRightClicked(const gfx::Rect& bounds, int modifiers) override;
void OnBalloonShow() override;
void OnBalloonClicked() override;
void OnBalloonClosed() override;
2015-11-10 16:02:50 +00:00
void OnDrop() override;
void OnDropFiles(const std::vector<std::string>& files) override;
2016-07-14 17:21:39 +00:00
void OnDropText(const std::string& text) override;
void OnDragEntered() override;
void OnDragExited() override;
2015-11-10 16:02:50 +00:00
void OnDragEnded() override;
void OnMouseUp(const gfx::Point& location, int modifiers) override;
void OnMouseDown(const gfx::Point& location, int modifiers) override;
void OnMouseEntered(const gfx::Point& location, int modifiers) override;
void OnMouseExited(const gfx::Point& location, int modifiers) override;
void OnMouseMoved(const gfx::Point& location, int modifiers) override;
2014-06-02 03:08:29 +00:00
// JS API:
void Destroy();
bool IsDestroyed();
void SetImage(gin::Handle<NativeImage> image);
void SetPressedImage(gin::Handle<NativeImage> image);
void SetToolTip(const std::string& tool_tip);
void SetTitle(const std::string& title);
std::string GetTitle();
void SetIgnoreDoubleClickEvents(bool ignore);
bool GetIgnoreDoubleClickEvents();
void DisplayBalloon(gin_helper::ErrorThrower thrower,
const gin_helper::Dictionary& options);
void RemoveBalloon();
2019-08-09 14:43:48 +00:00
void Focus();
void PopUpContextMenu(gin::Arguments* args);
void CloseContextMenu();
void SetContextMenu(gin_helper::ErrorThrower thrower,
v8::Local<v8::Value> arg);
2016-06-21 06:40:30 +00:00
gfx::Rect GetBounds();
2014-05-30 15:57:54 +00:00
2020-04-03 00:22:46 +00:00
bool CheckAlive();
v8::Global<v8::Value> menu_;
2016-05-23 01:59:39 +00:00
std::unique_ptr<TrayIcon> tray_icon_;
2014-05-30 15:57:54 +00:00
DISALLOW_COPY_AND_ASSIGN(Tray);
};
} // namespace api
} // namespace electron
2014-05-30 15:57:54 +00:00
#endif // SHELL_BROWSER_API_ELECTRON_API_TRAY_H_