ManaPlus
window.cpp
Go to the documentation of this file.
1 /*
2  * The ManaPlus Client
3  * Copyright (C) 2004-2009 The Mana World Development Team
4  * Copyright (C) 2009-2010 The Mana Developers
5  * Copyright (C) 2011-2018 The ManaPlus Developers
6  *
7  * This file is part of The ManaPlus Client.
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program. If not, see <http://www.gnu.org/licenses/>.
21  */
22 
23 /* _______ __ __ __ ______ __ __ _______ __ __
24  * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
25  * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
26  * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
27  * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
28  * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
29  * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
30  *
31  * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
32  *
33  *
34  * Per Larsson a.k.a finalman
35  * Olof Naessén a.k.a jansem/yakslem
36  *
37  * Visit: http://guichan.sourceforge.net
38  *
39  * License: (BSD)
40  * Redistribution and use in source and binary forms, with or without
41  * modification, are permitted provided that the following conditions
42  * are met:
43  * 1. Redistributions of source code must retain the above copyright
44  * notice, this list of conditions and the following disclaimer.
45  * 2. Redistributions in binary form must reproduce the above copyright
46  * notice, this list of conditions and the following disclaimer in
47  * the documentation and/or other materials provided with the
48  * distribution.
49  * 3. Neither the name of Guichan nor the names of its contributors may
50  * be used to endorse or promote products derived from this software
51  * without specific prior written permission.
52  *
53  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
54  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
55  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
56  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
57  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
58  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
59  * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
60  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
61  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
62  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
63  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
64  */
65 
66 #include "gui/widgets/window.h"
67 
68 #include "client.h"
69 #include "configuration.h"
70 #ifndef DYECMD
71 #include "dragdrop.h"
72 #else // DYECMD
73 #include "resources/image/image.h"
74 #endif // DYECMD
75 #include "soundmanager.h"
76 
77 #include "const/sound.h"
78 
79 #include "gui/focushandler.h"
80 #include "gui/gui.h"
81 #include "gui/popupmanager.h"
82 #include "gui/skin.h"
83 #include "gui/viewport.h"
84 
85 #include "gui/fonts/font.h"
86 
87 #include "gui/popups/popupmenu.h"
88 
90 
92 #include "gui/widgets/layout.h"
93 
94 #include "render/renderers.h"
95 
97 
98 #include "utils/checkutils.h"
99 #include "utils/delete2.h"
100 
101 #include "debug.h"
102 
103 const int resizeMask = 8 + 4 + 2 + 1;
104 
106 int Window::mouseResize = 0;
107 
108 Window::Window(const std::string &caption,
109  const Modal modal,
110  Window *const parent,
111  std::string skin) :
113  MouseListener(),
114  WidgetListener(),
115  mCaption(caption),
116  mAlignment(Graphics::CENTER),
117  mPadding(2),
118  mTitleBarHeight(16),
119  mMovable(Move_true),
120  mDragOffsetX(0),
121  mDragOffsetY(0),
122  mMoved(false),
123  mSkin(nullptr),
124  mDefaultX(0),
125  mDefaultY(0),
126  mDefaultWidth(0),
127  mDefaultHeight(0),
128  mCaptionOffsetX(7),
129  mCaptionOffsetY(5),
130  mShowTitle(true),
131  mLastRedraw(true),
132  mGrip(nullptr),
133  mParentWindow(parent),
134  mLayout(nullptr),
135  mCloseRect(),
136  mStickyRect(),
137  mGripRect(),
138  mTextChunk(),
139  mWindowName("window"),
140  mMinWinWidth(100),
141  mMinWinHeight(40),
142  mMaxWinWidth(mainGraphics->mWidth),
143  mMaxWinHeight(mainGraphics->mHeight),
144  mVertexes(new ImageCollection),
145  mCaptionAlign(Graphics::LEFT),
146  mTitlePadding(4),
147  mGripPadding(2),
148  mResizeHandles(-1),
149  mOldResizeHandles(-1),
150  mClosePadding(0),
151  mStickySpacing(0),
152  mStickyPadding(0),
153  mCaptionFont(getFont()),
154  mModal(modal),
155  mCloseWindowButton(false),
156  mDefaultVisible(false),
157  mSaveVisible(false),
158  mStickyButton(false),
159  mSticky(false),
160  mStickyButtonLock(false),
161  mPlayVisibleSound(false),
162  mInit(false),
163  mTextChanged(true),
164  mAllowClose(false)
165 {
166  logger->log("Window::Window(\"%s\")", caption.c_str());
167 
168  mWindow = this;
169 
170  windowInstances++;
171 
172 // mFrameSize = 1;
173  addMouseListener(this);
174 
175  setFrameSize(0);
176  setPadding(3);
177  setTitleBarHeight(20);
178 
179  if (skin.empty())
180  {
181  reportAlways("Default skin was used for window: %s",
182  caption.c_str());
183  skin = "window.xml";
184  }
185 
186  int childPalette = 1;
187  // Loads the skin
188  if (theme != nullptr)
189  {
190  mSkin = theme->load(skin,
191  "window.xml",
192  true,
194  if (mSkin != nullptr)
195  {
197  if (getOptionBool("titlebarBold", false))
200  mGripPadding = getOption("resizePadding", 0);
201  mCaptionOffsetX = getOption("captionoffsetx", 0);
202  if (mCaptionOffsetX == 0)
203  mCaptionOffsetX = 7;
204  mCaptionOffsetY = getOption("captionoffsety", 0);
205  if (mCaptionOffsetY == 0)
206  mCaptionOffsetY = 5;
207  mCaptionAlign = static_cast<Graphics::Alignment>(
208  getOption("captionalign", 0));
211  {
213  }
215  getOption("titlebarHeight", 0)));
216  if (mTitleBarHeight == 0U)
218 
219  mTitleBarHeight += getOption("titlebarHeightRelative", 0);
220  setPalette(getOption("palette", 0));
221  childPalette = getOption("childPalette", 0);
222  mShowTitle = getOptionBool("showTitle", true);
223  mClosePadding = getOption("closePadding", 0);
224  mStickySpacing = getOption("stickySpacing", 0);
225  mStickyPadding = getOption("stickyPadding", 0);
226  }
227  }
228 
229  // Add this window to the window container
230  if (windowContainer != nullptr)
231  windowContainer->add(this);
232 
233  if (mModal == Modal_true)
234  {
237  }
238 
239  // Windows are invisible by default
240  setVisible(Visible_false, false);
241 
242  addWidgetListener(this);
245  setPalette(childPalette);
246 }
247 
249 {
250  if (mInit)
251  {
252  reportAlways("error: Window created with calling postInit() "
253  "more than once: %s",
254  mWindowName.c_str());
255  }
256  mInit = true;
257 }
258 
260 {
261  logger->log("Window::~Window(\"%s\")", getCaption().c_str());
262 
263  if (gui != nullptr)
264  gui->removeDragged(this);
265 
266 #ifndef DYECMD
267  if (setupWindow != nullptr)
269 #endif // DYECMD
270 
271  client->windowRemoved(this);
272 
273  saveWindowState();
274 
275  delete2(mLayout);
276 
277  while (!mWidgets.empty())
278  delete mWidgets.front();
279 
280  mWidgets.clear();
281 
282  removeWidgetListener(this);
284 
285  windowInstances--;
286 
287  if (mSkin != nullptr)
288  {
289  if (theme != nullptr)
290  theme->unload(mSkin);
291  mSkin = nullptr;
292  }
293  if (mGrip != nullptr)
294  {
295  mGrip->decRef();
296  mGrip = nullptr;
297  }
298  if (!mInit)
299  {
300  reportAlways("error: Window created without calling postInit(): %s",
301  mWindowName.c_str());
302  }
303 }
304 
306 {
307  windowContainer = wc;
308 }
309 
310 void Window::draw(Graphics *const graphics)
311 {
312  if (mSkin == nullptr)
313  return;
314 
315  BLOCK_START("Window::draw")
316  bool update = false;
317 
319  {
320  mRedraw = true;
322  }
323  if (mRedraw)
324  {
325  mLastRedraw = true;
326  mRedraw = false;
327  update = true;
328  mVertexes->clear();
329  graphics->calcWindow(mVertexes,
330  0, 0,
333  mSkin->getBorder());
334 
335  // Draw Close Button
336  if (mCloseWindowButton)
337  {
338  const Image *const button = mSkin->getCloseImage(
339  mResizeHandles == CLOSE);
340  if (button != nullptr)
341  {
342  graphics->calcTileCollection(mVertexes,
343  button,
344  mCloseRect.x,
345  mCloseRect.y);
346  }
347  }
348  // Draw Sticky Button
349  if (mStickyButton)
350  {
351  const Image *const button = mSkin->getStickyImage(mSticky);
352  if (button != nullptr)
353  {
354  graphics->calcTileCollection(mVertexes,
355  button,
356  mStickyRect.x,
357  mStickyRect.y);
358  }
359  }
360 
361  if (mGrip != nullptr)
362  {
363  graphics->calcTileCollection(mVertexes,
364  mGrip,
365  mGripRect.x,
366  mGripRect.y);
367  }
368  graphics->finalize(mVertexes);
369  }
370  else
371  {
372  mLastRedraw = false;
373  }
374  graphics->drawTileCollection(mVertexes);
375 
376  // Draw title
377  if (mShowTitle)
378  {
379  int x;
380  switch (mCaptionAlign)
381  {
382  case Graphics::LEFT:
383  default:
384  x = mCaptionOffsetX;
385  break;
386  case Graphics::CENTER:
388  break;
389  case Graphics::RIGHT:
391  break;
392  }
393  if (mTextChanged)
394  {
401  mTextChanged = false;
402  }
403 
404  const Image *const image = mTextChunk.img;
405  if (image != nullptr)
406  graphics->drawImage(image, x, mCaptionOffsetY);
407  }
408 
409  if (update)
410  {
411  graphics->setRedraw(update);
412  drawChildren(graphics);
413  graphics->setRedraw(false);
414  }
415  else
416  {
417  drawChildren(graphics);
418  }
419  BLOCK_END("Window::draw")
420 }
421 
422 void Window::safeDraw(Graphics *const graphics)
423 {
424  if (mSkin == nullptr)
425  return;
426 
427  BLOCK_START("Window::safeDraw")
428 
429  graphics->drawImageRect(0, 0,
432  mSkin->getBorder());
433 
434  // Draw Close Button
435  if (mCloseWindowButton)
436  {
437  const Image *const button = mSkin->getCloseImage(
438  mResizeHandles == CLOSE);
439  if (button != nullptr)
440  graphics->drawImage(button, mCloseRect.x, mCloseRect.y);
441  }
442  // Draw Sticky Button
443  if (mStickyButton)
444  {
445  const Image *const button = mSkin->getStickyImage(mSticky);
446  if (button != nullptr)
447  graphics->drawImage(button, mStickyRect.x, mStickyRect.y);
448  }
449 
450  if (mGrip != nullptr)
451  graphics->drawImage(mGrip, mGripRect.x, mGripRect.y);
452 
453  // Draw title
454  if (mShowTitle)
455  {
456  int x;
457  switch (mCaptionAlign)
458  {
459  case Graphics::LEFT:
460  default:
461  x = mCaptionOffsetX;
462  break;
463  case Graphics::CENTER:
465  break;
466  case Graphics::RIGHT:
468  break;
469  }
470  if (mTextChanged)
471  {
478  mTextChanged = false;
479  }
480 
481  const Image *const image = mTextChunk.img;
482  if (image != nullptr)
483  graphics->drawImage(image, x, mCaptionOffsetY);
484  }
485 
486  safeDrawChildren(graphics);
487 
488  BLOCK_END("Window::safeDraw")
489 }
490 
491 void Window::setContentSize(int width, int height)
492 {
493  width = width + 2 * mPadding;
494  height = height + mPadding + mTitleBarHeight;
495 
496  if (mMinWinWidth > width)
497  width = mMinWinWidth;
498  else if (mMaxWinWidth < width)
499  width = mMaxWinWidth;
500  if (mMinWinHeight > height)
501  height = mMinWinHeight;
502  else if (mMaxWinHeight < height)
503  height = mMaxWinHeight;
504 
505  setSize(width, height);
506 }
507 
508 void Window::setLocationRelativeTo(const Widget *const widget)
509 {
510  if (widget == nullptr)
511  return;
512 
513  int wx;
514  int wy;
515  int x;
516  int y;
517 
518  widget->getAbsolutePosition(wx, wy);
519  getAbsolutePosition(x, y);
520 
521  setPosition(mDimension.x + (wx + (widget->getWidth()
522  - mDimension.width) / 2 - x),
523  mDimension.y + (wy + (widget->getHeight()
524  - mDimension.height) / 2 - y));
525 }
526 
528 {
529  if (widget == nullptr)
530  return;
531 
532  int wx;
533  int wy;
534  int x;
535  int y;
536 
537  widget->getAbsolutePosition(wx, wy);
538  getAbsolutePosition(x, y);
539 
540  setPosition(mDimension.x + (wx + (widget->getWidth()
541  - mDimension.width) / 2 - x), 0);
542 }
543 
545  int offsetX, int offsetY)
546 {
547  if (position == ImagePosition::UPPER_LEFT)
548  {
549  }
550  else if (position == ImagePosition::UPPER_CENTER)
551  {
552  offsetX += (mainGraphics->mWidth - mDimension.width) / 2;
553  }
554  else if (position == ImagePosition::UPPER_RIGHT)
555  {
556  offsetX += mainGraphics->mWidth - mDimension.width;
557  }
558  else if (position == ImagePosition::LEFT)
559  {
560  offsetY += (mainGraphics->mHeight - mDimension.height) / 2;
561  }
562  else if (position == ImagePosition::CENTER)
563  {
564  offsetX += (mainGraphics->mWidth - mDimension.width) / 2;
565  offsetY += (mainGraphics->mHeight - mDimension.height) / 2;
566  }
567  else if (position == ImagePosition::RIGHT)
568  {
569  offsetX += mainGraphics->mWidth - mDimension.width;
570  offsetY += (mainGraphics->mHeight - mDimension.height) / 2;
571  }
572  else if (position == ImagePosition::LOWER_LEFT)
573  {
574  offsetY += mainGraphics->mHeight - mDimension.height;
575  }
576  else if (position == ImagePosition::LOWER_CENTER)
577  {
578  offsetX += (mainGraphics->mWidth - mDimension.width) / 2;
579  offsetY += mainGraphics->mHeight - mDimension.height;
580  }
581  else if (position == ImagePosition::LOWER_RIGHT)
582  {
583  offsetX += mainGraphics->mWidth - mDimension.width;
584  offsetY += mainGraphics->mHeight - mDimension.height;
585  }
586 
587  setPosition(offsetX, offsetY);
588 }
589 
590 void Window::setMinWidth(const int width)
591 {
592  if (mSkin != nullptr)
593  {
594  mMinWinWidth = width > mSkin->getMinWidth()
595  ? width : mSkin->getMinWidth();
596  }
597  else
598  {
599  mMinWinWidth = width;
600  }
601 }
602 
603 void Window::setMinHeight(const int height)
604 {
605  if (mSkin != nullptr)
606  {
607  mMinWinHeight = height > mSkin->getMinHeight()
608  ? height : mSkin->getMinHeight();
609  }
610  else
611  {
612  mMinWinHeight = height;
613  }
614 }
615 
616 void Window::setMaxWidth(const int width)
617 {
618  mMaxWinWidth = width;
619 }
620 
621 void Window::setMaxHeight(const int height)
622 {
623  mMaxWinHeight = height;
624 }
625 
626 void Window::setResizable(const bool r)
627 {
628  if ((mGrip != nullptr) == r)
629  return;
630 
631  if (mGrip != nullptr)
632  mGrip->decRef();
633  if (r)
634  {
635  mGrip = Theme::getImageFromThemeXml("resize.xml", "");
636  if (mGrip != nullptr)
637  {
640  - mGripPadding;
641  }
642  else
643  {
644  mGripRect.x = 0;
645  mGripRect.y = 0;
646  }
647  }
648  else
649  {
650  mGrip = nullptr;
651  }
652 }
653 
655 {
656  if (mGrip != nullptr)
657  {
660  }
661 
662  if (mLayout != nullptr)
663  {
664  const Rect area = getChildrenArea();
665  int w = area.width;
666  int h = area.height;
667  mLayout->reflow(w, h);
668  }
669  if (mSkin != nullptr)
670  {
671  const bool showClose = mCloseWindowButton
672  && (mSkin->getCloseImage(false) != nullptr);
673  if (showClose)
674  {
675  const Image *const button = mSkin->getCloseImage(false);
676  if (button != nullptr)
677  {
678  const int buttonWidth = button->getWidth();
679  mCloseRect.x = mDimension.width - buttonWidth - mClosePadding;
682  mCloseRect.height = button->getHeight();
683  }
684  }
685  if (mStickyButton)
686  {
687  const Image *const button = mSkin->getStickyImage(mSticky);
688  if (button != nullptr)
689  {
690  const int buttonWidth = button->getWidth();
691  int x = mDimension.width - buttonWidth
693 
694  if (showClose)
695  x -= mSkin->getCloseImage(false)->getWidth();
696 
697  mStickyRect.x = x;
700  mStickyRect.height = button->getHeight();
701  }
702  }
703  }
704  else
705  {
706  mCloseRect.x = 0;
707  mCloseRect.y = 0;
708  mCloseRect.width = 0;
709  mCloseRect.height = 0;
710  mStickyRect.x = 0;
711  mStickyRect.y = 0;
712  mStickyRect.width = 0;
713  mStickyRect.height = 0;
714  }
715 
716  mRedraw = true;
717 }
718 
720 {
721  mRedraw = true;
722 }
723 
725 {
727  mVertexes->clear();
728 
730 
731  mTextChanged = true;
732  mRedraw = true;
733 
734  if (gui != nullptr)
736 
737  if (mFocusHandler == nullptr)
738  return;
739 
740  for (WidgetListConstIterator it = mWidgets.begin();
741  it != mWidgets.end(); ++ it)
742  {
743  if (mFocusHandler->isFocused(*it))
745  }
746 }
747 
748 void Window::setCloseButton(const bool flag)
749 {
750  mCloseWindowButton = flag;
751  if (flag)
752  mAllowClose = true;
753 }
754 
756 {
757  return mGrip != nullptr;
758 }
759 
760 void Window::setStickyButton(const bool flag)
761 {
762  mStickyButton = flag;
763 }
764 
765 void Window::setSticky(const bool sticky)
766 {
767  mSticky = sticky;
768  mRedraw = true;
769 }
770 
771 void Window::setStickyButtonLock(const bool lock)
772 {
773  mStickyButtonLock = lock;
774  mStickyButton = lock;
775 }
776 
778 {
779  setVisible(visible, false);
780 }
781 
782 void Window::setVisible(const Visible visible, const bool forceSticky)
783 {
784  if (visible == mVisible)
785  return;
786 
787  // Check if the window is off screen...
788  if (visible == Visible_true)
789  ensureOnScreen();
790  else
791  mResizeHandles = 0;
792 
793  if (mStickyButtonLock)
794  {
796  }
797  else
798  {
799  BasicContainer2::setVisible(fromBool((!forceSticky && mSticky) ||
800  visible == Visible_true, Visible));
801  }
802  if (visible == Visible_true)
803  {
804  if (mPlayVisibleSound)
806  if (gui != nullptr)
807  {
808  MouseEvent *const event = reinterpret_cast<MouseEvent*>(
809  gui->createMouseEvent(this));
810  if (event != nullptr)
811  {
812  const int x = event->getX();
813  const int y = event->getY();
814  if (x >= 0 && x <= mDimension.width
815  && y >= 0 && y <= mDimension.height)
816  {
817  mouseMoved(*event);
818  }
819  delete event;
820  }
821  }
822  }
823  else
824  {
825  if (mPlayVisibleSound)
827  }
828 }
829 
831 {
833 }
834 
836 {
837  if (event.isConsumed())
838  return;
839 
840  if (event.getSource() == this)
841  {
842  if (getParent() != nullptr)
843  getParent()->moveToTop(this);
844 
845  mDragOffsetX = event.getX();
846  mDragOffsetY = event.getY();
847  mMoved = event.getY() <= CAST_S32(mTitleBarHeight);
848  }
849 
850  const MouseButtonT button = event.getButton();
851  if (button == MouseButton::LEFT)
852  {
853  const int x = event.getX();
854  const int y = event.getY();
855 
856  // Handle close button
857  if (mCloseWindowButton &&
858  mSkin != nullptr &&
860  {
861  mouseResize = 0;
862  mMoved = false;
863  event.consume();
864  close();
865  return;
866  }
867 
868  // Handle sticky button
869  if (mStickyButton &&
870  mSkin != nullptr &&
872  {
873  setSticky(!isSticky());
874  mouseResize = 0;
875  mMoved = false;
876  event.consume();
877  return;
878  }
879 
880  // Handle window resizing
882  if (mouseResize != 0)
883  event.consume();
884  if (canMove())
885  mMoved = (mouseResize == 0);
886  else
887  mMoved = false;
888  }
889 #ifndef DYECMD
890  else if (button == MouseButton::RIGHT)
891  {
892  if (popupMenu != nullptr)
893  {
894  event.consume();
895  popupMenu->showWindowPopup(this);
896  }
897  }
898 #endif // DYECMD
899 }
900 
902 {
904 }
905 
907 {
908  if ((mGrip != nullptr) && (mouseResize != 0))
909  {
910  mouseResize = 0;
911  if (gui != nullptr)
913  }
914 
915  mMoved = false;
916 }
917 
919 {
920  updateResizeHandler(event);
921 }
922 
924 {
925  if ((mGrip != nullptr) && (mouseResize == 0) && (gui != nullptr))
927 }
928 
930 {
931  if (gui == nullptr)
932  return;
933 
934 #ifndef DYECMD
935  if (!dragDrop.isEmpty())
936  return;
937 #endif // DYECMD
938 
940 
941  // Changes the custom mouse cursor based on it's current position.
942  switch (mResizeHandles & resizeMask)
943  {
944  case BOTTOM | RIGHT:
945  case TOP | LEFT:
947  break;
948  case TOP | RIGHT:
949  case BOTTOM | LEFT:
951  break;
952  case BOTTOM:
953  case TOP:
955  break;
956  case RIGHT:
957  case LEFT:
959  break;
960  default:
962  break;
963  }
964 }
965 
967 {
968  updateResizeHandler(event);
969  if ((popupManager != nullptr) && !event.isConsumed())
970  {
973  }
974 }
975 
976 bool Window::canMove() const
977 {
978  return !mStickyButtonLock || !mSticky;
979 }
980 
982 {
983  if (canMove())
984  {
985  if (!event.isConsumed() && event.getSource() == this)
986  {
987  if (isMovable() && mMoved)
988  {
989  setPosition(event.getX() - mDragOffsetX + getX(),
990  event.getY() - mDragOffsetY + getY());
991  }
992 
993  event.consume();
994  }
995  }
996  else
997  {
998  if (!event.isConsumed() && event.getSource() == this)
999  event.consume();
1000  return;
1001  }
1002 
1003  // Keep guichan window inside screen when it may be moved
1004  if (isMovable() && mMoved)
1005  {
1007  std::max(0, mDimension.x)),
1008  std::min(mainGraphics->mHeight - mDimension.height,
1009  std::max(0, mDimension.y)));
1010  }
1011 
1012  if ((mouseResize != 0) && !mMoved)
1013  {
1014  const int dx = event.getX() - mDragOffsetX;
1015  const int dy = event.getY() - mDragOffsetY;
1016  Rect newDim = getDimension();
1017 
1018  if ((mouseResize & (TOP | BOTTOM)) != 0)
1019  {
1020  const int newHeight = newDim.height
1021  + ((mouseResize & TOP) != 0 ? -dy : dy);
1022  newDim.height = std::min(mMaxWinHeight,
1023  std::max(mMinWinHeight, newHeight));
1024 
1025  if ((mouseResize & TOP) != 0)
1026  newDim.y -= newDim.height - getHeight();
1027  }
1028 
1029  if ((mouseResize & (LEFT | RIGHT)) != 0)
1030  {
1031  const int newWidth = newDim.width
1032  + ((mouseResize & LEFT) != 0 ? -dx : dx);
1033  newDim.width = std::min(mMaxWinWidth,
1034  std::max(mMinWinWidth, newWidth));
1035 
1036  if ((mouseResize & LEFT) != 0)
1037  newDim.x -= newDim.width - mDimension.width;
1038  }
1039 
1040  // Keep guichan window inside screen (supports resizing any side)
1041  if (newDim.x < 0)
1042  {
1043  newDim.width += newDim.x;
1044  newDim.x = 0;
1045  }
1046  if (newDim.y < 0)
1047  {
1048  newDim.height += newDim.y;
1049  newDim.y = 0;
1050  }
1051  if (newDim.x + newDim.width > mainGraphics->mWidth)
1052  newDim.width = mainGraphics->mWidth - newDim.x;
1053  if (newDim.y + newDim.height > mainGraphics->mHeight)
1054  newDim.height = mainGraphics->mHeight - newDim.y;
1055 
1056  // Update mouse offset when dragging bottom or right border
1057  if ((mouseResize & BOTTOM) != 0)
1058  mDragOffsetY += newDim.height - mDimension.height;
1059 
1060  if ((mouseResize & RIGHT) != 0)
1061  mDragOffsetX += newDim.width - mDimension.width;
1062 
1063  // Set the new window and content dimensions
1064  setDimension(newDim);
1065  }
1066 }
1067 
1068 void Window::setModal(const Modal modal)
1069 {
1070  if (mModal != modal)
1071  {
1072  mModal = modal;
1073  if (mModal == Modal_true)
1074  {
1075  if (gui != nullptr)
1078  }
1079  else
1080  {
1082  }
1083  }
1084 }
1085 
1087 {
1088  const std::string &name = mWindowName;
1089  if (name.empty())
1090  return;
1091 
1092  setPosition(config.getValueInt(name + "WinX", mDefaultX),
1093  config.getValueInt(name + "WinY", mDefaultY));
1094 
1095  if (mSaveVisible)
1096  {
1098  + "Visible", mDefaultVisible), Visible));
1099  }
1100 
1101  if (mStickyButton)
1102  {
1104  + "Sticky", isSticky()));
1105  }
1106 
1107  if (mGrip != nullptr)
1108  {
1109  int width = config.getValueInt(name + "WinWidth", mDefaultWidth);
1110  int height = config.getValueInt(name + "WinHeight", mDefaultHeight);
1111 
1112  if (getMinWidth() > width)
1113  width = getMinWidth();
1114  else if (getMaxWidth() < width)
1115  width = getMaxWidth();
1116  if (getMinHeight() > height)
1117  height = getMinHeight();
1118  else if (getMaxHeight() < height)
1119  height = getMaxHeight();
1120 
1121  setSize(width, height);
1122  }
1123  else
1124  {
1126  }
1127 
1128  // Check if the window is off screen...
1129  ensureOnScreen();
1130 
1131  if (viewport != nullptr)
1132  {
1133  int width = mDimension.width;
1134  int height = mDimension.height;
1135 
1136  if (mDimension.x + width > viewport->getWidth())
1137  width = viewport->getWidth() - mDimension.x;
1138  if (mDimension.y + height > viewport->getHeight())
1139  height = viewport->getHeight() - mDimension.y;
1140  if (width < 0)
1141  width = 0;
1142  if (height < 0)
1143  height = 0;
1144  setSize(width, height);
1145  }
1146 }
1147 
1149 {
1150  // Saving X, Y and Width and Height for resizables in the config
1151  if (!mWindowName.empty() && mWindowName != "window")
1152  {
1153  config.setValue(mWindowName + "WinX", mDimension.x);
1154  config.setValue(mWindowName + "WinY", mDimension.y);
1155 
1156  if (mSaveVisible)
1157  config.setValue(mWindowName + "Visible", isWindowVisible());
1158 
1159  if (mStickyButton)
1160  config.setValue(mWindowName + "Sticky", isSticky());
1161 
1162  if (mGrip != nullptr)
1163  {
1164  if (getMinWidth() > mDimension.width)
1165  setWidth(getMinWidth());
1166  else if (getMaxWidth() < mDimension.width)
1167  setWidth(getMaxWidth());
1168  if (getMinHeight() > mDimension.height)
1170  else if (getMaxHeight() < mDimension.height)
1172 
1173  config.setValue(mWindowName + "WinWidth", mDimension.width);
1174  config.setValue(mWindowName + "WinHeight", mDimension.height);
1175  }
1176  }
1177 }
1178 
1179 void Window::setDefaultSize(const int defaultX, const int defaultY,
1180  int defaultWidth, int defaultHeight)
1181 {
1182  if (mMinWinWidth > defaultWidth)
1183  defaultWidth = mMinWinWidth;
1184  else if (mMaxWinWidth < defaultWidth)
1185  defaultWidth = mMaxWinWidth;
1186  if (mMinWinHeight > defaultHeight)
1187  defaultHeight = mMinWinHeight;
1188  else if (mMaxWinHeight < defaultHeight)
1189  defaultHeight = mMaxWinHeight;
1190 
1191  mDefaultX = defaultX;
1192  mDefaultY = defaultY;
1193  mDefaultWidth = defaultWidth;
1194  mDefaultHeight = defaultHeight;
1195 }
1196 
1198 {
1203 }
1204 
1205 void Window::setDefaultSize(const int defaultWidth, const int defaultHeight,
1206  const ImagePosition::Type &position,
1207  const int offsetX, const int offsetY)
1208 {
1209  int x = 0;
1210  int y = 0;
1211 
1212  if (position == ImagePosition::UPPER_LEFT)
1213  {
1214  }
1215  else if (position == ImagePosition::UPPER_CENTER)
1216  {
1217  x = (mainGraphics->mWidth - defaultWidth) / 2;
1218  }
1219  else if (position == ImagePosition::UPPER_RIGHT)
1220  {
1221  x = mainGraphics->mWidth - defaultWidth;
1222  }
1223  else if (position == ImagePosition::LEFT)
1224  {
1225  y = (mainGraphics->mHeight - defaultHeight) / 2;
1226  }
1227  else if (position == ImagePosition::CENTER)
1228  {
1229  x = (mainGraphics->mWidth - defaultWidth) / 2;
1230  y = (mainGraphics->mHeight - defaultHeight) / 2;
1231  }
1232  else if (position == ImagePosition::RIGHT)
1233  {
1234  x = mainGraphics->mWidth - defaultWidth;
1235  y = (mainGraphics->mHeight - defaultHeight) / 2;
1236  }
1237  else if (position == ImagePosition::LOWER_LEFT)
1238  {
1239  y = mainGraphics->mHeight - defaultHeight;
1240  }
1241  else if (position == ImagePosition::LOWER_CENTER)
1242  {
1243  x = (mainGraphics->mWidth - defaultWidth) / 2;
1244  y = mainGraphics->mHeight - defaultHeight;
1245  }
1246  else if (position == ImagePosition::LOWER_RIGHT)
1247  {
1248  x = mainGraphics->mWidth - defaultWidth;
1249  y = mainGraphics->mHeight - defaultHeight;
1250  }
1251 
1252  mDefaultX = x - offsetX;
1253  mDefaultY = y - offsetY;
1254  mDefaultWidth = defaultWidth;
1255  mDefaultHeight = defaultHeight;
1256 }
1257 
1259 {
1262  saveWindowState();
1263 }
1264 
1265 void Window::adjustPositionAfterResize(const int oldScreenWidth,
1266  const int oldScreenHeight)
1267 {
1268  // If window was aligned to the right or bottom, keep it there
1269  const int rightMargin = oldScreenWidth - (mDimension.x + mDimension.width);
1270  const int bottomMargin = oldScreenHeight
1271  - (mDimension.y + mDimension.height);
1272  if (mDimension.x > 0 && mDimension.x > rightMargin)
1273  mDimension.x = mainGraphics->mWidth - rightMargin - mDimension.width;
1274  if (mDimension.y > 0 && mDimension.y > bottomMargin)
1275  {
1277  - bottomMargin - mDimension.height;
1278  }
1279 
1280  ensureOnScreen();
1282 }
1283 
1285 {
1286  if (mGrip == nullptr)
1287  return;
1288 
1289  const int screenWidth = mainGraphics->mWidth;
1290  const int screenHeight = mainGraphics->mHeight;
1291  const int oldWidth = mDimension.width;
1292  const int oldHeight = mDimension.height;
1293  if (oldWidth + mDimension.x > screenWidth)
1294  mDimension.x = 0;
1295  if (oldHeight + mDimension.y > screenHeight)
1296  mDimension.x = 0;
1297  if (mDimension.width > screenWidth)
1298  mDimension.width = screenWidth;
1299  if (mDimension.height > screenHeight)
1300  mDimension.height = screenHeight;
1301  if (oldWidth != mDimension.width || oldHeight != mDimension.height)
1302  widgetResized(Event(this));
1303 }
1304 
1306 {
1307  if (event.getX() < 0 || event.getY() < 0)
1308  return 0;
1309 
1310  int resizeHandles = 0;
1311  const unsigned y = event.getY();
1312  const unsigned x = event.getX();
1313  if (mCloseRect.isPointInRect(x, y))
1314  return CLOSE;
1315 
1316  if (!mStickyButtonLock || !mSticky)
1317  {
1318  if ((mGrip != nullptr) &&
1319  (y > mTitleBarHeight ||
1320  (CAST_S32(y) < mPadding &&
1322  {
1323  if (!getWindowArea().isPointInRect(x, y)
1324  && event.getSource() == this)
1325  {
1326  resizeHandles |= (x > mDimension.width - resizeBorderWidth)
1327  ? RIGHT : (x < resizeBorderWidth) ? LEFT : 0;
1328  resizeHandles |= (y > mDimension.height - resizeBorderWidth)
1329  ? BOTTOM : (y < resizeBorderWidth) ? TOP : 0;
1330  }
1331  if (x >= CAST_U32(mGripRect.x)
1332  && y >= CAST_U32(mGripRect.y))
1333  {
1334  mDragOffsetX = x;
1335  mDragOffsetY = y;
1336  resizeHandles |= BOTTOM | RIGHT;
1337  }
1338  }
1339  }
1340 
1341  return resizeHandles;
1342 }
1343 
1344 bool Window::isResizeAllowed(const MouseEvent &event) const
1345 {
1346  const int y = event.getY();
1347 
1348  if ((mGrip != nullptr) &&
1349  (y > CAST_S32(mTitleBarHeight) ||
1350  y < mPadding))
1351  {
1352  const int x = event.getX();
1353 
1354  if (!getWindowArea().isPointInRect(x, y) && event.getSource() == this)
1355  return true;
1356 
1357  if (x >= mGripRect.x && y >= mGripRect.y)
1358  return true;
1359  }
1360 
1361  return false;
1362 }
1363 
1365 {
1366  if (mLayout == nullptr)
1367  mLayout = new Layout;
1368  return *mLayout;
1369 }
1370 
1372 {
1373  clear();
1374 
1375  // Recreate layout instance when one is present
1376  if (mLayout != nullptr)
1377  {
1378  delete mLayout;
1379  mLayout = new Layout;
1380  }
1381 }
1382 
1383 LayoutCell &Window::place(const int x, const int y, Widget *const wg,
1384  const int w, const int h)
1385 {
1386  add(wg);
1387  return getLayout().place(wg, x, y, w, h);
1388 }
1389 
1390 ContainerPlacer Window::getPlacer(const int x, const int y)
1391 {
1392  return ContainerPlacer(this, &getLayout().at(x, y));
1393 }
1394 
1395 void Window::reflowLayout(int w, int h)
1396 {
1397  if (mLayout == nullptr)
1398  return;
1399 
1400  mLayout->reflow(w, h);
1401  delete2(mLayout);
1402  setContentSize(w, h);
1403 }
1404 
1406 {
1407  if (mLayout != nullptr)
1408  {
1409  const Rect area = getChildrenArea();
1410  int w = area.width;
1411  int h = area.height;
1412  mLayout->reflow(w, h);
1413  }
1414 }
1415 
1417 {
1419 }
1420 
1422 {
1424 }
1425 
1427 {
1428  // Skip when a window hasn't got any size initialized yet
1429  if (mDimension.width == 0 && mDimension.height == 0)
1430  return;
1431 
1432  // Check the left and bottom screen boundaries
1437 
1438  // But never allow the windows to disappear in to the right and top
1439  if (mDimension.x < 0)
1440  mDimension.x = 0;
1441  if (mDimension.y < 0)
1442  mDimension.y = 0;
1443 }
1444 
1446 {
1447  return Rect(mPadding,
1448  mPadding,
1449  mDimension.width - mPadding * 2,
1450  mDimension.height - mPadding * 2);
1451 }
1452 
1453 int Window::getOption(const std::string &name, const int def) const
1454 {
1455  if (mSkin != nullptr)
1456  {
1457  const int val = mSkin->getOption(name);
1458  if (val != 0)
1459  return val;
1460  return def;
1461  }
1462  return def;
1463 }
1464 
1465 bool Window::getOptionBool(const std::string &name, const bool def) const
1466 {
1467  if (mSkin != nullptr)
1468  return mSkin->getOption(name, static_cast<int>(def)) != 0;
1469  return def;
1470 }
1471 
1473 {
1474  return Rect(mPadding,
1476  mDimension.width - mPadding * 2,
1478 }
1479 
1481 {
1482  int w = 0;
1483  int h = 0;
1484  for (WidgetListConstIterator it = mWidgets.begin();
1485  it != mWidgets.end(); ++ it)
1486  {
1487  const Widget *const widget = *it;
1488  const int x = widget->getX();
1489  const int y = widget->getY();
1490  const int width = widget->getWidth();
1491  const int height = widget->getHeight();
1492  if (x + width > w)
1493  w = x + width;
1494 
1495  if (y + height > h)
1496  h = y + height;
1497  }
1498 
1499  setSize(w + 2 * mPadding,
1500  h + mPadding + mTitleBarHeight);
1501 }
1502 
1503 #ifdef USE_PROFILER
1504 void Window::logic()
1505 {
1506  BLOCK_START("Window::logic")
1507  logicChildren();
1508  BLOCK_END("Window::logic")
1509 }
1510 #endif // USE_PROFILER
bool mShowTitle
Definition: window.h:655
void setSize(const int width, const int height)
Definition: widget.cpp:366
static const int buttonWidth
Definition: sliderlist.cpp:34
#define CAST_U32
Definition: cast.h:30
void setDefaultSize()
Definition: window.cpp:1197
MouseEvent * createMouseEvent(Window *const widget)
Definition: gui.cpp:985
LayoutCell & place(const int x, const int y, Widget *const wg, const int w, const int h)
Definition: window.cpp:1383
Rect mGripRect
Definition: window.h:691
bool isResizable() const
Definition: window.cpp:755
static const std::string SOUND_HIDE_WINDOW
Definition: sound.h:37
int getMinHeight() const
Definition: skin.cpp:141
std::string mWindowName
Definition: window.h:693
int width
Definition: rect.h:218
void updateResizeHandler(MouseEvent &event)
Definition: window.cpp:929
std::string text
Definition: textchunk.h:64
void redraw()
Definition: window.cpp:1405
Font * mCaptionFont
Definition: window.h:718
int getWidth() const
Definition: widget.h:220
Skin * mSkin
Definition: window.h:648
Font * boldFont
Definition: gui.cpp:111
TextChunk mTextChunk
Definition: window.h:692
void adjustSizeToScreen()
Definition: window.cpp:1284
int mGripPadding
Definition: window.h:712
int mDragOffsetY
Definition: window.h:641
virtual void drawTileCollection(const ImageCollection *const vertCol)=0
void setWidth(const int width)
Definition: widget.cpp:132
void unload(Skin *const skin)
Definition: theme.cpp:249
bool getOptionBool(const std::string &name, const bool def) const
Definition: window.cpp:1465
void scheduleDelete(Widget *const widget)
int mPadding
Definition: window.h:617
Gui * gui
Definition: gui.cpp:110
void requestModalFocus()
Definition: widget.cpp:379
virtual void releaseModalFocus()
Definition: widget.cpp:393
void setLocationHorisontallyRelativeTo(const Widget *const widget)
Definition: window.cpp:527
const bool Visible_true
Definition: visible.h:29
void setMaxWidth(const int width)
Definition: window.cpp:616
void loadWindowState()
Definition: window.cpp:1086
WindowContainer * windowContainer
virtual void drawImageRect(const int x, const int y, const int w, const int h, const ImageRect &imgRect)=0
int getY() const
Definition: widget.h:287
WidgetList::const_iterator WidgetListConstIterator
virtual void resetToDefaultSize()
Definition: window.cpp:1258
static int mouseResize
Definition: window.h:699
Rect getChildrenArea()
Definition: window.cpp:1472
void setVisible(Visible visible)
Definition: widget.cpp:224
void setMaxHeight(const int height)
Definition: window.cpp:621
static Image * getImageFromThemeXml(const std::string &name, const std::string &name2)
Definition: theme.cpp:925
virtual void resizeToContent()
Definition: window.cpp:1480
int mOldResizeHandles
Definition: window.h:714
bool mTextChanged
Definition: window.h:728
bool mStickyButtonLock
Definition: window.h:725
int mCaptionOffsetY
Definition: window.h:654
Definition: rect.h:72
void reflow(int &nW, int &nH)
Definition: layout.cpp:35
void setMinWidth(const int width)
Definition: window.cpp:590
Definition: window.h:98
int mWidth
Definition: graphics.h:483
int mStickySpacing
Definition: window.h:716
#define BLOCK_START(name)
Definition: perfomance.h:78
SoundManager soundManager
Configuration config
bool isFocused(const Widget *const widget) const
static std::string getThemePath()
Definition: theme.h:66
bool isPointInRect(const int x_, const int y_) const
Definition: rect.h:196
bool mDefaultVisible
Definition: window.h:721
void setDimension(const Rect &dimension)
Definition: widget.cpp:168
void centerHorisontally()
Definition: window.cpp:1421
int getOption(const std::string &name, const int def) const
Definition: window.cpp:1453
PopupManager * popupManager
ImageCollection * mVertexes
Definition: window.h:709
void mouseMoved(MouseEvent &event)
Definition: window.cpp:966
Rect mCloseRect
Definition: window.h:689
bool mStickyButton
Definition: window.h:723
DragDrop dragDrop
Skin * load(const std::string &filename, const std::string &filename2, const bool full, const std::string &defaultPath)
Definition: theme.cpp:178
#define BLOCK_END(name)
Definition: perfomance.h:79
RenderType openGLMode
FocusHandler * mFocusHandler
Definition: widget.h:1115
bool mMoved
Definition: window.h:646
Client * client
Definition: client.cpp:117
#define delete2(var)
Definition: delete2.h:24
bool isEmpty() const
Definition: dragdrop.h:195
Color mForegroundColor
Definition: widget.h:1085
int mCaptionOffsetX
Definition: window.h:653
Font * textFont
Definition: textchunk.h:63
int mDragOffsetX
Definition: window.h:634
int getOption(const std::string &name) const
Definition: skin.h:105
virtual void clear()
bool isMovable() const
Definition: window.h:575
int mMaxWinWidth
Definition: window.h:696
Logger * logger
Definition: logger.cpp:88
int mDefaultY
Definition: window.h:650
virtual void finalize(ImageCollection *const col)
Definition: graphics.h:464
Visible mVisible
Definition: widget.h:962
void ensureOnScreen()
Definition: window.cpp:1426
virtual void close()
Definition: window.cpp:901
void widgetHidden(const Event &event)
Definition: window.cpp:724
#define new
Definition: debug_new.h:147
void setContentSize(int width, int height)
Definition: window.cpp:491
bool mAllowClose
Definition: window.h:729
int getMinHeight() const
Definition: window.h:212
int x
Definition: rect.h:208
int getPadding() const
Definition: skin.h:99
void widgetResized(const Event &event)
Definition: window.cpp:654
#define CAST_S32
Definition: cast.h:29
static void hideTextPopup()
const ImageRect & getBorder() const
Definition: skin.h:67
int mTitlePadding
Definition: window.h:711
void setSticky(const bool sticky)
Definition: window.cpp:765
const bool Visible_false
Definition: visible.h:29
#define fromBool(val, name)
Definition: booldefines.h:48
Widget * mWindow
Definition: widget2.h:111
void draw(Graphics *const graphics)
Definition: window.cpp:310
bool canMove() const
Definition: window.cpp:976
Widget * getSource() const
Definition: event.h:103
int mDefaultWidth
Definition: window.h:651
bool mLastRedraw
Definition: window.h:656
int y
Definition: rect.h:213
PopupMenu * popupMenu
Definition: popupmenu.cpp:102
void setFrameSize(const unsigned int frameSize)
Definition: widget.h:167
virtual void logicChildren()
virtual void add(Widget *const widget)
int mStickyPadding
Definition: window.h:717
bool mInit
Definition: window.h:727
Graphics::Alignment mCaptionAlign
Definition: window.h:710
#define nullptr
Definition: localconsts.h:44
Graphics * mainGraphics
Definition: graphics.cpp:108
static const unsigned resizeBorderWidth
Definition: window.h:708
bool isWindowVisible() const
Definition: window.h:483
bool getValueBool(const std::string &key, const bool deflt) const
int getTitlePadding() const
Definition: skin.h:102
const Image * getStickyImage(const bool state) const
Definition: skin.h:80
int mClosePadding
Definition: window.h:715
void addMouseListener(MouseListener *const mouseListener)
Definition: widget.cpp:291
~Window()
Definition: window.cpp:259
void setPosition(const int x, const int y)
Definition: widget.cpp:160
void setCloseButton(const bool flag)
Definition: window.cpp:748
int height
Definition: rect.h:223
bool mCloseWindowButton
Definition: window.h:720
int mHeight
Definition: graphics.h:484
void setCursorType(const CursorT index)
Definition: gui.h:195
virtual void getAbsolutePosition(int &x, int &y) const
Definition: widget.cpp:311
Rect getWindowArea() const
Definition: window.cpp:1445
bool isConsumed() const
int mResizeHandles
Definition: window.h:713
const Rect & getDimension() const
Definition: widget.h:316
bool mSticky
Definition: window.h:724
const bool Move_true
Definition: move.h:29
void setMinHeight(const int height)
Definition: window.cpp:603
ContainerPlacer getPlacer(const int x, const int y)
Definition: window.cpp:1390
static int windowInstances
Definition: window.h:700
Rect mStickyRect
Definition: window.h:690
virtual void scheduleDelete()
Definition: window.cpp:830
Modal mModal
Definition: window.h:719
bool mPlayVisibleSound
Definition: window.h:726
Layout & getLayout()
Definition: window.cpp:1364
void widgetMoved(const Event &event)
Definition: window.cpp:719
int getMaxHeight() const
Definition: window.h:228
virtual void moveToTop(Widget *widget)
Definition: widget.h:866
std::string mCaption
Definition: window.h:607
void setHeight(const int height)
Definition: widget.cpp:139
void addWidgetListener(WidgetListener *const widgetListener)
Definition: widget.cpp:301
void mouseReleased(MouseEvent &event)
Definition: window.cpp:906
bool mSaveVisible
Definition: window.h:722
int getX() const
Definition: widget.h:268
Widget * getParent() const
Definition: widget.h:201
Theme * theme
Definition: theme.cpp:61
#define A_UNUSED
Definition: localconsts.h:159
static void hideBeingPopup()
virtual void setVisible(Visible visible)
Definition: window.cpp:777
void center()
Definition: window.cpp:1416
static const std::string SOUND_SHOW_WINDOW
Definition: sound.h:36
bool Visible
Definition: visible.h:29
const Image * getCloseImage(const bool state) const
Definition: skin.h:73
Color mForegroundColor2
Definition: widget2.h:112
Image * img
Definition: textchunk.h:62
virtual void drawImage(const Image *const image, int dstX, int dstY)=0
void removeDragged(const Widget *const widget)
Definition: gui.cpp:1161
Definition: widget.h:97
int mDefaultHeight
Definition: window.h:652
void removeWidgetListener(WidgetListener *const widgetListener)
Definition: widget.cpp:306
virtual void drawChildren(Graphics *const graphics)
int getWidth(const std::string &text) const
Definition: font.cpp:333
Definition: event.h:77
int getMaxWidth() const
Definition: window.h:220
int mDefaultX
Definition: window.h:649
void mouseDragged(MouseEvent &event)
Definition: window.cpp:981
void windowRemoved(const Window *const window)
Definition: client.cpp:802
bool isResizeAllowed(const MouseEvent &event) const
Definition: window.cpp:1344
void mouseEntered(MouseEvent &event)
Definition: window.cpp:918
bool mRedraw
Definition: widget.h:1163
void mousePressed(MouseEvent &event)
Definition: window.cpp:835
Definition: image.h:61
virtual void calcTileCollection(ImageCollection *const vertCol, const Image *const image, int x, int y)=0
int getHeight() const
Definition: widget.h:239
void mouseExited(MouseEvent &event)
Definition: window.cpp:923
Color color
Definition: textchunk.h:65
Layout * mLayout
Definition: window.h:688
int getWidth() const A_INLINE
Definition: image.h:116
WidgetList mWidgets
void setResizable(const bool resize)
Definition: window.cpp:626
bool isSticky() const
Definition: window.h:252
void setRedraw(const bool n)
Definition: graphics.h:283
void setStickyButtonLock(const bool sticky)
Definition: window.cpp:771
const Color & getThemeColor(const ThemeColorIdT type, const unsigned int alpha) const A_INLINE
Definition: widget2.h:44
int getX() const
Definition: mouseevent.h:126
void unregisterWindowForReset(const Window *const window)
void showWindowPopup(Window *const window)
Definition: popupmenu.cpp:1163
static void setWindowContainer(WindowContainer *const windowContainer)
Definition: window.cpp:305
SetupWindow * setupWindow
Definition: setupwindow.cpp:63
LayoutCell & place(Widget *const wg, const int x, const int y, const int w, const int h)
Definition: layoutcell.cpp:110
void setPadding(int padding)
Definition: window.h:493
void log(const char *const log_text,...)
Definition: logger.cpp:264
void setTitleBarHeight(unsigned int height)
Definition: window.h:512
int getValueInt(const std::string &key, const int deflt) const
int getHeight() const
Definition: font.cpp:361
void setStickyButton(const bool flag)
Definition: window.cpp:760
void deleteImage()
Definition: textchunk.cpp:192
Definition: layout.h:43
Color color2
Definition: textchunk.h:66
void saveWindowState()
Definition: window.cpp:1148
void clearLayout()
Definition: window.cpp:1371
MouseButton ::T MouseButtonT
Definition: mousebutton.h:77
Rect mDimension
Definition: widget.h:1100
unsigned int mTitleBarHeight
Definition: window.h:622
#define isBatchDrawRenders(val)
Definition: renderers.h:30
const std::string & getCaption() const
Definition: window.h:539
#define reportAlways(...)
Definition: checkutils.h:252
virtual void safeDrawChildren(Graphics *const graphics)
int mMinWinWidth
Definition: window.h:694
void decRef()
Definition: image.cpp:522
void setValue(const std::string &key, const std::string &value)
void update()
Definition: useragent.cpp:31
Window(const std::string &caption, const Modal modal, Window *const parent, std::string skin)
Definition: window.cpp:108
void setLocationRelativeTo(const Widget *const widget)
Definition: window.cpp:508
int getResizeHandles(const MouseEvent &event)
Definition: window.cpp:1305
int getMinWidth() const
Definition: window.h:204
void setModal(const Modal modal)
Definition: window.cpp:1068
int mMaxWinHeight
Definition: window.h:697
void reflowLayout(int w, int h)
Definition: window.cpp:1395
void postInit()
Definition: window.cpp:248
virtual void calcWindow(ImageCollection *const vertCol, const int x, const int y, const int w, const int h, const ImageRect &imgRect)=0
int mMinWinHeight
Definition: window.h:695
Viewport * viewport
Definition: viewport.cpp:35
void safeDraw(Graphics *const graphics)
Definition: window.cpp:422
void playGuiSound(const std::string &name)
const int resizeMask
Definition: window.cpp:103
int getHeight() const A_INLINE
Definition: image.h:122
int getMinWidth() const
Definition: skin.cpp:128
void generate(TextChunk &chunk)
Definition: font.cpp:429
void setPalette(int palette)
Definition: widget2.h:68
Image * mGrip
Definition: window.h:686
void adjustPositionAfterResize(const int oldScreenWidth, const int oldScreenHeight)
Definition: window.cpp:1265