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-2017 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  skin = "window.xml";
181 
182  int childPalette = 1;
183  // Loads the skin
184  if (theme != nullptr)
185  {
186  mSkin = theme->load(skin, "window.xml");
187  if (mSkin != nullptr)
188  {
190  if (getOptionBool("titlebarBold"))
193  mGripPadding = getOption("resizePadding");
194  mCaptionOffsetX = getOption("captionoffsetx");
195  if (mCaptionOffsetX == 0)
196  mCaptionOffsetX = 7;
197  mCaptionOffsetY = getOption("captionoffsety");
198  if (mCaptionOffsetY == 0)
199  mCaptionOffsetY = 5;
200  mCaptionAlign = static_cast<Graphics::Alignment>(
201  getOption("captionalign"));
204  {
206  }
208  getOption("titlebarHeight")));
209  if (mTitleBarHeight == 0u)
211 
212  mTitleBarHeight += getOption("titlebarHeightRelative");
213  setPalette(getOption("palette"));
214  childPalette = getOption("childPalette");
215  mShowTitle = getOptionBool("showTitle", true);
216  mClosePadding = getOption("closePadding");
217  mStickySpacing = getOption("stickySpacing");
218  mStickyPadding = getOption("stickyPadding");
219  }
220  }
221 
222  // Add this window to the window container
223  if (windowContainer != nullptr)
224  windowContainer->add(this);
225 
226  if (mModal == Modal_true)
227  {
230  }
231 
232  // Windows are invisible by default
233  setVisible(Visible_false, false);
234 
235  addWidgetListener(this);
238  setPalette(childPalette);
239 }
240 
242 {
243  if (mInit)
244  {
245  reportAlways("error: Window created with calling postInit() "
246  "more than once: %s",
247  mWindowName.c_str());
248  }
249  mInit = true;
250 }
251 
253 {
254  logger->log("Window::~Window(\"%s\")", getCaption().c_str());
255 
256  if (gui != nullptr)
257  gui->removeDragged(this);
258 
259 #ifndef DYECMD
260  if (setupWindow != nullptr)
262 #endif // DYECMD
263 
264  client->windowRemoved(this);
265 
266  saveWindowState();
267 
268  delete2(mLayout);
269 
270  while (!mWidgets.empty())
271  delete mWidgets.front();
272 
273  mWidgets.clear();
274 
275  removeWidgetListener(this);
277 
278  windowInstances--;
279 
280  if (mSkin != nullptr)
281  {
282  if (theme != nullptr)
283  theme->unload(mSkin);
284  mSkin = nullptr;
285  }
286  if (mGrip != nullptr)
287  {
288  mGrip->decRef();
289  mGrip = nullptr;
290  }
291  if (!mInit)
292  {
293  reportAlways("error: Window created without calling postInit(): %s",
294  mWindowName.c_str());
295  }
296 }
297 
299 {
300  windowContainer = wc;
301 }
302 
303 void Window::draw(Graphics *const graphics)
304 {
305  if (mSkin == nullptr)
306  return;
307 
308  BLOCK_START("Window::draw")
309  bool update = false;
310 
312  {
313  mRedraw = true;
315  }
316  if (mRedraw)
317  {
318  mLastRedraw = true;
319  mRedraw = false;
320  update = true;
321  mVertexes->clear();
322  graphics->calcWindow(mVertexes,
323  0, 0,
326  mSkin->getBorder());
327 
328  // Draw Close Button
329  if (mCloseWindowButton)
330  {
331  const Image *const button = mSkin->getCloseImage(
332  mResizeHandles == CLOSE);
333  if (button != nullptr)
334  {
335  graphics->calcTileCollection(mVertexes,
336  button,
337  mCloseRect.x,
338  mCloseRect.y);
339  }
340  }
341  // Draw Sticky Button
342  if (mStickyButton)
343  {
344  const Image *const button = mSkin->getStickyImage(mSticky);
345  if (button != nullptr)
346  {
347  graphics->calcTileCollection(mVertexes,
348  button,
349  mStickyRect.x,
350  mStickyRect.y);
351  }
352  }
353 
354  if (mGrip != nullptr)
355  {
356  graphics->calcTileCollection(mVertexes,
357  mGrip,
358  mGripRect.x,
359  mGripRect.y);
360  }
361  graphics->finalize(mVertexes);
362  }
363  else
364  {
365  mLastRedraw = false;
366  }
367  graphics->drawTileCollection(mVertexes);
368 
369  // Draw title
370  if (mShowTitle)
371  {
372  int x;
373  switch (mCaptionAlign)
374  {
375  case Graphics::LEFT:
376  default:
377  x = mCaptionOffsetX;
378  break;
379  case Graphics::CENTER:
381  break;
382  case Graphics::RIGHT:
384  break;
385  }
386  if (mTextChanged)
387  {
394  mTextChanged = false;
395  }
396 
397  const Image *const image = mTextChunk.img;
398  if (image != nullptr)
399  graphics->drawImage(image, x, mCaptionOffsetY);
400  }
401 
402  if (update)
403  {
404  graphics->setRedraw(update);
405  drawChildren(graphics);
406  graphics->setRedraw(false);
407  }
408  else
409  {
410  drawChildren(graphics);
411  }
412  BLOCK_END("Window::draw")
413 }
414 
415 void Window::safeDraw(Graphics *const graphics)
416 {
417  if (mSkin == nullptr)
418  return;
419 
420  BLOCK_START("Window::safeDraw")
421 
422  graphics->drawImageRect(0, 0,
425  mSkin->getBorder());
426 
427  // Draw Close Button
428  if (mCloseWindowButton)
429  {
430  const Image *const button = mSkin->getCloseImage(
431  mResizeHandles == CLOSE);
432  if (button != nullptr)
433  graphics->drawImage(button, mCloseRect.x, mCloseRect.y);
434  }
435  // Draw Sticky Button
436  if (mStickyButton)
437  {
438  const Image *const button = mSkin->getStickyImage(mSticky);
439  if (button != nullptr)
440  graphics->drawImage(button, mStickyRect.x, mStickyRect.y);
441  }
442 
443  if (mGrip != nullptr)
444  graphics->drawImage(mGrip, mGripRect.x, mGripRect.y);
445 
446  // Draw title
447  if (mShowTitle)
448  {
449  int x;
450  switch (mCaptionAlign)
451  {
452  case Graphics::LEFT:
453  default:
454  x = mCaptionOffsetX;
455  break;
456  case Graphics::CENTER:
458  break;
459  case Graphics::RIGHT:
461  break;
462  }
463  if (mTextChanged)
464  {
471  mTextChanged = false;
472  }
473 
474  const Image *const image = mTextChunk.img;
475  if (image != nullptr)
476  graphics->drawImage(image, x, mCaptionOffsetY);
477  }
478 
479  safeDrawChildren(graphics);
480 
481  BLOCK_END("Window::safeDraw")
482 }
483 
484 void Window::setContentSize(int width, int height)
485 {
486  width = width + 2 * mPadding;
487  height = height + mPadding + mTitleBarHeight;
488 
489  if (mMinWinWidth > width)
490  width = mMinWinWidth;
491  else if (mMaxWinWidth < width)
492  width = mMaxWinWidth;
493  if (mMinWinHeight > height)
494  height = mMinWinHeight;
495  else if (mMaxWinHeight < height)
496  height = mMaxWinHeight;
497 
498  setSize(width, height);
499 }
500 
501 void Window::setLocationRelativeTo(const Widget *const widget)
502 {
503  if (widget == nullptr)
504  return;
505 
506  int wx, wy;
507  int x, y;
508 
509  widget->getAbsolutePosition(wx, wy);
510  getAbsolutePosition(x, y);
511 
512  setPosition(mDimension.x + (wx + (widget->getWidth()
513  - mDimension.width) / 2 - x),
514  mDimension.y + (wy + (widget->getHeight()
515  - mDimension.height) / 2 - y));
516 }
517 
519 {
520  if (widget == nullptr)
521  return;
522 
523  int wx, wy;
524  int x, y;
525 
526  widget->getAbsolutePosition(wx, wy);
527  getAbsolutePosition(x, y);
528 
529  setPosition(mDimension.x + (wx + (widget->getWidth()
530  - mDimension.width) / 2 - x), 0);
531 }
532 
534  int offsetX, int offsetY)
535 {
536  if (position == ImagePosition::UPPER_LEFT)
537  {
538  }
539  else if (position == ImagePosition::UPPER_CENTER)
540  {
541  offsetX += (mainGraphics->mWidth - mDimension.width) / 2;
542  }
543  else if (position == ImagePosition::UPPER_RIGHT)
544  {
545  offsetX += mainGraphics->mWidth - mDimension.width;
546  }
547  else if (position == ImagePosition::LEFT)
548  {
549  offsetY += (mainGraphics->mHeight - mDimension.height) / 2;
550  }
551  else if (position == ImagePosition::CENTER)
552  {
553  offsetX += (mainGraphics->mWidth - mDimension.width) / 2;
554  offsetY += (mainGraphics->mHeight - mDimension.height) / 2;
555  }
556  else if (position == ImagePosition::RIGHT)
557  {
558  offsetX += mainGraphics->mWidth - mDimension.width;
559  offsetY += (mainGraphics->mHeight - mDimension.height) / 2;
560  }
561  else if (position == ImagePosition::LOWER_LEFT)
562  {
563  offsetY += mainGraphics->mHeight - mDimension.height;
564  }
565  else if (position == ImagePosition::LOWER_CENTER)
566  {
567  offsetX += (mainGraphics->mWidth - mDimension.width) / 2;
568  offsetY += mainGraphics->mHeight - mDimension.height;
569  }
570  else if (position == ImagePosition::LOWER_RIGHT)
571  {
572  offsetX += mainGraphics->mWidth - mDimension.width;
573  offsetY += mainGraphics->mHeight - mDimension.height;
574  }
575 
576  setPosition(offsetX, offsetY);
577 }
578 
579 void Window::setMinWidth(const int width)
580 {
581  if (mSkin != nullptr)
582  {
583  mMinWinWidth = width > mSkin->getMinWidth()
584  ? width : mSkin->getMinWidth();
585  }
586  else
587  {
588  mMinWinWidth = width;
589  }
590 }
591 
592 void Window::setMinHeight(const int height)
593 {
594  if (mSkin != nullptr)
595  {
596  mMinWinHeight = height > mSkin->getMinHeight()
597  ? height : mSkin->getMinHeight();
598  }
599  else
600  {
601  mMinWinHeight = height;
602  }
603 }
604 
605 void Window::setMaxWidth(const int width)
606 {
607  mMaxWinWidth = width;
608 }
609 
610 void Window::setMaxHeight(const int height)
611 {
612  mMaxWinHeight = height;
613 }
614 
615 void Window::setResizable(const bool r)
616 {
617  if ((mGrip != nullptr) == r)
618  return;
619 
620  if (mGrip != nullptr)
621  mGrip->decRef();
622  if (r)
623  {
624  mGrip = Theme::getImageFromThemeXml("resize.xml", "");
625  if (mGrip != nullptr)
626  {
629  - mGripPadding;
630  }
631  else
632  {
633  mGripRect.x = 0;
634  mGripRect.y = 0;
635  }
636  }
637  else
638  {
639  mGrip = nullptr;
640  }
641 }
642 
644 {
645  if (mGrip != nullptr)
646  {
649  }
650 
651  if (mLayout != nullptr)
652  {
653  const Rect area = getChildrenArea();
654  int w = area.width;
655  int h = area.height;
656  mLayout->reflow(w, h);
657  }
658  if (mSkin != nullptr)
659  {
660  const bool showClose = mCloseWindowButton
661  && (mSkin->getCloseImage(false) != nullptr);
662  if (showClose)
663  {
664  const Image *const button = mSkin->getCloseImage(false);
665  if (button != nullptr)
666  {
667  const int buttonWidth = button->getWidth();
668  mCloseRect.x = mDimension.width - buttonWidth - mClosePadding;
671  mCloseRect.height = button->getHeight();
672  }
673  }
674  if (mStickyButton)
675  {
676  const Image *const button = mSkin->getStickyImage(mSticky);
677  if (button != nullptr)
678  {
679  const int buttonWidth = button->getWidth();
680  int x = mDimension.width - buttonWidth
682 
683  if (showClose)
684  x -= mSkin->getCloseImage(false)->getWidth();
685 
686  mStickyRect.x = x;
689  mStickyRect.height = button->getHeight();
690  }
691  }
692  }
693  else
694  {
695  mCloseRect.x = 0;
696  mCloseRect.y = 0;
697  mCloseRect.width = 0;
698  mCloseRect.height = 0;
699  mStickyRect.x = 0;
700  mStickyRect.y = 0;
701  mStickyRect.width = 0;
702  mStickyRect.height = 0;
703  }
704 
705  mRedraw = true;
706 }
707 
709 {
710  mRedraw = true;
711 }
712 
714 {
716  mVertexes->clear();
717 
719 
720  mTextChanged = true;
721  mRedraw = true;
722 
723  if (gui != nullptr)
725 
726  if (mFocusHandler == nullptr)
727  return;
728 
729  for (WidgetListConstIterator it = mWidgets.begin();
730  it != mWidgets.end(); ++ it)
731  {
732  if (mFocusHandler->isFocused(*it))
734  }
735 }
736 
737 void Window::setCloseButton(const bool flag)
738 {
739  mCloseWindowButton = flag;
740  if (flag)
741  mAllowClose = true;
742 }
743 
745 {
746  return mGrip != nullptr;
747 }
748 
749 void Window::setStickyButton(const bool flag)
750 {
751  mStickyButton = flag;
752 }
753 
754 void Window::setSticky(const bool sticky)
755 {
756  mSticky = sticky;
757  mRedraw = true;
758 }
759 
760 void Window::setStickyButtonLock(const bool lock)
761 {
762  mStickyButtonLock = lock;
763  mStickyButton = lock;
764 }
765 
767 {
768  setVisible(visible, false);
769 }
770 
771 void Window::setVisible(const Visible visible, const bool forceSticky)
772 {
773  if (visible == mVisible)
774  return;
775 
776  // Check if the window is off screen...
777  if (visible == Visible_true)
778  ensureOnScreen();
779  else
780  mResizeHandles = 0;
781 
782  if (mStickyButtonLock)
783  {
785  }
786  else
787  {
788  BasicContainer2::setVisible(fromBool((!forceSticky && mSticky) ||
789  visible == Visible_true, Visible));
790  }
791  if (visible == Visible_true)
792  {
793  if (mPlayVisibleSound)
795  if (gui != nullptr)
796  {
797  MouseEvent *const event = reinterpret_cast<MouseEvent*>(
798  gui->createMouseEvent(this));
799  if (event != nullptr)
800  {
801  const int x = event->getX();
802  const int y = event->getY();
803  if (x >= 0 && x <= mDimension.width
804  && y >= 0 && y <= mDimension.height)
805  {
806  mouseMoved(*event);
807  }
808  delete event;
809  }
810  }
811  }
812  else
813  {
814  if (mPlayVisibleSound)
816  }
817 }
818 
820 {
822 }
823 
825 {
826  if (event.isConsumed())
827  return;
828 
829  if (event.getSource() == this)
830  {
831  if (getParent() != nullptr)
832  getParent()->moveToTop(this);
833 
834  mDragOffsetX = event.getX();
835  mDragOffsetY = event.getY();
836  mMoved = event.getY() <= CAST_S32(mTitleBarHeight);
837  }
838 
839  const MouseButtonT button = event.getButton();
840  if (button == MouseButton::LEFT)
841  {
842  const int x = event.getX();
843  const int y = event.getY();
844 
845  // Handle close button
846  if (mCloseWindowButton &&
847  mSkin != nullptr &&
849  {
850  mouseResize = 0;
851  mMoved = false;
852  event.consume();
853  close();
854  return;
855  }
856 
857  // Handle sticky button
858  if (mStickyButton &&
859  mSkin != nullptr &&
861  {
862  setSticky(!isSticky());
863  mouseResize = 0;
864  mMoved = false;
865  event.consume();
866  return;
867  }
868 
869  // Handle window resizing
871  if (mouseResize != 0)
872  event.consume();
873  if (canMove())
874  mMoved = (mouseResize == 0);
875  else
876  mMoved = false;
877  }
878 #ifndef DYECMD
879  else if (button == MouseButton::RIGHT)
880  {
881  if (popupMenu != nullptr)
882  {
883  event.consume();
884  popupMenu->showWindowPopup(this);
885  }
886  }
887 #endif // DYECMD
888 }
889 
891 {
893 }
894 
896 {
897  if ((mGrip != nullptr) && (mouseResize != 0))
898  {
899  mouseResize = 0;
900  if (gui != nullptr)
902  }
903 
904  mMoved = false;
905 }
906 
908 {
909  updateResizeHandler(event);
910 }
911 
913 {
914  if ((mGrip != nullptr) && (mouseResize == 0) && (gui != nullptr))
916 }
917 
919 {
920  if (gui == nullptr)
921  return;
922 
923 #ifndef DYECMD
924  if (!dragDrop.isEmpty())
925  return;
926 #endif // DYECMD
927 
929 
930  // Changes the custom mouse cursor based on it's current position.
931  switch (mResizeHandles & resizeMask)
932  {
933  case BOTTOM | RIGHT:
934  case TOP | LEFT:
936  break;
937  case TOP | RIGHT:
938  case BOTTOM | LEFT:
940  break;
941  case BOTTOM:
942  case TOP:
944  break;
945  case RIGHT:
946  case LEFT:
948  break;
949  default:
951  break;
952  }
953 }
954 
956 {
957  updateResizeHandler(event);
958  if ((popupManager != nullptr) && !event.isConsumed())
959  {
962  }
963 }
964 
965 bool Window::canMove() const
966 {
967  return !mStickyButtonLock || !mSticky;
968 }
969 
971 {
972  if (canMove())
973  {
974  if (!event.isConsumed() && event.getSource() == this)
975  {
976  if (isMovable() && mMoved)
977  {
978  setPosition(event.getX() - mDragOffsetX + getX(),
979  event.getY() - mDragOffsetY + getY());
980  }
981 
982  event.consume();
983  }
984  }
985  else
986  {
987  if (!event.isConsumed() && event.getSource() == this)
988  event.consume();
989  return;
990  }
991 
992  // Keep guichan window inside screen when it may be moved
993  if (isMovable() && mMoved)
994  {
996  std::max(0, mDimension.x)),
998  std::max(0, mDimension.y)));
999  }
1000 
1001  if ((mouseResize != 0) && !mMoved)
1002  {
1003  const int dx = event.getX() - mDragOffsetX;
1004  const int dy = event.getY() - mDragOffsetY;
1005  Rect newDim = getDimension();
1006 
1007  if ((mouseResize & (TOP | BOTTOM)) != 0)
1008  {
1009  const int newHeight = newDim.height
1010  + ((mouseResize & TOP) != 0 ? -dy : dy);
1011  newDim.height = std::min(mMaxWinHeight,
1012  std::max(mMinWinHeight, newHeight));
1013 
1014  if ((mouseResize & TOP) != 0)
1015  newDim.y -= newDim.height - getHeight();
1016  }
1017 
1018  if ((mouseResize & (LEFT | RIGHT)) != 0)
1019  {
1020  const int newWidth = newDim.width
1021  + ((mouseResize & LEFT) != 0 ? -dx : dx);
1022  newDim.width = std::min(mMaxWinWidth,
1023  std::max(mMinWinWidth, newWidth));
1024 
1025  if ((mouseResize & LEFT) != 0)
1026  newDim.x -= newDim.width - mDimension.width;
1027  }
1028 
1029  // Keep guichan window inside screen (supports resizing any side)
1030  if (newDim.x < 0)
1031  {
1032  newDim.width += newDim.x;
1033  newDim.x = 0;
1034  }
1035  if (newDim.y < 0)
1036  {
1037  newDim.height += newDim.y;
1038  newDim.y = 0;
1039  }
1040  if (newDim.x + newDim.width > mainGraphics->mWidth)
1041  newDim.width = mainGraphics->mWidth - newDim.x;
1042  if (newDim.y + newDim.height > mainGraphics->mHeight)
1043  newDim.height = mainGraphics->mHeight - newDim.y;
1044 
1045  // Update mouse offset when dragging bottom or right border
1046  if ((mouseResize & BOTTOM) != 0)
1047  mDragOffsetY += newDim.height - mDimension.height;
1048 
1049  if ((mouseResize & RIGHT) != 0)
1050  mDragOffsetX += newDim.width - mDimension.width;
1051 
1052  // Set the new window and content dimensions
1053  setDimension(newDim);
1054  }
1055 }
1056 
1057 void Window::setModal(const Modal modal)
1058 {
1059  if (mModal != modal)
1060  {
1061  mModal = modal;
1062  if (mModal == Modal_true)
1063  {
1064  if (gui != nullptr)
1067  }
1068  else
1069  {
1071  }
1072  }
1073 }
1074 
1076 {
1077  const std::string &name = mWindowName;
1078  if (name.empty())
1079  return;
1080 
1081  setPosition(config.getValueInt(name + "WinX", mDefaultX),
1082  config.getValueInt(name + "WinY", mDefaultY));
1083 
1084  if (mSaveVisible)
1085  {
1087  + "Visible", mDefaultVisible), Visible));
1088  }
1089 
1090  if (mStickyButton)
1091  {
1093  + "Sticky", isSticky()));
1094  }
1095 
1096  if (mGrip != nullptr)
1097  {
1098  int width = config.getValueInt(name + "WinWidth", mDefaultWidth);
1099  int height = config.getValueInt(name + "WinHeight", mDefaultHeight);
1100 
1101  if (getMinWidth() > width)
1102  width = getMinWidth();
1103  else if (getMaxWidth() < width)
1104  width = getMaxWidth();
1105  if (getMinHeight() > height)
1106  height = getMinHeight();
1107  else if (getMaxHeight() < height)
1108  height = getMaxHeight();
1109 
1110  setSize(width, height);
1111  }
1112  else
1113  {
1115  }
1116 
1117  // Check if the window is off screen...
1118  ensureOnScreen();
1119 
1120  if (viewport != nullptr)
1121  {
1122  int width = mDimension.width;
1123  int height = mDimension.height;
1124 
1125  if (mDimension.x + width > viewport->getWidth())
1126  width = viewport->getWidth() - mDimension.x;
1127  if (mDimension.y + height > viewport->getHeight())
1128  height = viewport->getHeight() - mDimension.y;
1129  if (width < 0)
1130  width = 0;
1131  if (height < 0)
1132  height = 0;
1133  setSize(width, height);
1134  }
1135 }
1136 
1138 {
1139  // Saving X, Y and Width and Height for resizables in the config
1140  if (!mWindowName.empty() && mWindowName != "window")
1141  {
1142  config.setValue(mWindowName + "WinX", mDimension.x);
1143  config.setValue(mWindowName + "WinY", mDimension.y);
1144 
1145  if (mSaveVisible)
1146  config.setValue(mWindowName + "Visible", isWindowVisible());
1147 
1148  if (mStickyButton)
1149  config.setValue(mWindowName + "Sticky", isSticky());
1150 
1151  if (mGrip != nullptr)
1152  {
1153  if (getMinWidth() > mDimension.width)
1154  setWidth(getMinWidth());
1155  else if (getMaxWidth() < mDimension.width)
1156  setWidth(getMaxWidth());
1157  if (getMinHeight() > mDimension.height)
1159  else if (getMaxHeight() < mDimension.height)
1161 
1162  config.setValue(mWindowName + "WinWidth", mDimension.width);
1163  config.setValue(mWindowName + "WinHeight", mDimension.height);
1164  }
1165  }
1166 }
1167 
1168 void Window::setDefaultSize(const int defaultX, const int defaultY,
1169  int defaultWidth, int defaultHeight)
1170 {
1171  if (mMinWinWidth > defaultWidth)
1172  defaultWidth = mMinWinWidth;
1173  else if (mMaxWinWidth < defaultWidth)
1174  defaultWidth = mMaxWinWidth;
1175  if (mMinWinHeight > defaultHeight)
1176  defaultHeight = mMinWinHeight;
1177  else if (mMaxWinHeight < defaultHeight)
1178  defaultHeight = mMaxWinHeight;
1179 
1180  mDefaultX = defaultX;
1181  mDefaultY = defaultY;
1182  mDefaultWidth = defaultWidth;
1183  mDefaultHeight = defaultHeight;
1184 }
1185 
1187 {
1192 }
1193 
1194 void Window::setDefaultSize(const int defaultWidth, const int defaultHeight,
1195  const ImagePosition::Type &position,
1196  const int offsetX, const int offsetY)
1197 {
1198  int x = 0;
1199  int y = 0;
1200 
1201  if (position == ImagePosition::UPPER_LEFT)
1202  {
1203  }
1204  else if (position == ImagePosition::UPPER_CENTER)
1205  {
1206  x = (mainGraphics->mWidth - defaultWidth) / 2;
1207  }
1208  else if (position == ImagePosition::UPPER_RIGHT)
1209  {
1210  x = mainGraphics->mWidth - defaultWidth;
1211  }
1212  else if (position == ImagePosition::LEFT)
1213  {
1214  y = (mainGraphics->mHeight - defaultHeight) / 2;
1215  }
1216  else if (position == ImagePosition::CENTER)
1217  {
1218  x = (mainGraphics->mWidth - defaultWidth) / 2;
1219  y = (mainGraphics->mHeight - defaultHeight) / 2;
1220  }
1221  else if (position == ImagePosition::RIGHT)
1222  {
1223  x = mainGraphics->mWidth - defaultWidth;
1224  y = (mainGraphics->mHeight - defaultHeight) / 2;
1225  }
1226  else if (position == ImagePosition::LOWER_LEFT)
1227  {
1228  y = mainGraphics->mHeight - defaultHeight;
1229  }
1230  else if (position == ImagePosition::LOWER_CENTER)
1231  {
1232  x = (mainGraphics->mWidth - defaultWidth) / 2;
1233  y = mainGraphics->mHeight - defaultHeight;
1234  }
1235  else if (position == ImagePosition::LOWER_RIGHT)
1236  {
1237  x = mainGraphics->mWidth - defaultWidth;
1238  y = mainGraphics->mHeight - defaultHeight;
1239  }
1240 
1241  mDefaultX = x - offsetX;
1242  mDefaultY = y - offsetY;
1243  mDefaultWidth = defaultWidth;
1244  mDefaultHeight = defaultHeight;
1245 }
1246 
1248 {
1251  saveWindowState();
1252 }
1253 
1254 void Window::adjustPositionAfterResize(const int oldScreenWidth,
1255  const int oldScreenHeight)
1256 {
1257  // If window was aligned to the right or bottom, keep it there
1258  const int rightMargin = oldScreenWidth - (mDimension.x + mDimension.width);
1259  const int bottomMargin = oldScreenHeight
1260  - (mDimension.y + mDimension.height);
1261  if (mDimension.x > 0 && mDimension.x > rightMargin)
1262  mDimension.x = mainGraphics->mWidth - rightMargin - mDimension.width;
1263  if (mDimension.y > 0 && mDimension.y > bottomMargin)
1264  {
1266  - bottomMargin - mDimension.height;
1267  }
1268 
1269  ensureOnScreen();
1271 }
1272 
1274 {
1275  if (mGrip == nullptr)
1276  return;
1277 
1278  const int screenWidth = mainGraphics->mWidth;
1279  const int screenHeight = mainGraphics->mHeight;
1280  const int oldWidth = mDimension.width;
1281  const int oldHeight = mDimension.height;
1282  if (oldWidth + mDimension.x > screenWidth)
1283  mDimension.x = 0;
1284  if (oldHeight + mDimension.y > screenHeight)
1285  mDimension.x = 0;
1286  if (mDimension.width > screenWidth)
1287  mDimension.width = screenWidth;
1288  if (mDimension.height > screenHeight)
1289  mDimension.height = screenHeight;
1290  if (oldWidth != mDimension.width || oldHeight != mDimension.height)
1291  widgetResized(Event(this));
1292 }
1293 
1295 {
1296  if (event.getX() < 0 || event.getY() < 0)
1297  return 0;
1298 
1299  int resizeHandles = 0;
1300  const unsigned y = event.getY();
1301  const unsigned x = event.getX();
1302  if (mCloseRect.isPointInRect(x, y))
1303  return CLOSE;
1304 
1305  if (!mStickyButtonLock || !mSticky)
1306  {
1307  if ((mGrip != nullptr) &&
1308  (y > mTitleBarHeight ||
1309  (CAST_S32(y) < mPadding &&
1311  {
1312  if (!getWindowArea().isPointInRect(x, y)
1313  && event.getSource() == this)
1314  {
1315  resizeHandles |= (x > mDimension.width - resizeBorderWidth)
1316  ? RIGHT : (x < resizeBorderWidth) ? LEFT : 0;
1317  resizeHandles |= (y > mDimension.height - resizeBorderWidth)
1318  ? BOTTOM : (y < resizeBorderWidth) ? TOP : 0;
1319  }
1320  if (x >= CAST_U32(mGripRect.x)
1321  && y >= CAST_U32(mGripRect.y))
1322  {
1323  mDragOffsetX = x;
1324  mDragOffsetY = y;
1325  resizeHandles |= BOTTOM | RIGHT;
1326  }
1327  }
1328  }
1329 
1330  return resizeHandles;
1331 }
1332 
1333 bool Window::isResizeAllowed(const MouseEvent &event) const
1334 {
1335  const int y = event.getY();
1336 
1337  if ((mGrip != nullptr) &&
1338  (y > CAST_S32(mTitleBarHeight) ||
1339  y < mPadding))
1340  {
1341  const int x = event.getX();
1342 
1343  if (!getWindowArea().isPointInRect(x, y) && event.getSource() == this)
1344  return true;
1345 
1346  if (x >= mGripRect.x && y >= mGripRect.y)
1347  return true;
1348  }
1349 
1350  return false;
1351 }
1352 
1354 {
1355  if (mLayout == nullptr)
1356  mLayout = new Layout;
1357  return *mLayout;
1358 }
1359 
1361 {
1362  clear();
1363 
1364  // Recreate layout instance when one is present
1365  if (mLayout != nullptr)
1366  {
1367  delete mLayout;
1368  mLayout = new Layout;
1369  }
1370 }
1371 
1372 LayoutCell &Window::place(const int x, const int y, Widget *const wg,
1373  const int w, const int h)
1374 {
1375  add(wg);
1376  return getLayout().place(wg, x, y, w, h);
1377 }
1378 
1379 ContainerPlacer Window::getPlacer(const int x, const int y)
1380 {
1381  return ContainerPlacer(this, &getLayout().at(x, y));
1382 }
1383 
1384 void Window::reflowLayout(int w, int h)
1385 {
1386  if (mLayout == nullptr)
1387  return;
1388 
1389  mLayout->reflow(w, h);
1390  delete2(mLayout);
1391  setContentSize(w, h);
1392 }
1393 
1395 {
1396  if (mLayout != nullptr)
1397  {
1398  const Rect area = getChildrenArea();
1399  int w = area.width;
1400  int h = area.height;
1401  mLayout->reflow(w, h);
1402  }
1403 }
1404 
1406 {
1408 }
1409 
1411 {
1413 }
1414 
1416 {
1417  // Skip when a window hasn't got any size initialized yet
1418  if (mDimension.width == 0 && mDimension.height == 0)
1419  return;
1420 
1421  // Check the left and bottom screen boundaries
1426 
1427  // But never allow the windows to disappear in to the right and top
1428  if (mDimension.x < 0)
1429  mDimension.x = 0;
1430  if (mDimension.y < 0)
1431  mDimension.y = 0;
1432 }
1433 
1435 {
1436  return Rect(mPadding,
1437  mPadding,
1438  mDimension.width - mPadding * 2,
1439  mDimension.height - mPadding * 2);
1440 }
1441 
1442 int Window::getOption(const std::string &name, const int def) const
1443 {
1444  if (mSkin != nullptr)
1445  {
1446  const int val = mSkin->getOption(name);
1447  if (val != 0)
1448  return val;
1449  return def;
1450  }
1451  return def;
1452 }
1453 
1454 bool Window::getOptionBool(const std::string &name, const bool def) const
1455 {
1456  if (mSkin != nullptr)
1457  return mSkin->getOption(name, static_cast<int>(def)) != 0;
1458  return def;
1459 }
1460 
1462 {
1463  return Rect(mPadding,
1465  mDimension.width - mPadding * 2,
1467 }
1468 
1470 {
1471  int w = 0;
1472  int h = 0;
1473  for (WidgetListConstIterator it = mWidgets.begin();
1474  it != mWidgets.end(); ++ it)
1475  {
1476  const Widget *const widget = *it;
1477  const int x = widget->getX();
1478  const int y = widget->getY();
1479  const int width = widget->getWidth();
1480  const int height = widget->getHeight();
1481  if (x + width > w)
1482  w = x + width;
1483 
1484  if (y + height > h)
1485  h = y + height;
1486  }
1487 
1488  setSize(w + 2 * mPadding,
1489  h + mPadding + mTitleBarHeight);
1490 }
1491 
1492 #ifdef USE_PROFILER
1493 void Window::logic()
1494 {
1495  BLOCK_START("Window::logic")
1496  logicChildren();
1497  BLOCK_END("Window::logic")
1498 }
1499 #endif // USE_PROFILER
bool mShowTitle
Definition: window.h:648
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:1186
MouseEvent * createMouseEvent(Window *const widget)
Definition: gui.cpp:974
Rect mGripRect
Definition: window.h:684
bool isResizable() const
Definition: window.cpp:744
static const std::string SOUND_HIDE_WINDOW
Definition: sound.h:35
int getMinHeight() const
Definition: skin.cpp:141
std::string mWindowName
Definition: window.h:686
int width
Definition: rect.h:218
void updateResizeHandler(MouseEvent &event)
Definition: window.cpp:918
std::string text
Definition: textchunk.h:64
void redraw()
Definition: window.cpp:1394
Font * mCaptionFont
Definition: window.h:711
int getWidth() const
Definition: widget.h:220
Skin * mSkin
Definition: window.h:641
Font * boldFont
Definition: gui.cpp:111
TextChunk mTextChunk
Definition: window.h:685
void adjustSizeToScreen()
Definition: window.cpp:1273
int mGripPadding
Definition: window.h:705
int mDragOffsetY
Definition: window.h:634
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
void scheduleDelete(Widget *const widget)
int mPadding
Definition: window.h:610
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:518
const bool Visible_true
Definition: visible.h:29
const Color & getThemeColor(const ThemeColorIdT type, const unsigned int alpha=255U) const A_INLINE
Definition: widget2.h:44
void setMaxWidth(const int width)
Definition: window.cpp:605
void loadWindowState()
Definition: window.cpp:1075
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:1247
static int mouseResize
Definition: window.h:692
Rect getChildrenArea()
Definition: window.cpp:1461
void setVisible(Visible visible)
Definition: widget.cpp:224
void setMaxHeight(const int height)
Definition: window.cpp:610
static Image * getImageFromThemeXml(const std::string &name, const std::string &name2)
Definition: theme.cpp:1129
virtual void resizeToContent()
Definition: window.cpp:1469
int mOldResizeHandles
Definition: window.h:707
bool mTextChanged
Definition: window.h:721
bool mStickyButtonLock
Definition: window.h:718
int mCaptionOffsetY
Definition: window.h:647
Definition: rect.h:72
void reflow(int &nW, int &nH)
Definition: layout.cpp:35
void setMinWidth(const int width)
Definition: window.cpp:579
Definition: window.h:98
int mWidth
Definition: graphics.h:483
int mStickySpacing
Definition: window.h:709
#define BLOCK_START(name)
Definition: perfomance.h:78
SoundManager soundManager
Configuration config
bool isFocused(const Widget *const widget) const
bool isPointInRect(const int x_, const int y_) const
Definition: rect.h:196
bool mDefaultVisible
Definition: window.h:714
void setDimension(const Rect &dimension)
Definition: widget.cpp:168
void centerHorisontally()
Definition: window.cpp:1410
PopupManager * popupManager
ImageCollection * mVertexes
Definition: window.h:702
void mouseMoved(MouseEvent &event)
Definition: window.cpp:955
Rect mCloseRect
Definition: window.h:682
bool mStickyButton
Definition: window.h:716
DragDrop dragDrop
bool getOptionBool(const std::string &name, const bool def=false) const
Definition: window.cpp:1454
#define BLOCK_END(name)
Definition: perfomance.h:79
RenderType openGLMode
FocusHandler * mFocusHandler
Definition: widget.h:1115
bool mMoved
Definition: window.h:639
Client * client
Definition: client.cpp:113
#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:646
Font * textFont
Definition: textchunk.h:63
int mDragOffsetX
Definition: window.h:627
int getOption(const std::string &name) const
Definition: skin.h:105
virtual void clear()
bool isMovable() const
Definition: window.h:568
int mMaxWinWidth
Definition: window.h:689
Logger * logger
Definition: logger.cpp:95
void reflowLayout(int w=0, int h=0)
Definition: window.cpp:1384
int mDefaultY
Definition: window.h:643
virtual void finalize(ImageCollection *const col)
Definition: graphics.h:464
Visible mVisible
Definition: widget.h:962
void ensureOnScreen()
Definition: window.cpp:1415
virtual void close()
Definition: window.cpp:890
void widgetHidden(const Event &event)
Definition: window.cpp:713
#define new
Definition: debug_new.h:147
void setContentSize(int width, int height)
Definition: window.cpp:484
bool mAllowClose
Definition: window.h:722
int getMinHeight() const
Definition: window.h:211
int x
Definition: rect.h:208
int getPadding() const
Definition: skin.h:99
void widgetResized(const Event &event)
Definition: window.cpp:643
#define CAST_S32
Definition: cast.h:29
LayoutCell & place(Widget *const wg, const int x, const int y, const int w=1, const int h=1)
Definition: layoutcell.cpp:110
static void hideTextPopup()
const ImageRect & getBorder() const
Definition: skin.h:67
int mTitlePadding
Definition: window.h:704
void setSticky(const bool sticky)
Definition: window.cpp:754
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:303
bool canMove() const
Definition: window.cpp:965
Widget * getSource() const
Definition: event.h:103
LayoutCell & place(const int x, const int y, Widget *const wg, const int w=1, const int h=1)
Definition: window.cpp:1372
int mDefaultWidth
Definition: window.h:644
bool mLastRedraw
Definition: window.h:649
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:710
bool mInit
Definition: window.h:720
Graphics::Alignment mCaptionAlign
Definition: window.h:703
#define nullptr
Definition: localconsts.h:44
Graphics * mainGraphics
Definition: graphics.cpp:108
static const unsigned resizeBorderWidth
Definition: window.h:701
bool isWindowVisible() const
Definition: window.h:476
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:708
void addMouseListener(MouseListener *const mouseListener)
Definition: widget.cpp:291
virtual ~Window()
Definition: window.cpp:252
void setPosition(const int x, const int y)
Definition: widget.cpp:160
void setCloseButton(const bool flag)
Definition: window.cpp:737
int height
Definition: rect.h:223
bool mCloseWindowButton
Definition: window.h:713
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:1434
bool isConsumed() const
int mResizeHandles
Definition: window.h:706
const Rect & getDimension() const
Definition: widget.h:316
bool mSticky
Definition: window.h:717
const bool Move_true
Definition: move.h:29
void setMinHeight(const int height)
Definition: window.cpp:592
ContainerPlacer getPlacer(const int x, const int y)
Definition: window.cpp:1379
static int windowInstances
Definition: window.h:693
Rect mStickyRect
Definition: window.h:683
virtual void scheduleDelete()
Definition: window.cpp:819
Modal mModal
Definition: window.h:712
bool mPlayVisibleSound
Definition: window.h:719
Layout & getLayout()
Definition: window.cpp:1353
void widgetMoved(const Event &event)
Definition: window.cpp:708
int getMaxHeight() const
Definition: window.h:227
virtual void moveToTop(Widget *widget)
Definition: widget.h:866
std::string mCaption
Definition: window.h:600
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:895
Skin * load(const std::string &filename, const std::string &filename2, const bool full=true, const std::string &defaultPath=getThemePath())
Definition: theme.cpp:178
bool mSaveVisible
Definition: window.h:715
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:171
static void hideBeingPopup()
virtual void setVisible(Visible visible)
Definition: window.cpp:766
void center()
Definition: window.cpp:1405
static const std::string SOUND_SHOW_WINDOW
Definition: sound.h:34
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:1144
Definition: widget.h:97
int mDefaultHeight
Definition: window.h:645
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:219
int mDefaultX
Definition: window.h:642
void mouseDragged(MouseEvent &event)
Definition: window.cpp:970
void windowRemoved(const Window *const window)
Definition: client.cpp:781
bool isResizeAllowed(const MouseEvent &event) const
Definition: window.cpp:1333
void mouseEntered(MouseEvent &event)
Definition: window.cpp:907
bool mRedraw
Definition: widget.h:1163
void mousePressed(MouseEvent &event)
Definition: window.cpp:824
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:912
Color color
Definition: textchunk.h:65
Layout * mLayout
Definition: window.h:681
int getWidth() const A_INLINE
Definition: image.h:116
WidgetList mWidgets
void setResizable(const bool resize)
Definition: window.cpp:615
bool isSticky() const
Definition: window.h:251
void setRedraw(const bool n)
Definition: graphics.h:283
void setStickyButtonLock(const bool sticky)
Definition: window.cpp:760
int getX() const
Definition: mouseevent.h:124
void unregisterWindowForReset(const Window *const window)
void showWindowPopup(Window *const window)
Definition: popupmenu.cpp:1153
static void setWindowContainer(WindowContainer *const windowContainer)
Definition: window.cpp:298
SetupWindow * setupWindow
Definition: setupwindow.cpp:63
int getOption(const std::string &name, const int def=0) const
Definition: window.cpp:1442
void setPadding(int padding)
Definition: window.h:486
void log(const char *const log_text,...)
Definition: logger.cpp:243
void setTitleBarHeight(unsigned int height)
Definition: window.h:505
int getValueInt(const std::string &key, const int deflt) const
Window(const std::string &caption="Window", const Modal modal=Modal_false, Window *const parent=0, std::string skin="")
Definition: window.cpp:108
int getHeight() const
Definition: font.cpp:360
void setStickyButton(const bool flag)
Definition: window.cpp:749
void deleteImage()
Definition: textchunk.cpp:192
Definition: layout.h:43
Color color2
Definition: textchunk.h:66
void saveWindowState()
Definition: window.cpp:1137
void clearLayout()
Definition: window.cpp:1360
MouseButton ::T MouseButtonT
Definition: mousebutton.h:77
Rect mDimension
Definition: widget.h:1100
unsigned int mTitleBarHeight
Definition: window.h:615
#define isBatchDrawRenders(val)
Definition: renderers.h:30
const std::string & getCaption() const
Definition: window.h:532
#define reportAlways(...)
Definition: checkutils.h:252
virtual void safeDrawChildren(Graphics *const graphics)
int mMinWinWidth
Definition: window.h:687
void decRef()
Definition: image.cpp:521
void setValue(const std::string &key, const std::string &value)
void update()
Definition: useragent.cpp:31
void setLocationRelativeTo(const Widget *const widget)
Definition: window.cpp:501
int getResizeHandles(const MouseEvent &event)
Definition: window.cpp:1294
int getMinWidth() const
Definition: window.h:203
void setModal(const Modal modal)
Definition: window.cpp:1057
int mMaxWinHeight
Definition: window.h:690
void postInit()
Definition: window.cpp:241
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:688
Viewport * viewport
Definition: viewport.cpp:35
void safeDraw(Graphics *const graphics)
Definition: window.cpp:415
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:679
void adjustPositionAfterResize(const int oldScreenWidth, const int oldScreenHeight)
Definition: window.cpp:1254