ManaPlus
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 ()
 
void createMail (const std::string &to)
 
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="Window", const Modal modal=Modal_false, Window *const parent=0, std::string skin="")
 
virtual ~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=0, int offsetY=0)
 
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=0, const int offsetY=0)
 
virtual void resetToDefaultSize ()
 
void adjustPositionAfterResize (const int oldScreenWidth, const int oldScreenHeight)
 
LayoutgetLayout ()
 
void clearLayout ()
 
void reflowLayout (int w=0, int h=0)
 
LayoutCellplace (const int x, const int y, Widget *const wg, const int w=1, const int h=1)
 
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)
 
virtual ~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)
 
virtual ~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)
 
virtual ~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=255U) 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 ()
 

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

- 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)
 
- 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=0) const
 
bool getOptionBool (const std::string &name, const bool def=false) 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 42 of file mailwindow.h.

Constructor & Destructor Documentation

◆ MailWindow()

MailWindow::MailWindow ( )

Definition at line 56 of file mailwindow.cpp.

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.

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"), Opaque),
67  "mail_listbackground.xml")),
68  // TRANSLATORS: mail window button
69  mRefreshButton(new Button(this, _("Refresh"), "refresh", this)),
70  // TRANSLATORS: mail window button
71  mNewButton(new Button(this, _("New"), "new", this)),
72  // TRANSLATORS: mail window button
73  mDeleteButton(new Button(this, _("Delete"), "delete", this)),
74  mReturnButton(new Button(this,
75  // TRANSLATORS: mail window button
76  settings.enableNewMailSystem ? _("Get old") : _("Return"),
77  "return", this)),
78  // TRANSLATORS: mail window button
79  mOpenButton(new Button(this, _("Open"), "open", this)),
82  mLastPage(false)
83 {
84  setWindowName("Mail");
85  setCloseButton(true);
86  setResizable(true);
87  setCloseButton(true);
88  setSaveVisible(true);
89  setStickyButtonLock(true);
90 
91  if (setupWindow != nullptr)
93 
95  setMinWidth(310);
96  setMinHeight(250);
97  center();
98 
100 
101  ContainerPlacer placer;
102  placer = getPlacer(0, 0);
103 
104  placer(0, 0, mListScrollArea, 4, 5).setPadding(3);
105  placer(4, 0, mRefreshButton);
106  placer(4, 1, mOpenButton);
107  placer(4, 2, mNewButton);
108  placer(4, 3, mDeleteButton);
109  placer(4, 4, mReturnButton);
110 
111  Layout &layout = getLayout();
112  layout.setRowHeight(0, LayoutType::SET);
113 
114  loadWindowState();
115  enableVisibleSound(true);
116 }
void setDefaultSize()
Definition: window.cpp:1186
#define _(s)
Definition: gettext.h:34
void loadWindowState()
Definition: window.cpp:1075
ExtendedListBox * mListBox
Definition: mailwindow.h:94
void setMinWidth(const int width)
Definition: window.cpp:579
Definition: button.h:94
Button * mRefreshButton
Definition: mailwindow.h:96
bool getOptionBool(const std::string &name, const bool def=false) const
Definition: window.cpp:1454
ExtendedNamesModel * mMailModel
Definition: mailwindow.h:93
void registerWindowForReset(Window *const window)
Button * mReturnButton
Definition: mailwindow.h:99
Settings settings
Definition: settings.cpp:31
Button * mOpenButton
Definition: mailwindow.h:100
#define fromBool(val, name)
Definition: booldefines.h:48
Button * mDeleteButton
Definition: mailwindow.h:98
Button * mNewButton
Definition: mailwindow.h:97
bool mLastPage
Definition: mailwindow.h:103
void setCloseButton(const bool flag)
Definition: window.cpp:737
void enableVisibleSound(bool b)
Definition: window.h:473
void setMinHeight(const int height)
Definition: window.cpp:592
ContainerPlacer getPlacer(const int x, const int y)
Definition: window.cpp:1379
Layout & getLayout()
Definition: window.cpp:1353
void setSaveVisible(const bool save)
Definition: window.h:298
void center()
Definition: window.cpp:1405
MailOpenTypeT mOpenType
Definition: mailwindow.h:101
ScrollArea * mListScrollArea
Definition: mailwindow.h:95
void setResizable(const bool resize)
Definition: window.cpp:615
void setStickyButtonLock(const bool sticky)
Definition: window.cpp:760
SetupWindow * setupWindow
Definition: setupwindow.cpp:63
#define CREATEWIDGETR(type,...)
Definition: createwidget.h:35
Window(const std::string &caption="Window", const Modal modal=Modal_false, Window *const parent=0, std::string skin="")
Definition: window.cpp:108
Definition: layout.h:43
bool mUseMail2
Definition: mailwindow.h:102
void setRowHeight(const int n, const int h)
Definition: layoutcell.cpp:127
bool enableNewMailSystem
Definition: settings.h:163
std::vector< MailMessage * > mMessages
Definition: mailwindow.h:91
std::map< int64_t, MailMessage * > mMessagesMap
Definition: mailwindow.h:92
void setWindowName(const std::string &name)
Definition: window.h:353
void setHorizontalScrollPolicy(const ScrollPolicy hPolicy)

◆ ~MailWindow()

MailWindow::~MailWindow ( )

Definition at line 118 of file mailwindow.cpp.

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

119 {
124 }
MailViewWindow * mailViewWindow
ExtendedNamesModel * mMailModel
Definition: mailwindow.h:93
#define delete2(var)
Definition: delete2.h:24
void delete_all(Container &c)
Definition: dtor.h:55
MailEditWindow * mailEditWindow
std::vector< MailMessage * > mMessages
Definition: mailwindow.h:91

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 126 of file mailwindow.cpp.

References CAST_S32, CREATEWIDGETV0, Net::Mail2Handler::deleteMail(), Net::MailHandler::deleteMessage(), ListBox::getSelected(), MailMessage::id, MailOpenType::Mail, ServerCommandType::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().

127 {
128  const std::string &eventId = event.getId();
129  if (eventId == "refresh")
130  {
131  refreshMails();
132  }
133  else if (eventId == "new")
134  {
135  if (mailEditWindow == nullptr)
136  {
138  }
139  }
140  else if (eventId == "open")
141  {
142  const int sel = mListBox->getSelected();
143  if (sel < 0)
144  return;
145  const MailMessage *const mail = mMessages[sel];
146  if (mUseMail2)
148  else
150  }
151  else if (eventId == "delete")
152  {
153  const int sel = mListBox->getSelected();
154  if (sel < 0)
155  return;
156  const MailMessage *const mail = mMessages[sel];
157  if (mUseMail2)
159  else
161  }
162  else if (eventId == "return")
163  {
164  if (mUseMail2)
165  {
166  const size_t idx = mMessages.size();
167  if (idx == 0)
169  else
170  mail2Handler->nextPage(mOpenType, mMessages[idx - 1]->id);
171  }
172  else
173  {
174  const int sel = mListBox->getSelected();
175  if (sel < 0)
176  return;
177  const MailMessage *const mail = mMessages[sel];
179  }
180  }
181 }
#define CREATEWIDGETV0(var, type)
Definition: createwidget.h:31
void refreshMails()
Definition: mailwindow.cpp:346
ExtendedListBox * mListBox
Definition: mailwindow.h:94
Net::Mail2Handler * mail2Handler
Definition: net.cpp:104
virtual void readMail(const MailOpenTypeT openType, const int64_t mailId) const =0
virtual void deleteMail(const MailOpenTypeT openType, const int64_t mailId) const =0
#define CAST_S32
Definition: cast.h:29
virtual void nextPage(const MailOpenTypeT openType, const int64_t mailId) const =0
int getSelected() const
Definition: listbox.h:167
Net::MailHandler * mailHandler
Definition: net.cpp:105
virtual void readMessage(const int msgId) const =0
virtual void returnMessage(const int msgId) const =0
MailOpenTypeT mOpenType
Definition: mailwindow.h:101
virtual void deleteMessage(const int msgId) const =0
MailEditWindow * mailEditWindow
bool mUseMail2
Definition: mailwindow.h:102
int64_t id
Definition: mailmessage.h:52
std::vector< MailMessage * > mMessages
Definition: mailwindow.h:91
virtual void refreshMailList(const MailOpenTypeT openType, const int64_t mailId) const =0

◆ addMail()

void MailWindow::addMail ( MailMessage *const  message)

Definition at line 218 of file mailwindow.cpp.

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

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

219 {
220  if (message == nullptr)
221  return;
222  mMessages.push_back(message);
223  mMailModel->add(getMailHeader(message));
224  mMessagesMap[message->id] = message;
225 }
ExtendedNamesModel * mMailModel
Definition: mailwindow.h:93
void add(const std::string &str)
int64_t id
Definition: mailmessage.h:52
std::string getMailHeader(const MailMessage *const message) const
Definition: mailwindow.cpp:192
std::vector< MailMessage * > mMessages
Definition: mailwindow.h:91
std::map< int64_t, MailMessage * > mMessagesMap
Definition: mailwindow.h:92

◆ clear()

void MailWindow::clear ( )
virtual

Clears the basic container from all widgets.

See also
remove, clear

Reimplemented from BasicContainer.

Definition at line 183 of file mailwindow.cpp.

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

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

184 {
186  mMessages.clear();
187  mMessagesMap.clear();
188  mMailModel->clear();
189  mListBox->setSelected(-1);
190 }
void setSelected(const int selected)
Definition: listbox.cpp:392
ExtendedListBox * mListBox
Definition: mailwindow.h:94
ExtendedNamesModel * mMailModel
Definition: mailwindow.h:93
void delete_all(Container &c)
Definition: dtor.h:55
std::vector< MailMessage * > mMessages
Definition: mailwindow.h:91
std::map< int64_t, MailMessage * > mMessagesMap
Definition: mailwindow.h:92

◆ createMail()

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

Definition at line 361 of file mailwindow.cpp.

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

Referenced by Actions::changeRelation(), and EAthena::Mail2Recv::processCheckNameResult().

362 {
363  if (mailEditWindow != nullptr)
364  return;
365 
367  mailEditWindow->setTo(to);
368 }
#define CREATEWIDGETV0(var, type)
Definition: createwidget.h:31
void setTo(const std::string &str)
MailEditWindow * mailEditWindow

◆ findMail()

MailMessage * MailWindow::findMail ( const int64_t  id)

Definition at line 370 of file mailwindow.cpp.

References mMessagesMap.

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

371 {
372  std::map<int64_t, MailMessage*>::iterator it = mMessagesMap.find(id);
373  if (it != mMessagesMap.end())
374  return (*it).second;
375  return nullptr;
376 }
std::map< int64_t, MailMessage * > mMessagesMap
Definition: mailwindow.h:92

◆ getMailHeader()

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

Definition at line 192 of file mailwindow.cpp.

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

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

193 {
194  if (mUseMail2)
195  {
196  std::string header;
197  if (message->read)
198  header.append(" ");
199  else
200  header.append("U");
201  const MailMessageType::Type type = message->type;
202  if ((type & MailMessageType::Money) != 0)
203  header.append("M");
204  else
205  header.append(" ");
206  if ((type & MailMessageType::Item) != 0)
207  header.append("I");
208  else
209  header.append(" ");
210  header.append(" ").append(message->title);
211  return STD_MOVE(header);
212  }
213  return strprintf("%s %s",
214  message->read ? " " : "U",
215  message->title.c_str());
216 }
std::string title
Definition: mailmessage.h:48
std::string strprintf(const char *const format,...)
Definition: stringutils.cpp:99
MailMessageType::Type type
Definition: mailmessage.h:56
#define STD_MOVE(var)
Definition: stdmove.h:27
bool mUseMail2
Definition: mailwindow.h:102

◆ getOpenType()

MailOpenTypeT MailWindow::getOpenType ( ) const
inline

Definition at line 78 of file mailwindow.h.

References A_NONNULL, getMailHeader(), mOpenType, refreshMailNames(), refreshMails(), and setLastPage().

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

79  { return mOpenType; }
MailOpenTypeT mOpenType
Definition: mailwindow.h:101

◆ 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 328 of file mailwindow.cpp.

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

329 {
330  if (event.getButton() == MouseButton::LEFT)
331  {
332  event.consume();
333  if (event.getClickCount() == 2 &&
334  event.getSource() == mListBox)
335  {
336  action(ActionEvent(mListBox, "open"));
337  }
338  }
339 }
void action(const ActionEvent &event)
Definition: mailwindow.cpp:126
MouseButtonT getButton() const
Definition: mouseevent.h:113
ExtendedListBox * mListBox
Definition: mailwindow.h:94
int getClickCount() const
Definition: mouseevent.h:144

◆ postConnection()

void MailWindow::postConnection ( )

Definition at line 341 of file mailwindow.cpp.

References refreshMails().

Referenced by Game::Game().

342 {
343  refreshMails();
344 }
void refreshMails()
Definition: mailwindow.cpp:346

◆ refreshMailNames()

void MailWindow::refreshMailNames ( )

Definition at line 384 of file mailwindow.cpp.

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

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

385 {
386  mMailModel->clear();
387  FOR_EACH (STD_VECTOR<MailMessage*>::iterator, it, mMessages)
388  {
389  MailMessage *message = *it;
390  if (message != nullptr)
391  mMailModel->add(getMailHeader(message));
392  }
393 }
#define FOR_EACH(type, iter, array)
Definition: foreach.h:24
ExtendedNamesModel * mMailModel
Definition: mailwindow.h:93
void add(const std::string &str)
std::string getMailHeader(const MailMessage *const message) const
Definition: mailwindow.cpp:192
std::vector< MailMessage * > mMessages
Definition: mailwindow.h:91

◆ refreshMails()

void MailWindow::refreshMails ( )
private

Definition at line 346 of file mailwindow.cpp.

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

Referenced by action(), getOpenType(), and postConnection().

347 {
348  if (mUseMail2)
349  {
350  clear();
352  mLastPage = false;
353  mReturnButton->setEnabled(true);
354  }
355  else
356  {
357  mailHandler->refresh();
358  }
359 }
virtual void refresh() const =0
Net::Mail2Handler * mail2Handler
Definition: net.cpp:104
void clear()
Definition: mailwindow.cpp:183
Button * mReturnButton
Definition: mailwindow.h:99
bool mLastPage
Definition: mailwindow.h:103
Net::MailHandler * mailHandler
Definition: net.cpp:105
void setEnabled(const bool enabled)
Definition: widget.h:351
bool mUseMail2
Definition: mailwindow.h:102
virtual void refreshMailList(const MailOpenTypeT openType, const int64_t mailId) const =0

◆ removeMail()

void MailWindow::removeMail ( const int64_t  id)

Definition at line 227 of file mailwindow.cpp.

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().

228 {
229  std::map<int64_t, MailMessage*>::iterator it1 = mMessagesMap.find(id);
230  if (it1 != mMessagesMap.end())
231  mMessagesMap.erase(it1);
232 
233  mMailModel->clear();
234 
235  FOR_EACH (STD_VECTOR<MailMessage*>::iterator, it, mMessages)
236  {
237  MailMessage *message = *it;
238  if ((message != nullptr) && message->id == id)
239  {
240  mMessages.erase(it);
241  delete message;
242  break;
243  }
244  }
245 
246  FOR_EACH (STD_VECTOR<MailMessage*>::iterator, it, mMessages)
247  {
248  MailMessage *message = *it;
249  if (message != nullptr)
250  mMailModel->add(getMailHeader(message));
251  }
252 }
#define FOR_EACH(type, iter, array)
Definition: foreach.h:24
ExtendedNamesModel * mMailModel
Definition: mailwindow.h:93
void add(const std::string &str)
int64_t id
Definition: mailmessage.h:52
std::string getMailHeader(const MailMessage *const message) const
Definition: mailwindow.cpp:192
std::vector< MailMessage * > mMessages
Definition: mailwindow.h:91
std::map< int64_t, MailMessage * > mMessagesMap
Definition: mailwindow.h:92

◆ setLastPage()

void MailWindow::setLastPage ( )

Definition at line 378 of file mailwindow.cpp.

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

Referenced by getOpenType(), and EAthena::Mail2Recv::processMailListPage().

379 {
380  mLastPage = true;
381  mReturnButton->setEnabled(false);
382 }
Button * mReturnButton
Definition: mailwindow.h:99
bool mLastPage
Definition: mailwindow.h:103
void setEnabled(const bool enabled)
Definition: widget.h:351

◆ setOpenType()

void MailWindow::setOpenType ( const MailOpenTypeT type)
inline

Definition at line 75 of file mailwindow.h.

References mOpenType.

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

76  { mOpenType = type; }
MailOpenTypeT mOpenType
Definition: mailwindow.h:101

◆ showMessage()

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

Definition at line 254 of file mailwindow.cpp.

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

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

256 {
257  if (mail == nullptr)
258  return;
259  const std::map<int64_t, MailMessage*>::const_iterator
260  it = mMessagesMap.find(mail->id);
261  if (it != mMessagesMap.end())
262  {
263  const MailMessage *const mail2 = (*it).second;
264  mail->time = mail2->time;
265  mail->strTime = mail2->strTime;
266  }
267  delete mailViewWindow;
269  itemsCount);
270 }
MailViewWindow * mailViewWindow
#define CREATEWIDGETV(var, type,...)
Definition: createwidget.h:24
std::string strTime
Definition: mailmessage.h:50
int64_t id
Definition: mailmessage.h:52
std::map< int64_t, MailMessage * > mMessagesMap
Definition: mailwindow.h:92

◆ viewNext()

void MailWindow::viewNext ( const int64_t  id)

Definition at line 272 of file mailwindow.cpp.

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().

273 {
274  FOR_EACH (STD_VECTOR<MailMessage*>::iterator, it, mMessages)
275  {
276  MailMessage *message = *it;
277  if (message != nullptr &&
278  message->id == id)
279  {
280  ++ it;
281  if (it == mMessages.end())
282  {
283  it = mMessages.begin();
284  mListBox->setSelected(0);
285  }
286  else
287  {
289  }
290  message = *it;
291  if (mUseMail2)
292  mail2Handler->readMail(mOpenType, message->id);
293  else
294  mailHandler->readMessage(CAST_S32(message->id));
295  return;
296  }
297  }
298 }
#define FOR_EACH(type, iter, array)
Definition: foreach.h:24
void setSelected(const int selected)
Definition: listbox.cpp:392
ExtendedListBox * mListBox
Definition: mailwindow.h:94
Net::Mail2Handler * mail2Handler
Definition: net.cpp:104
virtual void readMail(const MailOpenTypeT openType, const int64_t mailId) const =0
#define CAST_S32
Definition: cast.h:29
int getSelected() const
Definition: listbox.h:167
Net::MailHandler * mailHandler
Definition: net.cpp:105
virtual void readMessage(const int msgId) const =0
MailOpenTypeT mOpenType
Definition: mailwindow.h:101
bool mUseMail2
Definition: mailwindow.h:102
int64_t id
Definition: mailmessage.h:52
std::vector< MailMessage * > mMessages
Definition: mailwindow.h:91

◆ viewPrev()

void MailWindow::viewPrev ( const int64_t  id)

Definition at line 300 of file mailwindow.cpp.

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().

301 {
302  FOR_EACH (STD_VECTOR<MailMessage*>::iterator, it, mMessages)
303  {
304  MailMessage *message = *it;
305  if (message != nullptr &&
306  message->id == id)
307  {
308  if (it == mMessages.begin())
309  {
310  it = mMessages.end();
311  mListBox->setSelected(CAST_S32(mMessages.size()) - 1);
312  }
313  else
314  {
316  }
317  -- it;
318  message = *it;
319  if (mUseMail2)
320  mail2Handler->readMail(mOpenType, message->id);
321  else
322  mailHandler->readMessage(CAST_S32(message->id));
323  return;
324  }
325  }
326 }
#define FOR_EACH(type, iter, array)
Definition: foreach.h:24
void setSelected(const int selected)
Definition: listbox.cpp:392
ExtendedListBox * mListBox
Definition: mailwindow.h:94
Net::Mail2Handler * mail2Handler
Definition: net.cpp:104
virtual void readMail(const MailOpenTypeT openType, const int64_t mailId) const =0
#define CAST_S32
Definition: cast.h:29
int getSelected() const
Definition: listbox.h:167
Net::MailHandler * mailHandler
Definition: net.cpp:105
virtual void readMessage(const int msgId) const =0
MailOpenTypeT mOpenType
Definition: mailwindow.h:101
bool mUseMail2
Definition: mailwindow.h:102
int64_t id
Definition: mailmessage.h:52
std::vector< MailMessage * > mMessages
Definition: mailwindow.h:91

Field Documentation

◆ mDeleteButton

Button* MailWindow::mDeleteButton
private

Definition at line 98 of file mailwindow.h.

Referenced by MailWindow().

◆ mLastPage

bool MailWindow::mLastPage
private

Definition at line 103 of file mailwindow.h.

Referenced by refreshMails(), and setLastPage().

◆ mListBox

ExtendedListBox* MailWindow::mListBox
private

Definition at line 94 of file mailwindow.h.

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

◆ mListScrollArea

ScrollArea* MailWindow::mListScrollArea
private

Definition at line 95 of file mailwindow.h.

Referenced by MailWindow().

◆ mMailModel

ExtendedNamesModel* MailWindow::mMailModel
private

Definition at line 93 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 92 of file mailwindow.h.

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

◆ mNewButton

Button* MailWindow::mNewButton
private

Definition at line 97 of file mailwindow.h.

Referenced by MailWindow().

◆ mOpenButton

Button* MailWindow::mOpenButton
private

Definition at line 100 of file mailwindow.h.

Referenced by MailWindow().

◆ mOpenType

MailOpenTypeT MailWindow::mOpenType
private

Definition at line 101 of file mailwindow.h.

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

◆ mRefreshButton

Button* MailWindow::mRefreshButton
private

Definition at line 96 of file mailwindow.h.

Referenced by MailWindow().

◆ mReturnButton

Button* MailWindow::mReturnButton
private

Definition at line 99 of file mailwindow.h.

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

◆ mUseMail2

bool MailWindow::mUseMail2
private

Definition at line 102 of file mailwindow.h.

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


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