1 /* 2 This file is part of Telegram Desktop, 3 the official desktop application for the Telegram messaging service. 4 5 For license and copyright information please follow this link: 6 https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL 7 */ 8 #pragma once 9 10 #include "ui/chat/chat_style.h" 11 12 namespace Data { 13 class Media; 14 } // namespace Data 15 16 struct WebPageData; 17 18 namespace HistoryView { 19 20 struct TextState; 21 22 class ViewButton { 23 public: 24 ViewButton(not_null<PeerData*> peer, Fn<void()> updateCallback); 25 ViewButton(not_null<Data::Media*> media, Fn<void()> updateCallback); 26 ~ViewButton(); 27 28 [[nodiscard]] static bool MediaHasViewButton( 29 not_null<Data::Media*> media); 30 [[nodiscard]] static bool MediaHasViewButton( 31 not_null<WebPageData*> webpage); 32 33 [[nodiscard]] int height() const; 34 35 void draw( 36 Painter &p, 37 const QRect &r, 38 const Ui::ChatPaintContext &context); 39 40 [[nodiscard]] const ClickHandlerPtr &link() const; 41 bool checkLink(const ClickHandlerPtr &other, bool pressed); 42 43 [[nodiscard]] QRect countRect(const QRect &r) const; 44 45 [[nodiscard]] bool getState( 46 QPoint point, 47 const QRect &g, 48 not_null<TextState*> outResult) const; 49 50 private: 51 void resized() const; 52 53 struct Inner; 54 const std::unique_ptr<Inner> _inner; 55 }; 56 57 } // namespace HistoryView 58