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, wy;
514  int x, y;
515 
516  widget->getAbsolutePosition(wx, wy);
517  getAbsolutePosition(x, y);
518 
519  setPosition(mDimension.x + (wx + (widget->getWidth()
520  - mDimension.width) / 2 - x),
521  mDimension.y + (wy + (widget->getHeight()
522  - mDimension.height) / 2 - y));
523 }
524 
526 {
527  if (widget == nullptr)
528  return;
529 
530  int wx, wy;
531  int x, y;
532 
533  widget->getAbsolutePosition(wx, wy);
534  getAbsolutePosition(x, y);
535 
536  setPosition(mDimension.x + (wx + (widget->getWidth()
537  - mDimension.width) / 2 - x), 0);
538 }
539 
541  int offsetX, int offsetY)
542 {
543  if (position == ImagePosition::UPPER_LEFT)
544  {
545  }
546  else if (position == ImagePosition::UPPER_CENTER)
547  {
548  offsetX += (mainGraphics->mWidth - mDimension.width) / 2;
549  }
550  else if (position == ImagePosition::UPPER_RIGHT)
551  {
552  offsetX += mainGraphics->mWidth - mDimension.width;
553  }
554  else if (position == ImagePosition::LEFT)
555  {
556  offsetY += (mainGraphics->mHeight - mDimension.height) / 2;
557  }
558  else if (position == ImagePosition::CENTER)
559  {
560  offsetX += (mainGraphics->mWidth - mDimension.width) / 2;
561  offsetY += (mainGraphics->mHeight - mDimension.height) / 2;
562  }
563  else if (position == ImagePosition::RIGHT)
564  {
565  offsetX += mainGraphics->mWidth - mDimension.width;
566  offsetY += (mainGraphics->mHeight - mDimension.height) / 2;
567  }
568  else if (position == ImagePosition::LOWER_LEFT)
569  {
570  offsetY += mainGraphics->mHeight - mDimension.height;
571  }
572  else if (position == ImagePosition::LOWER_CENTER)
573  {
574  offsetX += (mainGraphics->mWidth - mDimension.width) / 2;
575  offsetY += mainGraphics->mHeight - mDimension.height;
576  }
577  else if (position == ImagePosition::LOWER_RIGHT)
578  {
579  offsetX += mainGraphics->mWidth - mDimension.width;
580  offsetY += mainGraphics->mHeight - mDimension.height;
581  }
582 
583  setPosition(offsetX, offsetY);
584 }
585 
586 void Window::setMinWidth(const int width)
587 {
588  if (mSkin != nullptr)
589  {
590  mMinWinWidth = width > mSkin->getMinWidth()
591  ? width : mSkin->getMinWidth();
592  }
593  else
594  {
595  mMinWinWidth = width;
596  }
597 }
598 
599 void Window::setMinHeight(const int height)
600 {
601  if (mSkin != nullptr)
602  {
603  mMinWinHeight = height > mSkin->getMinHeight()
604  ? height : mSkin->getMinHeight();
605  }
606  else
607  {
608  mMinWinHeight = height;
609  }
610 }
611 
612 void Window::setMaxWidth(const int width)
613 {
614  mMaxWinWidth = width;
615 }
616 
617 void Window::setMaxHeight(const int height)
618 {
619  mMaxWinHeight = height;
620 }
621 
622 void Window::setResizable(const bool r)
623 {
624  if ((mGrip != nullptr) == r)
625  return;
626 
627  if (mGrip != nullptr)
628  mGrip->decRef();
629  if (r)
630  {
631  mGrip = Theme::getImageFromThemeXml("resize.xml", "");
632  if (mGrip != nullptr)
633  {
636  - mGripPadding;
637  }
638  else
639  {
640  mGripRect.x = 0;
641  mGripRect.y = 0;
642  }
643  }
644  else
645  {
646  mGrip = nullptr;
647  }
648 }
649 
651 {
652  if (mGrip != nullptr)
653  {
656  }
657 
658  if (mLayout != nullptr)
659  {
660  const Rect area = getChildrenArea();
661  int w = area.width;
662  int h = area.height;
663  mLayout->reflow(w, h);
664  }
665  if (mSkin != nullptr)
666  {
667  const bool showClose = mCloseWindowButton
668  && (mSkin->getCloseImage(false) != nullptr);
669  if (showClose)
670  {
671  const Image *const button = mSkin->getCloseImage(false);
672  if (button != nullptr)
673  {
674  const int buttonWidth = button->getWidth();
675  mCloseRect.x = mDimension.width - buttonWidth - mClosePadding;
678  mCloseRect.height = button->getHeight();
679  }
680  }
681  if (mStickyButton)
682  {
683  const Image *const button = mSkin->getStickyImage(mSticky);
684  if (button != nullptr)
685  {
686  const int buttonWidth = button->getWidth();
687  int x = mDimension.width - buttonWidth
689 
690  if (showClose)
691  x -= mSkin->getCloseImage(false)->getWidth();
692 
693  mStickyRect.x = x;
696  mStickyRect.height = button->getHeight();
697  }
698  }
699  }
700  else
701  {
702  mCloseRect.x = 0;
703  mCloseRect.y = 0;
704  mCloseRect.width = 0;
705  mCloseRect.height = 0;
706  mStickyRect.x = 0;
707  mStickyRect.y = 0;
708  mStickyRect.width = 0;
709  mStickyRect.height = 0;
710  }
711 
712  mRedraw = true;
713 }
714 
716 {
717  mRedraw = true;
718 }
719 
721 {
723  mVertexes->clear();
724 
726 
727  mTextChanged = true;
728  mRedraw = true;
729 
730  if (gui != nullptr)
732 
733  if (mFocusHandler == nullptr)
734  return;
735 
736  for (WidgetListConstIterator it = mWidgets.begin();
737  it != mWidgets.end(); ++ it)
738  {
739  if (mFocusHandler->isFocused(*it))
741  }
742 }
743 
744 void Window::setCloseButton(const bool flag)
745 {
746  mCloseWindowButton = flag;
747  if (flag)
748  mAllowClose = true;
749 }
750 
752 {
753  return mGrip != nullptr;
754 }
755 
756 void Window::setStickyButton(const bool flag)
757 {
758  mStickyButton = flag;
759 }
760 
761 void Window::setSticky(const bool sticky)
762 {
763  mSticky = sticky;
764  mRedraw = true;
765 }
766 
767 void Window::setStickyButtonLock(const bool lock)
768 {
769  mStickyButtonLock = lock;
770  mStickyButton = lock;
771 }
772 
774 {
775  setVisible(visible, false);
776 }
777 
778 void Window::setVisible(const Visible visible, const bool forceSticky)
779 {
780  if (visible == mVisible)
781  return;
782 
783  // Check if the window is off screen...
784  if (visible == Visible_true)
785  ensureOnScreen();
786  else
787  mResizeHandles = 0;
788 
789  if (mStickyButtonLock)
790  {
792  }
793  else
794  {
795  BasicContainer2::setVisible(fromBool((!forceSticky && mSticky) ||
796  visible == Visible_true, Visible));
797  }
798  if (visible == Visible_true)
799  {
800  if (mPlayVisibleSound)
802  if (gui != nullptr)
803  {
804  MouseEvent *const event = reinterpret_cast<MouseEvent*>(
805  gui->createMouseEvent(this));
806  if (event != nullptr)
807  {
808  const int x = event->getX();
809  const int y = event->getY();
810  if (x >= 0 && x <= mDimension.width
811  && y >= 0 && y <= mDimension.height)
812  {
813  mouseMoved(*event);
814  }
815  delete event;
816  }
817  }
818  }
819  else
820  {
821  if (mPlayVisibleSound)
823  }
824 }
825 
827 {
829 }
830 
832 {
833  if (event.isConsumed())
834  return;
835 
836  if (event.getSource() == this)
837  {
838  if (getParent() != nullptr)
839  getParent()->moveToTop(this);
840 
841  mDragOffsetX = event.getX();
842  mDragOffsetY = event.getY();
843  mMoved = event.getY() <= CAST_S32(mTitleBarHeight);
844  }
845 
846  const MouseButtonT button = event.getButton();
847  if (button == MouseButton::LEFT)
848  {
849  const int x = event.getX();
850  const int y = event.getY();
851 
852  // Handle close button
853  if (mCloseWindowButton &&
854  mSkin != nullptr &&
856  {
857  mouseResize = 0;
858  mMoved = false;
859  event.consume();
860  close();
861  return;
862  }
863 
864  // Handle sticky button
865  if (mStickyButton &&
866  mSkin != nullptr &&
868  {
869  setSticky(!isSticky());
870  mouseResize = 0;
871  mMoved = false;
872  event.consume();
873  return;
874  }
875 
876  // Handle window resizing
878  if (mouseResize != 0)
879  event.consume();
880  if (canMove())
881  mMoved = (mouseResize == 0);
882  else
883  mMoved = false;
884  }
885 #ifndef DYECMD
886  else if (button == MouseButton::RIGHT)
887  {
888  if (popupMenu != nullptr)
889  {
890  event.consume();
891  popupMenu->showWindowPopup(this);
892  }
893  }
894 #endif // DYECMD
895 }
896 
898 {
900 }
901 
903 {
904  if ((mGrip != nullptr) && (mouseResize != 0))
905  {
906  mouseResize = 0;
907  if (gui != nullptr)
909  }
910 
911  mMoved = false;
912 }
913 
915 {
916  updateResizeHandler(event);
917 }
918 
920 {
921  if ((mGrip != nullptr) && (mouseResize == 0) && (gui != nullptr))
923 }
924 
926 {
927  if (gui == nullptr)
928  return;
929 
930 #ifndef DYECMD
931  if (!dragDrop.isEmpty())
932  return;
933 #endif // DYECMD
934 
936 
937  // Changes the custom mouse cursor based on it's current position.
938  switch (mResizeHandles & resizeMask)
939  {
940  case BOTTOM | RIGHT:
941  case TOP | LEFT:
943  break;
944  case TOP | RIGHT:
945  case BOTTOM | LEFT:
947  break;
948  case BOTTOM:
949  case TOP:
951  break;
952  case RIGHT:
953  case LEFT:
955  break;
956  default:
958  break;
959  }
960 }
961 
963 {
964  updateResizeHandler(event);
965  if ((popupManager != nullptr) && !event.isConsumed())
966  {
969  }
970 }
971 
972 bool Window::canMove() const
973 {
974  return !mStickyButtonLock || !mSticky;
975 }
976 
978 {
979  if (canMove())
980  {
981  if (!event.isConsumed() && event.getSource() == this)
982  {
983  if (isMovable() && mMoved)
984  {
985  setPosition(event.getX() - mDragOffsetX + getX(),
986  event.getY() - mDragOffsetY + getY());
987  }
988 
989  event.consume();
990  }
991  }
992  else
993  {
994  if (!event.isConsumed() && event.getSource() == this)
995  event.consume();
996  return;
997  }
998 
999  // Keep guichan window inside screen when it may be moved
1000  if (isMovable() && mMoved)
1001  {
1003  std::max(0, mDimension.x)),
1004  std::min(mainGraphics->mHeight - mDimension.height,
1005  std::max(0, mDimension.y)));
1006  }
1007 
1008  if ((mouseResize != 0) && !mMoved)
1009  {
1010  const int dx = event.getX() - mDragOffsetX;
1011  const int dy = event.getY() - mDragOffsetY;
1012  Rect newDim = getDimension();
1013 
1014  if ((mouseResize & (TOP | BOTTOM)) != 0)
1015  {
1016  const int newHeight = newDim.height
1017  + ((mouseResize & TOP) != 0 ? -dy : dy);
1018  newDim.height = std::min(mMaxWinHeight,
1019  std::max(mMinWinHeight, newHeight));
1020 
1021  if ((mouseResize & TOP) != 0)
1022  newDim.y -= newDim.height - getHeight();
1023  }
1024 
1025  if ((mouseResize & (LEFT | RIGHT)) != 0)
1026  {
1027  const int newWidth = newDim.width
1028  + ((mouseResize & LEFT) != 0 ? -dx : dx);
1029  newDim.width = std::min(mMaxWinWidth,
1030  std::max(mMinWinWidth, newWidth));
1031 
1032  if ((mouseResize & LEFT) != 0)
1033  newDim.x -= newDim.width - mDimension.width;
1034  }
1035 
1036  // Keep guichan window inside screen (supports resizing any side)
1037  if (newDim.x < 0)
1038  {
1039  newDim.width += newDim.x;
1040  newDim.x = 0;
1041  }
1042  if (newDim.y < 0)
1043  {
1044  newDim.height += newDim.y;
1045  newDim.y = 0;
1046  }
1047  if (newDim.x + newDim.width > mainGraphics->mWidth)
1048  newDim.width = mainGraphics->mWidth - newDim.x;
1049  if (newDim.y + newDim.height > mainGraphics->mHeight)
1050  newDim.height = mainGraphics->mHeight - newDim.y;
1051 
1052  // Update mouse offset when dragging bottom or right border
1053  if ((mouseResize & BOTTOM) != 0)
1054  mDragOffsetY += newDim.height - mDimension.height;
1055 
1056  if ((mouseResize & RIGHT) != 0)
1057  mDragOffsetX += newDim.width - mDimension.width;
1058 
1059  // Set the new window and content dimensions
1060  setDimension(newDim);
1061  }
1062 }
1063 
1064 void Window::setModal(const Modal modal)
1065 {
1066  if (mModal != modal)
1067  {
1068  mModal = modal;
1069  if (mModal == Modal_true)
1070  {
1071  if (gui != nullptr)
1074  }
1075  else
1076  {
1078  }
1079  }
1080 }
1081 
1083 {
1084  const std::string &name = mWindowName;
1085  if (name.empty())
1086  return;
1087 
1088  setPosition(config.getValueInt(name + "WinX", mDefaultX),
1089  config.getValueInt(name + "WinY", mDefaultY));
1090 
1091  if (mSaveVisible)
1092  {
1094  + "Visible", mDefaultVisible), Visible));
1095  }
1096 
1097  if (mStickyButton)
1098  {
1100  + "Sticky", isSticky()));
1101  }
1102 
1103  if (mGrip != nullptr)
1104  {
1105  int width = config.getValueInt(name + "WinWidth", mDefaultWidth);
1106  int height = config.getValueInt(name + "WinHeight", mDefaultHeight);
1107 
1108  if (getMinWidth() > width)
1109  width = getMinWidth();
1110  else if (getMaxWidth() < width)
1111  width = getMaxWidth();
1112  if (getMinHeight() > height)
1113  height = getMinHeight();
1114  else if (getMaxHeight() < height)
1115  height = getMaxHeight();
1116 
1117  setSize(width, height);
1118  }
1119  else
1120  {
1122  }
1123 
1124  // Check if the window is off screen...
1125  ensureOnScreen();
1126 
1127  if (viewport != nullptr)
1128  {
1129  int width = mDimension.width;
1130  int height = mDimension.height;
1131 
1132  if (mDimension.x + width > viewport->getWidth())
1133  width = viewport->getWidth() - mDimension.x;
1134  if (mDimension.y + height > viewport->getHeight())
1135  height = viewport->getHeight() - mDimension.y;
1136  if (width < 0)
1137  width = 0;
1138  if (height < 0)
1139  height = 0;
1140  setSize(width, height);
1141  }
1142 }
1143 
1145 {
1146  // Saving X, Y and Width and Height for resizables in the config
1147  if (!mWindowName.empty() && mWindowName != "window")
1148  {
1149  config.setValue(mWindowName + "WinX", mDimension.x);
1150  config.setValue(mWindowName + "WinY", mDimension.y);
1151 
1152  if (mSaveVisible)
1153  config.setValue(mWindowName + "Visible", isWindowVisible());
1154 
1155  if (mStickyButton)
1156  config.setValue(mWindowName + "Sticky", isSticky());
1157 
1158  if (mGrip != nullptr)
1159  {
1160  if (getMinWidth() > mDimension.width)
1161  setWidth(getMinWidth());
1162  else if (getMaxWidth() < mDimension.width)
1163  setWidth(getMaxWidth());
1164  if (getMinHeight() > mDimension.height)
1166  else if (getMaxHeight() < mDimension.height)
1168 
1169  config.setValue(mWindowName + "WinWidth", mDimension.width);
1170  config.setValue(mWindowName + "WinHeight", mDimension.height);
1171  }
1172  }
1173 }
1174 
1175 void Window::setDefaultSize(const int defaultX, const int defaultY,
1176  int defaultWidth, int defaultHeight)
1177 {
1178  if (mMinWinWidth > defaultWidth)
1179  defaultWidth = mMinWinWidth;
1180  else if (mMaxWinWidth < defaultWidth)
1181  defaultWidth = mMaxWinWidth;
1182  if (mMinWinHeight > defaultHeight)
1183  defaultHeight = mMinWinHeight;
1184  else if (mMaxWinHeight < defaultHeight)
1185  defaultHeight = mMaxWinHeight;
1186 
1187  mDefaultX = defaultX;
1188  mDefaultY = defaultY;
1189  mDefaultWidth = defaultWidth;
1190  mDefaultHeight = defaultHeight;
1191 }
1192 
1194 {
1199 }
1200 
1201 void Window::setDefaultSize(const int defaultWidth, const int defaultHeight,
1202  const ImagePosition::Type &position,
1203  const int offsetX, const int offsetY)
1204 {
1205  int x = 0;
1206  int y = 0;
1207 
1208  if (position == ImagePosition::UPPER_LEFT)
1209  {
1210  }
1211  else if (position == ImagePosition::UPPER_CENTER)
1212  {
1213  x = (mainGraphics->mWidth - defaultWidth) / 2;
1214  }
1215  else if (position == ImagePosition::UPPER_RIGHT)
1216  {
1217  x = mainGraphics->mWidth - defaultWidth;
1218  }
1219  else if (position == ImagePosition::LEFT)
1220  {
1221  y = (mainGraphics->mHeight - defaultHeight) / 2;
1222  }
1223  else if (position == ImagePosition::CENTER)
1224  {
1225  x = (mainGraphics->mWidth - defaultWidth) / 2;
1226  y = (mainGraphics->mHeight - defaultHeight) / 2;
1227  }
1228  else if (position == ImagePosition::RIGHT)
1229  {
1230  x = mainGraphics->mWidth - defaultWidth;
1231  y = (mainGraphics->mHeight - defaultHeight) / 2;
1232  }
1233  else if (position == ImagePosition::LOWER_LEFT)
1234  {
1235  y = mainGraphics->mHeight - defaultHeight;
1236  }
1237  else if (position == ImagePosition::LOWER_CENTER)
1238  {
1239  x = (mainGraphics->mWidth - defaultWidth) / 2;
1240  y = mainGraphics->mHeight - defaultHeight;
1241  }
1242  else if (position == ImagePosition::LOWER_RIGHT)
1243  {
1244  x = mainGraphics->mWidth - defaultWidth;
1245  y = mainGraphics->mHeight - defaultHeight;
1246  }
1247 
1248  mDefaultX = x - offsetX;
1249  mDefaultY = y - offsetY;
1250  mDefaultWidth = defaultWidth;
1251  mDefaultHeight = defaultHeight;
1252 }
1253 
1255 {
1258  saveWindowState();
1259 }
1260 
1261 void Window::adjustPositionAfterResize(const int oldScreenWidth,
1262  const int oldScreenHeight)
1263 {
1264  // If window was aligned to the right or bottom, keep it there
1265  const int rightMargin = oldScreenWidth - (mDimension.x + mDimension.width);
1266  const int bottomMargin = oldScreenHeight
1267  - (mDimension.y + mDimension.height);
1268  if (mDimension.x > 0 && mDimension.x > rightMargin)
1269  mDimension.x = mainGraphics->mWidth - rightMargin - mDimension.width;
1270  if (mDimension.y > 0 && mDimension.y > bottomMargin)
1271  {
1273  - bottomMargin - mDimension.height;
1274  }
1275 
1276  ensureOnScreen();
1278 }
1279 
1281 {
1282  if (mGrip == nullptr)
1283  return;
1284 
1285  const int screenWidth = mainGraphics->mWidth;
1286  const int screenHeight = mainGraphics->mHeight;
1287  const int oldWidth = mDimension.width;
1288  const int oldHeight = mDimension.height;
1289  if (oldWidth + mDimension.x > screenWidth)
1290  mDimension.x = 0;
1291  if (oldHeight + mDimension.y > screenHeight)
1292  mDimension.x = 0;
1293  if (mDimension.width > screenWidth)
1294  mDimension.width = screenWidth;
1295  if (mDimension.height > screenHeight)
1296  mDimension.height = screenHeight;
1297  if (oldWidth != mDimension.width || oldHeight != mDimension.height)
1298  widgetResized(Event(this));
1299 }
1300 
1302 {
1303  if (event.getX() < 0 || event.getY() < 0)
1304  return 0;
1305 
1306  int resizeHandles = 0;
1307  const unsigned y = event.getY();
1308  const unsigned x = event.getX();
1309  if (mCloseRect.isPointInRect(x, y))
1310  return CLOSE;
1311 
1312  if (!mStickyButtonLock || !mSticky)
1313  {
1314  if ((mGrip != nullptr) &&
1315  (y > mTitleBarHeight ||
1316  (CAST_S32(y) < mPadding &&
1318  {
1319  if (!getWindowArea().isPointInRect(x, y)
1320  && event.getSource() == this)
1321  {
1322  resizeHandles |= (x > mDimension.width - resizeBorderWidth)
1323  ? RIGHT : (x < resizeBorderWidth) ? LEFT : 0;
1324  resizeHandles |= (y > mDimension.height - resizeBorderWidth)
1325  ? BOTTOM : (y < resizeBorderWidth) ? TOP : 0;
1326  }
1327  if (x >= CAST_U32(mGripRect.x)
1328  && y >= CAST_U32(mGripRect.y))
1329  {
1330  mDragOffsetX = x;
1331  mDragOffsetY = y;
1332  resizeHandles |= BOTTOM | RIGHT;
1333  }
1334  }
1335  }
1336 
1337  return resizeHandles;
1338 }
1339 
1340 bool Window::isResizeAllowed(const MouseEvent &event) const
1341 {
1342  const int y = event.getY();
1343 
1344  if ((mGrip != nullptr) &&
1345  (y > CAST_S32(mTitleBarHeight) ||
1346  y < mPadding))
1347  {
1348  const int x = event.getX();
1349 
1350  if (!getWindowArea().isPointInRect(x, y) && event.getSource() == this)
1351  return true;
1352 
1353  if (x >= mGripRect.x && y >= mGripRect.y)
1354  return true;
1355  }
1356 
1357  return false;
1358 }
1359 
1361 {
1362  if (mLayout == nullptr)
1363  mLayout = new Layout;
1364  return *mLayout;
1365 }
1366 
1368 {
1369  clear();
1370 
1371  // Recreate layout instance when one is present
1372  if (mLayout != nullptr)
1373  {
1374  delete mLayout;
1375  mLayout = new Layout;
1376  }
1377 }
1378 
1379 LayoutCell &Window::place(const int x, const int y, Widget *const wg,
1380  const int w, const int h)
1381 {
1382  add(wg);
1383  return getLayout().place(wg, x, y, w, h);
1384 }
1385 
1386 ContainerPlacer Window::getPlacer(const int x, const int y)
1387 {
1388  return ContainerPlacer(this, &getLayout().at(x, y));
1389 }
1390 
1391 void Window::reflowLayout(int w, int h)
1392 {
1393  if (mLayout == nullptr)
1394  return;
1395 
1396  mLayout->reflow(w, h);
1397  delete2(mLayout);
1398  setContentSize(w, h);
1399 }
1400 
1402 {
1403  if (mLayout != nullptr)
1404  {
1405  const Rect area = getChildrenArea();
1406  int w = area.width;
1407  int h = area.height;
1408  mLayout->reflow(w, h);
1409  }
1410 }
1411 
1413 {
1415 }
1416 
1418 {
1420 }
1421 
1423 {
1424  // Skip when a window hasn't got any size initialized yet
1425  if (mDimension.width == 0 && mDimension.height == 0)
1426  return;
1427 
1428  // Check the left and bottom screen boundaries
1433 
1434  // But never allow the windows to disappear in to the right and top
1435  if (mDimension.x < 0)
1436  mDimension.x = 0;
1437  if (mDimension.y < 0)
1438  mDimension.y = 0;
1439 }
1440 
1442 {
1443  return Rect(mPadding,
1444  mPadding,
1445  mDimension.width - mPadding * 2,
1446  mDimension.height - mPadding * 2);
1447 }
1448 
1449 int Window::getOption(const std::string &name, const int def) const
1450 {
1451  if (mSkin != nullptr)
1452  {
1453  const int val = mSkin->getOption(name);
1454  if (val != 0)
1455  return val;
1456  return def;
1457  }
1458  return def;
1459 }
1460 
1461 bool Window::getOptionBool(const std::string &name, const bool def) const
1462 {
1463  if (mSkin != nullptr)
1464  return mSkin->getOption(name, static_cast<int>(def)) != 0;
1465  return def;
1466 }
1467 
1469 {
1470  return Rect(mPadding,
1472  mDimension.width - mPadding * 2,
1474 }
1475 
1477 {
1478  int w = 0;
1479  int h = 0;
1480  for (WidgetListConstIterator it = mWidgets.begin();
1481  it != mWidgets.end(); ++ it)
1482  {
1483  const Widget *const widget = *it;
1484  const int x = widget->getX();
1485  const int y = widget->getY();
1486  const int width = widget->getWidth();
1487  const int height = widget->getHeight();
1488  if (x + width > w)
1489  w = x + width;
1490 
1491  if (y + height > h)
1492  h = y + height;
1493  }
1494 
1495  setSize(w + 2 * mPadding,
1496  h + mPadding + mTitleBarHeight);
1497 }
1498 
1499 #ifdef USE_PROFILER
1500 void Window::logic()
1501 {
1502  BLOCK_START("Window::logic")
1503  logicChildren();
1504  BLOCK_END("Window::logic")
1505 }
1506 #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:1193
MouseEvent * createMouseEvent(Window *const widget)
Definition: gui.cpp:984
LayoutCell & place(const int x, const int y, Widget *const wg, const int w, const int h)
Definition: window.cpp:1379
Rect mGripRect
Definition: window.h:691
bool isResizable() const
Definition: window.cpp:751
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:925
std::string text
Definition: textchunk.h:64
void redraw()
Definition: window.cpp:1401
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:1280
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:1461
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:525
const bool Visible_true
Definition: visible.h:29
void setMaxWidth(const int width)
Definition: window.cpp:612
void loadWindowState()
Definition: window.cpp:1082
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:1254
static int mouseResize
Definition: window.h:699
Rect getChildrenArea()
Definition: window.cpp:1468
void setVisible(Visible visible)
Definition: widget.cpp:224
void setMaxHeight(const int height)
Definition: window.cpp:617
static Image * getImageFromThemeXml(const std::string &name, const std::string &name2)
Definition: theme.cpp:925
virtual void resizeToContent()
Definition: window.cpp:1476
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:586
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:1417
int getOption(const std::string &name, const int def) const
Definition: window.cpp:1449
PopupManager * popupManager
ImageCollection * mVertexes
Definition: window.h:709
void mouseMoved(MouseEvent &event)
Definition: window.cpp:962
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:1422
virtual void close()
Definition: window.cpp:897
void widgetHidden(const Event &event)
Definition: window.cpp:720
#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:650
#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:761
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:972
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:744
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:1441
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:599
ContainerPlacer getPlacer(const int x, const int y)
Definition: window.cpp:1386
static int windowInstances
Definition: window.h:700
Rect mStickyRect
Definition: window.h:690
virtual void scheduleDelete()
Definition: window.cpp:826
Modal mModal
Definition: window.h:719
bool mPlayVisibleSound
Definition: window.h:726
Layout & getLayout()
Definition: window.cpp:1360
void widgetMoved(const Event &event)
Definition: window.cpp:715
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:902
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:151
static void hideBeingPopup()
virtual void setVisible(Visible visible)
Definition: window.cpp:773
void center()
Definition: window.cpp:1412
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:1160
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:977
void windowRemoved(const Window *const window)
Definition: client.cpp:801
bool isResizeAllowed(const MouseEvent &event) const
Definition: window.cpp:1340
void mouseEntered(MouseEvent &event)
Definition: window.cpp:914
bool mRedraw
Definition: widget.h:1163
void mousePressed(MouseEvent &event)
Definition: window.cpp:831
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:919
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:622
bool isSticky() const
Definition: window.h:252
void setRedraw(const bool n)
Definition: graphics.h:283
void setStickyButtonLock(const bool sticky)
Definition: window.cpp:767
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:360
void setStickyButton(const bool flag)
Definition: window.cpp:756
void deleteImage()
Definition: textchunk.cpp:192
Definition: layout.h:43
Color color2
Definition: textchunk.h:66
void saveWindowState()
Definition: window.cpp:1144
void clearLayout()
Definition: window.cpp:1367
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:1301
int getMinWidth() const
Definition: window.h:204
void setModal(const Modal modal)
Definition: window.cpp:1064
int mMaxWinHeight
Definition: window.h:697
void reflowLayout(int w, int h)
Definition: window.cpp:1391
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:428
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:1261