2016-05-31 09:46:31 +00:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
2018-01-03 10:23:14 +00:00
|
|
|
the official desktop application for the Telegram messaging service.
|
2016-05-31 09:46:31 +00:00
|
|
|
|
2018-01-03 10:23:14 +00:00
|
|
|
For license and copyright information please follow this link:
|
|
|
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
2016-05-31 09:46:31 +00:00
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
2018-01-11 19:33:26 +00:00
|
|
|
#include "history/view/history_view_element.h"
|
|
|
|
|
2017-06-22 15:11:41 +00:00
|
|
|
class HistoryService;
|
|
|
|
|
2018-01-09 17:08:31 +00:00
|
|
|
namespace HistoryView {
|
2016-05-31 09:46:31 +00:00
|
|
|
|
2018-01-11 19:33:26 +00:00
|
|
|
class Service : public Element {
|
|
|
|
public:
|
2018-01-19 17:10:58 +00:00
|
|
|
Service(
|
|
|
|
not_null<ElementDelegate*> delegate,
|
|
|
|
not_null<HistoryService*> data);
|
2018-01-11 19:33:26 +00:00
|
|
|
|
2018-02-16 17:59:35 +00:00
|
|
|
int marginTop() const override;
|
|
|
|
int marginBottom() const override;
|
2018-01-30 13:17:50 +00:00
|
|
|
bool isHidden() const override;
|
2018-01-13 12:45:11 +00:00
|
|
|
void draw(
|
|
|
|
Painter &p,
|
|
|
|
QRect clip,
|
|
|
|
TextSelection selection,
|
2019-02-19 06:57:53 +00:00
|
|
|
crl::time ms) const override;
|
2018-01-27 13:59:24 +00:00
|
|
|
PointState pointState(QPoint point) const override;
|
|
|
|
TextState textState(
|
2018-01-13 12:45:11 +00:00
|
|
|
QPoint point,
|
2018-01-27 13:59:24 +00:00
|
|
|
StateRequest request) const override;
|
2018-01-13 12:45:11 +00:00
|
|
|
void updatePressed(QPoint point) override;
|
2019-04-08 15:10:06 +00:00
|
|
|
TextForMimeData selectedText(TextSelection selection) const override;
|
2018-01-14 16:02:25 +00:00
|
|
|
TextSelection adjustSelection(
|
|
|
|
TextSelection selection,
|
|
|
|
TextSelectType type) const override;
|
2018-01-13 12:45:11 +00:00
|
|
|
|
2018-01-11 19:33:26 +00:00
|
|
|
private:
|
|
|
|
not_null<HistoryService*> message() const;
|
|
|
|
|
2018-01-13 12:45:11 +00:00
|
|
|
QRect countGeometry() const;
|
|
|
|
|
|
|
|
QSize performCountOptimalSize() override;
|
|
|
|
QSize performCountCurrentSize(int newWidth) override;
|
|
|
|
|
2018-01-11 19:33:26 +00:00
|
|
|
};
|
|
|
|
|
2017-05-17 12:38:42 +00:00
|
|
|
int WideChatWidth();
|
|
|
|
|
2016-06-09 11:51:24 +00:00
|
|
|
struct PaintContext {
|
2019-02-19 06:57:53 +00:00
|
|
|
PaintContext(crl::time ms, const QRect &clip, TextSelection selection)
|
2016-06-09 11:51:24 +00:00
|
|
|
: ms(ms)
|
|
|
|
, clip(clip)
|
|
|
|
, selection(selection) {
|
|
|
|
}
|
2019-02-19 06:57:53 +00:00
|
|
|
crl::time ms;
|
2016-06-09 11:51:24 +00:00
|
|
|
const QRect &clip;
|
|
|
|
TextSelection selection;
|
|
|
|
};
|
2016-05-31 09:46:31 +00:00
|
|
|
|
2016-06-09 11:51:24 +00:00
|
|
|
class ServiceMessagePainter {
|
|
|
|
public:
|
2016-06-10 10:21:09 +00:00
|
|
|
static void paintDate(Painter &p, const QDateTime &date, int y, int w);
|
|
|
|
static void paintDate(Painter &p, const QString &dateText, int dateTextWidth, int y, int w);
|
|
|
|
|
2016-07-08 10:06:41 +00:00
|
|
|
static void paintBubble(Painter &p, int x, int y, int w, int h);
|
|
|
|
|
2019-06-12 13:26:04 +00:00
|
|
|
static void paintComplexBubble(Painter &p, int left, int width, const Ui::Text::String &text, const QRect &textRect);
|
2018-01-13 12:45:11 +00:00
|
|
|
|
|
|
|
private:
|
2019-06-12 13:26:04 +00:00
|
|
|
static QVector<int> countLineWidths(const Ui::Text::String &text, const QRect &textRect);
|
2016-06-09 11:51:24 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
2019-01-18 08:11:15 +00:00
|
|
|
class EmptyPainter {
|
|
|
|
public:
|
|
|
|
explicit EmptyPainter(not_null<History*> history);
|
|
|
|
|
|
|
|
void paint(Painter &p, int width, int height);
|
|
|
|
|
|
|
|
private:
|
|
|
|
void fillAboutGroup();
|
|
|
|
|
|
|
|
not_null<History*> _history;
|
2019-06-12 13:26:04 +00:00
|
|
|
Ui::Text::String _header = { st::msgMinWidth };
|
|
|
|
Ui::Text::String _text = { st::msgMinWidth };
|
|
|
|
std::vector<Ui::Text::String> _phrases;
|
2019-01-18 08:11:15 +00:00
|
|
|
|
|
|
|
};
|
2016-10-22 18:58:25 +00:00
|
|
|
|
2016-06-09 11:51:24 +00:00
|
|
|
void serviceColorsUpdated();
|
|
|
|
|
2018-01-09 17:08:31 +00:00
|
|
|
} // namespace HistoryView
|