electron/shell/browser/api/atom_api_tray.h

95 lines
2.9 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.
2019-06-19 20:56:58 +00:00
#ifndef SHELL_BROWSER_API_ATOM_API_TRAY_H_
#define SHELL_BROWSER_API_ATOM_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 "shell/browser/ui/tray_icon.h"
#include "shell/browser/ui/tray_icon_observer.h"
#include "shell/common/gin_helper/error_thrower.h"
#include "shell/common/gin_helper/trackable_object.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
class TrayIcon;
namespace api {
class Menu;
class NativeImage;
2014-05-30 15:57:54 +00:00
class Tray : public gin_helper::TrackableObject<Tray>, public TrayIconObserver {
2014-05-30 15:57:54 +00:00
public:
static gin_helper::WrappableBase* New(gin_helper::ErrorThrower thrower,
gin::Handle<NativeImage> image,
gin_helper::Arguments* args);
2014-05-30 15:57:54 +00:00
static void BuildPrototype(v8::Isolate* isolate,
v8::Local<v8::FunctionTemplate> prototype);
2014-05-30 15:57:54 +00:00
protected:
Tray(gin::Handle<NativeImage> image, gin_helper::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 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
void SetImage(v8::Isolate* isolate, gin::Handle<NativeImage> image);
void SetPressedImage(v8::Isolate* isolate, 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_helper::Arguments* args);
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
private:
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
2019-06-19 20:56:58 +00:00
#endif // SHELL_BROWSER_API_ATOM_API_TRAY_H_