ManaPlus
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes

#include <mailwindow.h>

Inheritance diagram for MailWindow:
Window ActionListener BasicContainer2 MouseListener WidgetListener BasicContainer Widget WidgetDeathListener Widget2

Public Member Functions

 MailWindow ()
 
 ~MailWindow ()
 
void action (const ActionEvent &event)
 
void addMail (MailMessage *const message)
 
void clear ()
 
void showMessage (MailMessage *const mail, const int itemsCount)
 
void removeMail (const int64_t id)
 
void viewNext (const int64_t id)
 
void viewPrev (const int64_t id)
 
void mouseClicked (MouseEvent &event)
 
void postConnection ()
 
MailMessagefindMail (const int64_t id)
 
void setOpenType (const MailOpenTypeT &type)
 
MailOpenTypeT getOpenType () const
 
void setLastPage ()
 
void refreshMailNames ()
 
- Public Member Functions inherited from Window
 Window (const std::string &caption, const Modal modal, Window *const parent, std::string skin)
 
 ~Window ()
 
void draw (Graphics *const graphics)
 
void safeDraw (Graphics *const graphics)
 
void setContentSize (int width, int height)
 
void setLocationRelativeTo (const Widget *const widget)
 
void setLocationHorisontallyRelativeTo (const Widget *const widget)
 
void setLocationRelativeTo (const ImagePosition::Type &position, int offsetX, int offsetY)
 
void setResizable (const bool resize)
 
void redraw ()
 
void widgetResized (const Event &event)
 
void widgetMoved (const Event &event)
 
void widgetHidden (const Event &event)
 
void setCloseButton (const bool flag)
 
bool getCloseButton () const
 
void setAllowClose (const bool b)
 
bool getAlowClose () const
 
bool isResizable () const
 
void setMinWidth (const int width)
 
int getMinWidth () const
 
void setMinHeight (const int height)
 
int getMinHeight () const
 
void setMaxWidth (const int width)
 
int getMaxWidth () const
 
void setMaxHeight (const int height)
 
int getMaxHeight () const
 
void setShowTitle (bool flag)
 
void setStickyButton (const bool flag)
 
void setSticky (const bool sticky)
 
bool isSticky () const
 
void setStickyButtonLock (const bool sticky)
 
bool isStickyButtonLock () const
 
virtual void setVisible (Visible visible)
 
void setVisible (const Visible visible, const bool forceSticky)
 
bool isDefaultVisible () const
 
void setDefaultVisible (const bool save)
 
bool willSaveVisible () const
 
void setSaveVisible (const bool save)
 
void postInit ()
 
WindowgetParentWindow () const
 
virtual void scheduleDelete ()
 
void mousePressed (MouseEvent &event)
 
void mouseDragged (MouseEvent &event)
 
void mouseMoved (MouseEvent &event)
 
void mouseReleased (MouseEvent &event)
 
void mouseExited (MouseEvent &event)
 
void mouseEntered (MouseEvent &event)
 
void updateResizeHandler (MouseEvent &event)
 
void setWindowName (const std::string &name)
 
const std::string & getWindowName () const
 
void loadWindowState ()
 
void saveWindowState ()
 
void setDefaultSize (const int defaultX, const int defaultY, int defaultWidth, int defaultHeight)
 
void setDefaultSize ()
 
void setDefaultSize (const int defaultWidth, const int defaultHeight, const ImagePosition::Type &position, const int offsetx, const int offsetY)
 
virtual void resetToDefaultSize ()
 
void adjustPositionAfterResize (const int oldScreenWidth, const int oldScreenHeight)
 
LayoutgetLayout ()
 
void clearLayout ()
 
void reflowLayout (int w, int h)
 
LayoutCellplace (const int x, const int y, Widget *const wg, const int w, const int h)
 
ContainerPlacer getPlacer (const int x, const int y)
 
void center ()
 
void centerHorisontally ()
 
virtual void close ()
 
void setModal (const Modal modal)
 
Rect getWindowArea () const
 
bool isResizeAllowed (const MouseEvent &event) const
 
void setCaptionFont (Font *font)
 
void enableVisibleSound (bool b)
 
bool isWindowVisible () const
 
void setPadding (int padding)
 
int getPadding () const
 
void setTitleBarHeight (unsigned int height)
 
unsigned int getTitleBarHeight () const
 
void setCaption (const std::string &caption)
 
const std::string & getCaption () const
 
void setAlignment (Graphics::Alignment alignment)
 
Graphics::Alignment getAlignment () const
 
void setMovable (Move movable)
 
bool isMovable () const
 
Rect getChildrenArea ()
 
virtual void resizeToContent ()
 
- Public Member Functions inherited from BasicContainer2
 BasicContainer2 (const Widget2 *const widget)
 
 ~BasicContainer2 ()
 
void setOpaque (Opaque opaque)
 
bool isOpaque () const
 
virtual void add (Widget *const widget)
 
void addXY (Widget *const widget, const int x, const int y)
 
- Public Member Functions inherited from BasicContainer
 BasicContainer (const Widget2 *const widget)
 
 ~BasicContainer ()
 
void showWidgetPart (Widget *const widget, const Rect &area)
 
void moveToTop (Widget *const widget)
 
void moveToBottom (Widget *const widget)
 
void focusNext ()
 
void focusPrevious ()
 
void logic ()
 
void setFocusHandler (FocusHandler *const focusHandler)
 
void setInternalFocusHandler (FocusHandler *const focusHandler)
 
WidgetgetWidgetAt (int x, int y)
 
void death (const Event &event)
 
WidgetfindFirstWidget (const std::set< Widget * > &list)
 
void add (Widget *const widget)
 
virtual void remove (Widget *const widget)
 
- Public Member Functions inherited from Widget
 Widget (const Widget2 *const widget)
 
 ~Widget ()
 
virtual void drawFrame (Graphics *graphics)
 
virtual void safeDrawFrame (Graphics *graphics)
 
void setFrameSize (const unsigned int frameSize)
 
unsigned int getFrameSize () const
 
WidgetgetParent () const
 
void setWidth (const int width)
 
int getWidth () const
 
void setHeight (const int height)
 
int getHeight () const
 
void setSize (const int width, const int height)
 
void setX (const int x)
 
int getX () const
 
void setY (const int y)
 
int getY () const
 
void setPosition (const int x, const int y)
 
void setDimension (const Rect &dimension)
 
const RectgetDimension () const
 
void setFocusable (const bool focusable)
 
bool isFocusable () const
 
virtual bool isFocused () const
 
void setEnabled (const bool enabled)
 
bool isEnabled () const
 
void setVisible (Visible visible)
 
bool isVisible () const
 
void setBaseColor (const Color &color)
 
const ColorgetBaseColor () const
 
void setForegroundColor (const Color &color)
 
const ColorgetForegroundColor () const
 
void setBackgroundColor (const Color &color)
 
const ColorgetBackgroundColor () const
 
virtual void requestFocus ()
 
virtual void requestMoveToTop ()
 
virtual void requestMoveToBottom ()
 
FocusHandlergetFocusHandler ()
 
void addActionListener (ActionListener *const actionListener)
 
void removeActionListener (ActionListener *const actionListener)
 
void addDeathListener (WidgetDeathListener *const deathListener)
 
void removeDeathListener (WidgetDeathListener *const deathListener)
 
void addMouseListener (MouseListener *const mouseListener)
 
void removeMouseListener (MouseListener *const mouseListener)
 
void addKeyListener (KeyListener *const keyListener)
 
void removeKeyListener (KeyListener *const keyListener)
 
void addFocusListener (FocusListener *const focusListener)
 
void removeFocusListener (FocusListener *const focusListener)
 
void addWidgetListener (WidgetListener *const widgetListener)
 
void removeWidgetListener (WidgetListener *const widgetListener)
 
void setActionEventId (const std::string &actionEventId)
 
const std::string & getActionEventId () const
 
virtual void getAbsolutePosition (int &x, int &y) const
 
virtual void setParent (Widget *parent)
 
FontgetFont () const
 
void setFont (Font *const font)
 
virtual void fontChanged ()
 
bool isTabInEnabled () const
 
void setTabInEnabled (const bool enabled)
 
bool isTabOutEnabled () const
 
void setTabOutEnabled (const bool enabled)
 
void requestModalFocus ()
 
virtual void requestModalMouseInputFocus ()
 
virtual void releaseModalFocus ()
 
virtual void releaseModalMouseInputFocus ()
 
virtual bool isModalFocused () const
 
virtual bool isModalMouseInputFocused () const
 
const std::list< MouseListener * > & getMouseListeners () const A_CONST
 
const std::list< KeyListener * > & getKeyListeners () const A_CONST
 
const std::list< FocusListener * > & getFocusListeners () const A_CONST
 
virtual FocusHandlergetInternalFocusHandler ()
 
void setInternalFocusHandler (FocusHandler *const internalFocusHandler)
 
void setId (const std::string &id)
 
const std::string & getId () const
 
virtual void showPart (const Rect &rectangle)
 
bool isAllowLogic () const
 
void setMouseConsume (const bool b)
 
bool isMouseConsume () const
 
void setRedraw (const bool b)
 
virtual bool isSelectable () const
 
void setSelectable (const bool selectable)
 
void windowResized ()
 
- Public Member Functions inherited from Widget2
virtual ~Widget2 ()
 
const ColorgetThemeColor (const ThemeColorIdT type, const unsigned int alpha) const A_INLINE
 
const ColorgetThemeCharColor (const signed char c, bool &valid) const A_INLINE
 
virtual void setWidget2 (const Widget2 *const widget)
 
void setPalette (int palette)
 
void checkPalette ()
 
void setForegroundColor2 (const Color &color)
 
WidgetgetWindow () const
 
virtual void setWindow (Widget *const window)
 
- Public Member Functions inherited from WidgetDeathListener
virtual ~WidgetDeathListener ()
 
- Public Member Functions inherited from MouseListener
virtual ~MouseListener ()
 
virtual void mouseWheelMovedUp (MouseEvent &event)
 
virtual void mouseWheelMovedDown (MouseEvent &event)
 
- Public Member Functions inherited from WidgetListener
virtual ~WidgetListener ()
 
virtual void widgetShown (const Event &event)
 
- Public Member Functions inherited from ActionListener
virtual ~ActionListener ()
 

Static Public Member Functions

static void createMail (const std::string &to)
 
- Static Public Member Functions inherited from Window
static void setWindowContainer (WindowContainer *const windowContainer)
 
- Static Public Member Functions inherited from Widget
static void setGlobalFont (Font *const font)
 
static FontgetGloablFont ()
 
static void cleanGlobalFont ()
 
static bool widgetExists (const Widget *const widget)
 
static void distributeWindowResizeEvent ()
 
static WidgetcallPostInit (Widget *const widget)
 

Private Member Functions

void refreshMails ()
 
std::string getMailHeader (const MailMessage *const message) const
 

Private Attributes

std::vector< MailMessage * > mMessages
 
std::map< int64_t, MailMessage * > mMessagesMap
 
ExtendedNamesModelmMailModel
 
ExtendedListBoxmListBox
 
ScrollAreamListScrollArea
 
ButtonmRefreshButton
 
ButtonmNewButton
 
ButtonmDeleteButton
 
ButtonmReturnButton
 
ButtonmOpenButton
 
MailOpenTypeT mOpenType
 
bool mUseMail2
 
bool mLastPage
 

Additional Inherited Members

- Data Fields inherited from Widget
Visible mVisible
 
- Protected Types inherited from BasicContainer
typedef std::vector< Widget * > WidgetList
 
typedef WidgetList::iterator WidgetListIterator
 
typedef WidgetList::const_iterator WidgetListConstIterator
 
typedef WidgetList::reverse_iterator WidgetListReverseIterator
 
typedef WidgetList::const_reverse_iterator WidgetListCReverseIterator
 
- Protected Types inherited from Widget
typedef std::list< MouseListener * > MouseListenerList
 
typedef MouseListenerList::iterator MouseListenerIterator
 
typedef std::list< KeyListener * > KeyListenerList
 
typedef KeyListenerList::iterator KeyListenerIterator
 
typedef std::list< ActionListener * > ActionListenerList
 
typedef ActionListenerList::iterator ActionListenerIterator
 
typedef std::list< WidgetDeathListener * > WidgetDeathListenerList
 
typedef WidgetDeathListenerList::iterator WidgetDeathListenerIterator
 
typedef std::list< FocusListener * > FocusListenerList
 
typedef FocusListenerList::iterator FocusListenerIterator
 
typedef std::list< WidgetListener * > WidgetListenerList
 
typedef WidgetListenerList::iterator WidgetListenerIterator
 
- Protected Member Functions inherited from Window
bool canMove () const
 
int getOption (const std::string &name, const int def) const
 
bool getOptionBool (const std::string &name, const bool def) const
 
void setTitlePadding (const int p)
 
int getTitlePadding () const
 
- Protected Member Functions inherited from BasicContainer
virtual void drawChildren (Graphics *const graphics)
 
virtual void safeDrawChildren (Graphics *const graphics)
 
virtual void logicChildren ()
 
- Protected Member Functions inherited from Widget
void distributeActionEvent ()
 
void distributeResizedEvent ()
 
void distributeMovedEvent ()
 
void distributeHiddenEvent ()
 
void distributeShownEvent ()
 
- Protected Member Functions inherited from Widget2
 Widget2 (const Widget2 *const widget)
 
- Protected Member Functions inherited from WidgetDeathListener
 WidgetDeathListener ()
 
- Protected Member Functions inherited from MouseListener
 MouseListener ()
 
- Protected Member Functions inherited from WidgetListener
 WidgetListener ()
 
- Protected Member Functions inherited from ActionListener
 ActionListener ()
 
- Protected Attributes inherited from Window
std::string mCaption
 
Graphics::Alignment mAlignment
 
int mPadding
 
unsigned int mTitleBarHeight
 
Move mMovable
 
int mDragOffsetX
 
int mDragOffsetY
 
bool mMoved
 
SkinmSkin
 
int mDefaultX
 
int mDefaultY
 
int mDefaultWidth
 
int mDefaultHeight
 
int mCaptionOffsetX
 
int mCaptionOffsetY
 
bool mShowTitle
 
bool mLastRedraw
 
- Protected Attributes inherited from BasicContainer2
Opaque mOpaque
 
- Protected Attributes inherited from BasicContainer
WidgetList mWidgets
 
WidgetList mLogicWidgets
 
- Protected Attributes inherited from Widget
MouseListenerList mMouseListeners
 
KeyListenerList mKeyListeners
 
ActionListenerList mActionListeners
 
WidgetDeathListenerList mDeathListeners
 
FocusListenerList mFocusListeners
 
WidgetListenerList mWidgetListeners
 
Color mForegroundColor
 
Color mBackgroundColor
 
Color mBaseColor
 
Rect mDimension
 
std::string mActionEventId
 
std::string mId
 
FocusHandlermFocusHandler
 
FocusHandlermInternalFocusHandler
 
WidgetmParent
 
FontmCurrentFont
 
unsigned int mFrameSize
 
bool mFocusable
 
bool mTabIn
 
bool mTabOut
 
bool mEnabled
 
bool mAllowLogic
 
bool mMouseConsume
 
bool mRedraw
 
bool mSelectable
 
- Protected Attributes inherited from Widget2
int mPaletteOffset
 
WidgetmWindow
 
Color mForegroundColor2
 
- Static Protected Attributes inherited from Widget
static FontmGlobalFont = 0
 

Detailed Description

A dialog to choose between buying or selling at a shop.

Definition at line 43 of file mailwindow.h.

Constructor & Destructor Documentation

◆ MailWindow()

MailWindow::MailWindow ( )

Definition at line 56 of file mailwindow.cpp.

56  :
57  // TRANSLATORS: mail window name
58  Window(_("Mail"), Modal_false, nullptr, "mail.xml"),
60  mMessages(),
61  mMessagesMap(),
64  this, mMailModel, "extendedlistbox.xml", 0)),
66  fromBool(getOptionBool("showlistbackground", false), Opaque),
67  "mail_listbackground.xml")),
68  // TRANSLATORS: mail window button
69  mRefreshButton(new Button(this, _("Refresh"), "refresh",
70  BUTTON_SKIN, this)),
71  // TRANSLATORS: mail window button
72  mNewButton(new Button(this, _("New"), "new", BUTTON_SKIN, this)),
73  // TRANSLATORS: mail window button
74  mDeleteButton(new Button(this, _("Delete"), "delete", BUTTON_SKIN, this)),
75  mReturnButton(new Button(this,
76  // TRANSLATORS: mail window button
77  settings.enableNewMailSystem ? _("Get old") : _("Return"),
78  "return", BUTTON_SKIN, this)),
79  // TRANSLATORS: mail window button
80  mOpenButton(new Button(this, _("Open"), "open", BUTTON_SKIN, this)),
83  mLastPage(false)
84 {
85  setWindowName("Mail");
86  setCloseButton(true);
87  setResizable(true);
88  setCloseButton(true);
89  setSaveVisible(true);
90  setStickyButtonLock(true);
91 
92  if (setupWindow != nullptr)
94 
95  setDefaultSize(310, 180, ImagePosition::CENTER, 0, 0);
96  setMinWidth(310);
97  setMinHeight(250);
98  center();
99 
101 
102  ContainerPlacer placer(nullptr, nullptr);
103  placer = getPlacer(0, 0);
104 
105  placer(0, 0, mListScrollArea, 4, 5).setPadding(3);
106  placer(4, 0, mRefreshButton, 1, 1);
107  placer(4, 1, mOpenButton, 1, 1);
108  placer(4, 2, mNewButton, 1, 1);
109  placer(4, 3, mDeleteButton, 1, 1);
110  placer(4, 4, mReturnButton, 1, 1);
111 
112  Layout &layout = getLayout();
113  layout.setRowHeight(0, LayoutType::SET);
114 
115  loadWindowState();
116  enableVisibleSound(true);
117 }
#define fromBool(val, name)
Definition: booldefines.h:49
const std::string BUTTON_SKIN
Definition: button.h:89
Definition: button.h:102
void setRowHeight(const int n, const int h)
Definition: layoutcell.cpp:128
Definition: layout.h:45
Button * mRefreshButton
Definition: mailwindow.h:97
std::vector< MailMessage * > mMessages
Definition: mailwindow.h:92
bool mLastPage
Definition: mailwindow.h:104
std::map< int64_t, MailMessage * > mMessagesMap
Definition: mailwindow.h:93
Button * mReturnButton
Definition: mailwindow.h:100
ExtendedNamesModel * mMailModel
Definition: mailwindow.h:94
bool mUseMail2
Definition: mailwindow.h:103
ScrollArea * mListScrollArea
Definition: mailwindow.h:96
ExtendedListBox * mListBox
Definition: mailwindow.h:95
Button * mOpenButton
Definition: mailwindow.h:101
MailOpenTypeT mOpenType
Definition: mailwindow.h:102
Button * mNewButton
Definition: mailwindow.h:98
Button * mDeleteButton
Definition: mailwindow.h:99
void setHorizontalScrollPolicy(const ScrollPolicy hPolicy)
bool enableNewMailSystem
Definition: settings.h:165
void registerWindowForReset(Window *const window)
void center()
Definition: window.cpp:1417
void setSaveVisible(const bool save)
Definition: window.h:300
void setResizable(const bool resize)
Definition: window.cpp:627
ContainerPlacer getPlacer(const int x, const int y)
Definition: window.cpp:1391
bool getOptionBool(const std::string &name, const bool def) const
Definition: window.cpp:1466
Layout & getLayout()
Definition: window.cpp:1365
void setWindowName(const std::string &name)
Definition: window.h:355
Window(const std::string &caption, const Modal modal, Window *const parent, std::string skin)
Definition: window.cpp:109
void setMinHeight(const int height)
Definition: window.cpp:604
void setMinWidth(const int width)
Definition: window.cpp:591
void enableVisibleSound(bool b)
Definition: window.h:481
void setCloseButton(const bool flag)
Definition: window.cpp:749
void setStickyButtonLock(const bool sticky)
Definition: window.cpp:772
void setDefaultSize()
Definition: window.cpp:1198
void loadWindowState()
Definition: window.cpp:1087
#define CREATEWIDGETR(type,...)
Definition: createwidget.h:36
#define _(s)
Definition: gettext.h:35
const bool Modal_false
Definition: modal.h:30
bool Opaque
Definition: opaque.h:30
Settings settings
Definition: settings.cpp:32
SetupWindow * setupWindow
Definition: setupwindow.cpp:64

References ImagePosition::CENTER, Window::center(), Window::enableVisibleSound(), Window::getLayout(), Window::getPlacer(), Window::loadWindowState(), mDeleteButton, mListScrollArea, mNewButton, mOpenButton, mRefreshButton, mReturnButton, SetupWindow::registerWindowForReset(), LayoutType::SET, Window::setCloseButton(), Window::setDefaultSize(), ScrollArea::setHorizontalScrollPolicy(), Window::setMinHeight(), Window::setMinWidth(), Window::setResizable(), LayoutCell::setRowHeight(), Window::setSaveVisible(), Window::setStickyButtonLock(), setupWindow, Window::setWindowName(), and ScrollArea::SHOW_NEVER.

◆ ~MailWindow()

MailWindow::~MailWindow ( )

Definition at line 119 of file mailwindow.cpp.

120 {
125 }
#define delete2(var)
Definition: delete2.h:25
void delete_all(Container &c)
Definition: dtor.h:56
MailEditWindow * mailEditWindow
MailViewWindow * mailViewWindow

References delete2, delete_all(), mailEditWindow, mailViewWindow, mMailModel, and mMessages.

Member Function Documentation

◆ action()

void MailWindow::action ( const ActionEvent actionEvent)
virtual

Called when an action is recieved from a widget. It is used to be able to recieve a notification that an action has occured.

Parameters
actionEventThe event of the action.

Implements ActionListener.

Definition at line 127 of file mailwindow.cpp.

128 {
129  const std::string &eventId = event.getId();
130  if (eventId == "refresh")
131  {
132  refreshMails();
133  }
134  else if (eventId == "new")
135  {
136  if (mailEditWindow == nullptr)
137  {
139  }
140  }
141  else if (eventId == "open")
142  {
143  const int sel = mListBox->getSelected();
144  if (sel < 0)
145  return;
146  const MailMessage *const mail = mMessages[sel];
147  if (mUseMail2)
149  else
151  }
152  else if (eventId == "delete")
153  {
154  const int sel = mListBox->getSelected();
155  if (sel < 0)
156  return;
157  const MailMessage *const mail = mMessages[sel];
158  if (mUseMail2)
160  else
162  }
163  else if (eventId == "return")
164  {
165  if (mUseMail2)
166  {
167  const size_t idx = mMessages.size();
168  if (idx == 0)
170  else
171  mail2Handler->nextPage(mOpenType, mMessages[idx - 1]->id);
172  }
173  else
174  {
175  const int sel = mListBox->getSelected();
176  if (sel < 0)
177  return;
178  const MailMessage *const mail = mMessages[sel];
180  }
181  }
182 }
#define CAST_S32
Definition: cast.h:30
int getSelected() const
Definition: listbox.h:168
void refreshMails()
Definition: mailwindow.cpp:352
virtual void refreshMailList(const MailOpenTypeT openType, const int64_t mailId) const =0
virtual void deleteMail(const MailOpenTypeT openType, const int64_t mailId) const =0
virtual void readMail(const MailOpenTypeT openType, const int64_t mailId) const =0
virtual void nextPage(const MailOpenTypeT openType, const int64_t mailId) const =0
virtual void readMessage(const int msgId) const =0
virtual void returnMessage(const int msgId) const =0
virtual void deleteMessage(const int msgId) const =0
#define CREATEWIDGETV0(var, type)
Definition: createwidget.h:32
Net::Mail2Handler * mail2Handler
Definition: net.cpp:113
Net::MailHandler * mailHandler
Definition: net.cpp:114
int64_t id
Definition: mailmessage.h:54

References CAST_S32, CREATEWIDGETV0, Net::Mail2Handler::deleteMail(), Net::MailHandler::deleteMessage(), ListBox::getSelected(), MailMessage::id, MailOpenType::Mail, mail2Handler, mailEditWindow, mailHandler, mListBox, mMessages, mOpenType, mUseMail2, Net::Mail2Handler::nextPage(), Net::Mail2Handler::readMail(), Net::MailHandler::readMessage(), Net::Mail2Handler::refreshMailList(), refreshMails(), and Net::MailHandler::returnMessage().

Referenced by mouseClicked().

◆ addMail()

void MailWindow::addMail ( MailMessage *const  message)

Definition at line 224 of file mailwindow.cpp.

225 {
226  if (message == nullptr)
227  return;
228  mMessages.push_back(message);
229  mMailModel->add(getMailHeader(message));
230  mMessagesMap[message->id] = message;
231 }
void add(const std::string &str)
std::string getMailHeader(const MailMessage *const message) const
Definition: mailwindow.cpp:193

References ExtendedNamesModel::add(), getMailHeader(), MailMessage::id, mMailModel, mMessages, and mMessagesMap.

Referenced by EAthena::MailRecv::processMailList(), and EAthena::Mail2Recv::processMailListPage().

◆ clear()

void MailWindow::clear ( )
virtual

Clears the basic container from all widgets.

See also
remove, clear

Reimplemented from BasicContainer.

Definition at line 184 of file mailwindow.cpp.

185 {
187  mMessages.clear();
188  mMessagesMap.clear();
189  mMailModel->clear();
190  mListBox->setSelected(-1);
191 }
void setSelected(const int selected)
Definition: listbox.cpp:399

References ExtendedNamesModel::clear(), delete_all(), mListBox, mMailModel, mMessages, mMessagesMap, and ListBox::setSelected().

Referenced by EAthena::MailRecv::processMailList(), and refreshMails().

◆ createMail()

void MailWindow::createMail ( const std::string &  to)
static

Definition at line 367 of file mailwindow.cpp.

368 {
369  if (mailEditWindow != nullptr)
370  return;
371 
373  mailEditWindow->setTo(to);
374 }
void setTo(const std::string &str)

References CREATEWIDGETV0, mailEditWindow, and MailEditWindow::setTo().

Referenced by EAthena::Mail2Recv::processCheckNameResult().

◆ findMail()

MailMessage * MailWindow::findMail ( const int64_t  id)

Definition at line 376 of file mailwindow.cpp.

377 {
378  std::map<int64_t, MailMessage*>::iterator it = mMessagesMap.find(id);
379  if (it != mMessagesMap.end())
380  return (*it).second;
381  return nullptr;
382 }

References mMessagesMap.

Referenced by EAthena::Mail2Recv::processReadMail().

◆ getMailHeader()

std::string MailWindow::getMailHeader ( const MailMessage *const  message) const
private

Definition at line 193 of file mailwindow.cpp.

194 {
195  if (mUseMail2)
196  {
197  std::string header;
198  if (message->expired)
199  {
200  // TRANSLATORS: expired mail message prefix
201  header = _("(expired)");
202  }
203  if (message->read)
204  header.append(" ");
205  else
206  header.append("U");
207  const MailMessageType::Type type = message->type;
208  if ((type & MailMessageType::Money) != 0)
209  header.append("M");
210  else
211  header.append(" ");
212  if ((type & MailMessageType::Item) != 0)
213  header.append("I");
214  else
215  header.append(" ");
216  header.append(" ").append(message->title);
217  return header;
218  }
219  return strprintf("%s %s",
220  message->read ? " " : "U",
221  message->title.c_str());
222 }
std::string strprintf(const char *const format,...)
MailMessageType::Type type
Definition: mailmessage.h:58
std::string title
Definition: mailmessage.h:50
bool expired
Definition: mailmessage.h:60

References _, MailMessage::expired, MailMessageType::Item, MailMessageType::Money, mUseMail2, MailMessage::read, strprintf(), MailMessage::title, and MailMessage::type.

Referenced by addMail(), refreshMailNames(), and removeMail().

◆ getOpenType()

MailOpenTypeT MailWindow::getOpenType ( ) const
inline

Definition at line 79 of file mailwindow.h.

80  { return mOpenType; }

References mOpenType.

Referenced by MailViewWindow::action(), and EAthena::Mail2Recv::processReadMail().

◆ mouseClicked()

void MailWindow::mouseClicked ( MouseEvent event)
virtual

Called when a mouse button is pressed and released (clicked) on the widget area.

Parameters
eventDescribes the event.

Reimplemented from MouseListener.

Definition at line 334 of file mailwindow.cpp.

335 {
336  if (event.getButton() == MouseButton::LEFT)
337  {
338  event.consume();
339  if (event.getClickCount() == 2 &&
340  event.getSource() == mListBox)
341  {
342  action(ActionEvent(mListBox, "open"));
343  }
344  }
345 }
Widget * getSource() const
Definition: event.h:104
void action(const ActionEvent &event)
Definition: mailwindow.cpp:127
MouseButtonT getButton() const
Definition: mouseevent.h:116
int getClickCount() const
Definition: mouseevent.h:147

References action(), MouseEvent::getButton(), MouseEvent::getClickCount(), Event::getSource(), MouseButton::LEFT, and mListBox.

◆ postConnection()

void MailWindow::postConnection ( )

Definition at line 347 of file mailwindow.cpp.

348 {
349  refreshMails();
350 }

References refreshMails().

Referenced by Game::Game().

◆ refreshMailNames()

void MailWindow::refreshMailNames ( )

Definition at line 390 of file mailwindow.cpp.

391 {
392  mMailModel->clear();
393  FOR_EACH (STD_VECTOR<MailMessage*>::iterator, it, mMessages)
394  {
395  MailMessage *message = *it;
396  if (message != nullptr)
397  mMailModel->add(getMailHeader(message));
398  }
399 }
#define FOR_EACH(type, iter, array)
Definition: foreach.h:25

References ExtendedNamesModel::add(), ExtendedNamesModel::clear(), FOR_EACH, getMailHeader(), mMailModel, and mMessages.

Referenced by MailViewWindow::removeItems(), and MailViewWindow::removeMoney().

◆ refreshMails()

void MailWindow::refreshMails ( )
private

Definition at line 352 of file mailwindow.cpp.

353 {
354  if (mUseMail2)
355  {
356  clear();
358  mLastPage = false;
359  mReturnButton->setEnabled(true);
360  }
361  else
362  {
363  mailHandler->refresh();
364  }
365 }
void clear()
Definition: mailwindow.cpp:184
virtual void refresh() const =0
void setEnabled(const bool enabled)
Definition: widget.h:352

References clear(), MailOpenType::Mail, mail2Handler, mailHandler, mLastPage, mReturnButton, mUseMail2, Net::MailHandler::refresh(), Net::Mail2Handler::refreshMailList(), and Widget::setEnabled().

Referenced by action(), and postConnection().

◆ removeMail()

void MailWindow::removeMail ( const int64_t  id)

Definition at line 233 of file mailwindow.cpp.

234 {
235  std::map<int64_t, MailMessage*>::iterator it1 = mMessagesMap.find(id);
236  if (it1 != mMessagesMap.end())
237  mMessagesMap.erase(it1);
238 
239  mMailModel->clear();
240 
241  FOR_EACH (STD_VECTOR<MailMessage*>::iterator, it, mMessages)
242  {
243  MailMessage *message = *it;
244  if ((message != nullptr) && message->id == id)
245  {
246  mMessages.erase(it);
247  delete message;
248  break;
249  }
250  }
251 
252  FOR_EACH (STD_VECTOR<MailMessage*>::iterator, it, mMessages)
253  {
254  MailMessage *message = *it;
255  if (message != nullptr)
256  mMailModel->add(getMailHeader(message));
257  }
258 }

References ExtendedNamesModel::add(), ExtendedNamesModel::clear(), FOR_EACH, getMailHeader(), MailMessage::id, mMailModel, mMessages, and mMessagesMap.

Referenced by EAthena::MailRecv::processDeleteAck(), EAthena::Mail2Recv::processMailDelete(), and EAthena::MailRecv::processMailReturn().

◆ setLastPage()

void MailWindow::setLastPage ( )

Definition at line 384 of file mailwindow.cpp.

385 {
386  mLastPage = true;
387  mReturnButton->setEnabled(false);
388 }

References mLastPage, mReturnButton, and Widget::setEnabled().

Referenced by EAthena::Mail2Recv::processMailListPage().

◆ setOpenType()

void MailWindow::setOpenType ( const MailOpenTypeT type)
inline

Definition at line 76 of file mailwindow.h.

77  { mOpenType = type; }

References mOpenType.

Referenced by EAthena::Mail2Recv::processMailListPage().

◆ showMessage()

void MailWindow::showMessage ( MailMessage *const  mail,
const int  itemsCount 
)

Definition at line 260 of file mailwindow.cpp.

262 {
263  if (mail == nullptr)
264  return;
265  const std::map<int64_t, MailMessage*>::const_iterator
266  it = mMessagesMap.find(mail->id);
267  if (it != mMessagesMap.end())
268  {
269  const MailMessage *const mail2 = (*it).second;
270  mail->time = mail2->time;
271  mail->strTime = mail2->strTime;
272  }
273  delete mailViewWindow;
275  itemsCount);
276 }
#define CREATEWIDGETV(var, type,...)
Definition: createwidget.h:25
std::string strTime
Definition: mailmessage.h:52

References CREATEWIDGETV, MailMessage::id, mailViewWindow, mMessagesMap, MailMessage::strTime, and MailMessage::time.

Referenced by EAthena::Mail2Recv::processReadMail(), and EAthena::MailRecv::processReadMail().

◆ viewNext()

void MailWindow::viewNext ( const int64_t  id)

Definition at line 278 of file mailwindow.cpp.

279 {
280  FOR_EACH (STD_VECTOR<MailMessage*>::iterator, it, mMessages)
281  {
282  MailMessage *message = *it;
283  if (message != nullptr &&
284  message->id == id)
285  {
286  ++ it;
287  if (it == mMessages.end())
288  {
289  it = mMessages.begin();
290  mListBox->setSelected(0);
291  }
292  else
293  {
295  }
296  message = *it;
297  if (mUseMail2)
298  mail2Handler->readMail(mOpenType, message->id);
299  else
300  mailHandler->readMessage(CAST_S32(message->id));
301  return;
302  }
303  }
304 }

References CAST_S32, FOR_EACH, ListBox::getSelected(), MailMessage::id, mail2Handler, mailHandler, mListBox, mMessages, mOpenType, mUseMail2, Net::Mail2Handler::readMail(), Net::MailHandler::readMessage(), and ListBox::setSelected().

Referenced by MailViewWindow::action().

◆ viewPrev()

void MailWindow::viewPrev ( const int64_t  id)

Definition at line 306 of file mailwindow.cpp.

307 {
308  FOR_EACH (STD_VECTOR<MailMessage*>::iterator, it, mMessages)
309  {
310  MailMessage *message = *it;
311  if (message != nullptr &&
312  message->id == id)
313  {
314  if (it == mMessages.begin())
315  {
316  it = mMessages.end();
317  mListBox->setSelected(CAST_S32(mMessages.size()) - 1);
318  }
319  else
320  {
322  }
323  -- it;
324  message = *it;
325  if (mUseMail2)
326  mail2Handler->readMail(mOpenType, message->id);
327  else
328  mailHandler->readMessage(CAST_S32(message->id));
329  return;
330  }
331  }
332 }

References CAST_S32, FOR_EACH, ListBox::getSelected(), MailMessage::id, mail2Handler, mailHandler, mListBox, mMessages, mOpenType, mUseMail2, Net::Mail2Handler::readMail(), Net::MailHandler::readMessage(), and ListBox::setSelected().

Referenced by MailViewWindow::action().

Field Documentation

◆ mDeleteButton

Button* MailWindow::mDeleteButton
private

Definition at line 99 of file mailwindow.h.

Referenced by MailWindow().

◆ mLastPage

bool MailWindow::mLastPage
private

Definition at line 104 of file mailwindow.h.

Referenced by refreshMails(), and setLastPage().

◆ mListBox

ExtendedListBox* MailWindow::mListBox
private

Definition at line 95 of file mailwindow.h.

Referenced by action(), clear(), mouseClicked(), viewNext(), and viewPrev().

◆ mListScrollArea

ScrollArea* MailWindow::mListScrollArea
private

Definition at line 96 of file mailwindow.h.

Referenced by MailWindow().

◆ mMailModel

ExtendedNamesModel* MailWindow::mMailModel
private

Definition at line 94 of file mailwindow.h.

Referenced by addMail(), clear(), refreshMailNames(), removeMail(), and ~MailWindow().

◆ mMessages

std::vector<MailMessage*> MailWindow::mMessages
private

◆ mMessagesMap

std::map<int64_t, MailMessage*> MailWindow::mMessagesMap
private

Definition at line 93 of file mailwindow.h.

Referenced by addMail(), clear(), findMail(), removeMail(), and showMessage().

◆ mNewButton

Button* MailWindow::mNewButton
private

Definition at line 98 of file mailwindow.h.

Referenced by MailWindow().

◆ mOpenButton

Button* MailWindow::mOpenButton
private

Definition at line 101 of file mailwindow.h.

Referenced by MailWindow().

◆ mOpenType

MailOpenTypeT MailWindow::mOpenType
private

Definition at line 102 of file mailwindow.h.

Referenced by action(), getOpenType(), setOpenType(), viewNext(), and viewPrev().

◆ mRefreshButton

Button* MailWindow::mRefreshButton
private

Definition at line 97 of file mailwindow.h.

Referenced by MailWindow().

◆ mReturnButton

Button* MailWindow::mReturnButton
private

Definition at line 100 of file mailwindow.h.

Referenced by MailWindow(), refreshMails(), and setLastPage().

◆ mUseMail2

bool MailWindow::mUseMail2
private

Definition at line 103 of file mailwindow.h.

Referenced by action(), getMailHeader(), refreshMails(), viewNext(), and viewPrev().


The documentation for this class was generated from the following files: