2018-01-10 16:13:33 +03:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
|
|
|
the official desktop application for the Telegram messaging service.
|
|
|
|
|
|
|
|
For license and copyright information please follow this link:
|
|
|
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
class HistoryItem;
|
|
|
|
|
|
|
|
namespace HistoryView {
|
|
|
|
|
|
|
|
enum class Context : char {
|
|
|
|
History,
|
|
|
|
Feed,
|
|
|
|
AdminLog
|
|
|
|
};
|
|
|
|
|
|
|
|
class Message
|
|
|
|
: public RuntimeComposer
|
|
|
|
, public ClickHandlerHost {
|
|
|
|
public:
|
|
|
|
Message(not_null<HistoryItem*> data, Context context);
|
|
|
|
|
|
|
|
not_null<HistoryItem*> data() const;
|
|
|
|
|
|
|
|
int y() const {
|
|
|
|
return _y;
|
|
|
|
}
|
|
|
|
void setY(int y) {
|
|
|
|
_y = y;
|
|
|
|
}
|
|
|
|
|
2018-01-11 16:07:29 +03:00
|
|
|
HistoryBlock *block() {
|
|
|
|
return _block;
|
|
|
|
}
|
|
|
|
const HistoryBlock *block() const {
|
|
|
|
return _block;
|
|
|
|
}
|
|
|
|
void attachToBlock(not_null<HistoryBlock*> block, int index);
|
|
|
|
void removeFromBlock();
|
|
|
|
void setIndexInBlock(int index) {
|
|
|
|
Expects(_block != nullptr);
|
|
|
|
Expects(index >= 0);
|
|
|
|
|
|
|
|
_indexInBlock = index;
|
|
|
|
}
|
|
|
|
int indexInBlock() const {
|
|
|
|
Expects((_indexInBlock >= 0) == (_block != nullptr));
|
|
|
|
Expects((_block == nullptr) || (_block->messages[_indexInBlock].get() == this));
|
|
|
|
|
|
|
|
return _indexInBlock;
|
|
|
|
}
|
|
|
|
Message *previousInBlocks() const;
|
|
|
|
Message *nextInBlocks() const;
|
|
|
|
|
2018-01-11 18:51:59 +03:00
|
|
|
// ClickHandlerHost interface
|
|
|
|
void clickHandlerActiveChanged(
|
|
|
|
const ClickHandlerPtr &handler,
|
|
|
|
bool active) override;
|
|
|
|
void clickHandlerPressedChanged(
|
|
|
|
const ClickHandlerPtr &handler,
|
|
|
|
bool pressed) override;
|
|
|
|
|
2018-01-11 16:07:29 +03:00
|
|
|
~Message();
|
|
|
|
|
2018-01-10 16:13:33 +03:00
|
|
|
private:
|
|
|
|
const not_null<HistoryItem*> _data;
|
|
|
|
int _y = 0;
|
|
|
|
Context _context;
|
|
|
|
|
2018-01-11 16:07:29 +03:00
|
|
|
HistoryBlock *_block = nullptr;
|
|
|
|
int _indexInBlock = -1;
|
|
|
|
|
2018-01-10 16:13:33 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace HistoryView
|