OpenClonk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
C4GuiMenu.cpp
Go to the documentation of this file.
1 /*
2  * OpenClonk, http://www.openclonk.org
3  *
4  * Copyright (c) 2001-2009, RedWolf Design GmbH, http://www.clonk.de/
5  * Copyright (c) 2009-2016, The OpenClonk Team and contributors
6  *
7  * Distributed under the terms of the ISC license; see accompanying file
8  * "COPYING" for details.
9  *
10  * "Clonk" is a registered trademark of Matthes Bender, used with permission.
11  * See accompanying file "TRADEMARK" for details.
12  *
13  * To redistribute this file separately, substitute the full license texts
14  * for the above references.
15  */
16 // generic user interface
17 // context menu
18 
19 #include "C4Include.h"
20 #include "gui/C4Gui.h"
21 
22 #include "graphics/C4FacetEx.h"
23 #include "gui/C4MouseControl.h"
25 #include "graphics/C4Draw.h"
26 
27 #include "platform/C4Window.h"
28 
29 namespace C4GUI
30 {
31 
32  int32_t ContextMenu::iGlobalMenuIndex = 0;
33 
34 
35 // ----------------------------------------------------
36 // ContextMenu::Entry
37 
39  {
40  // icon
41  if (icoIcon > Ico_None)
42  {
43  // get icon counts
44  int32_t iXMax, iYMax;
46  if (!iXMax)
47  iXMax = 6;
48  // load icon
49  const C4Facet &rfctIcon = ::GraphicsResource.fctIcons.GetPhase(icoIcon % iXMax, icoIcon / iXMax);
50  rfctIcon.DrawX(cgo.Surface, rcBounds.x + cgo.TargetX, rcBounds.y + cgo.TargetY, rcBounds.Hgt, rcBounds.Hgt);
51  }
52  // print out label
53  if (!!sText)
55  // submenu arrow
56  if (pSubmenuHandler)
57  {
59  rSubFct.Draw(cgo.Surface, cgo.TargetX+rcBounds.x+rcBounds.Wdt - rSubFct.Wdt, cgo.TargetY+rcBounds.y+(rcBounds.Hgt - rSubFct.Hgt)/2);
60  }
61  }
62 
63  ContextMenu::Entry::Entry(const char *szText, Icons icoIcon, MenuHandler *pMenuHandler, ContextHandler *pSubmenuHandler)
64  : Element(), cHotkey(0), icoIcon(icoIcon), pMenuHandler(pMenuHandler), pSubmenuHandler(pSubmenuHandler)
65  {
66  // set text with hotkey
67  if (szText)
68  {
69  sText.Copy(szText);
71  // adjust size
73  }
74  else
75  {
76  rcBounds.Wdt = 40;
78  }
79  // regard icon
80  rcBounds.Wdt += GetIconIndent();
81  // submenu arrow
82  if (pSubmenuHandler) rcBounds.Wdt += ::GraphicsResource.fctSubmenu.Wdt+2;
83  }
84 
85 // ----------------------------------------------------
86 // ContextMenu
87 
88  ContextMenu::ContextMenu() : Window(), pTarget(nullptr), pSelectedItem(nullptr), pSubmenu(nullptr)
89  {
90  iMenuIndex = ++iGlobalMenuIndex;
91  // set min size
92  rcBounds.Wdt=40; rcBounds.Hgt=7;
93  // key bindings
95  Keys.push_back(C4KeyCodeEx(K_UP));
97  {
98  ControllerKeys::Up(Keys);
99  }
100  pKeySelUp = new C4KeyBinding(Keys, "GUIContextSelUp", KEYSCOPE_Gui,
101  new C4KeyCB<ContextMenu>(*this, &ContextMenu::KeySelUp), C4CustomKey::PRIO_Context);
102 
103  Keys.clear();
104  Keys.push_back(C4KeyCodeEx(K_DOWN));
106  {
107  ControllerKeys::Down(Keys);
108  }
109  pKeySelDown = new C4KeyBinding(Keys, "GUIContextSelDown", KEYSCOPE_Gui,
110  new C4KeyCB<ContextMenu>(*this, &ContextMenu::KeySelDown), C4CustomKey::PRIO_Context);
111 
112  Keys.clear();
113  Keys.push_back(C4KeyCodeEx(K_RIGHT));
115  {
116  ControllerKeys::Right(Keys);
117  }
118  pKeySubmenu = new C4KeyBinding(Keys, "GUIContextSubmenu", KEYSCOPE_Gui,
119  new C4KeyCB<ContextMenu>(*this, &ContextMenu::KeySubmenu), C4CustomKey::PRIO_Context);
120 
121  Keys.clear();
122  Keys.push_back(C4KeyCodeEx(K_LEFT));
124  {
125  ControllerKeys::Left(Keys);
126  }
127  pKeyBack = new C4KeyBinding(Keys, "GUIContextBack", KEYSCOPE_Gui,
128  new C4KeyCB<ContextMenu>(*this, &ContextMenu::KeyBack), C4CustomKey::PRIO_Context);
129 
130  Keys.clear();
131  Keys.push_back(C4KeyCodeEx(K_ESCAPE));
133  {
135  }
136  pKeyAbort = new C4KeyBinding(Keys, "GUIContextAbort", KEYSCOPE_Gui,
137  new C4KeyCB<ContextMenu>(*this, &ContextMenu::KeyAbort), C4CustomKey::PRIO_Context);
138 
139  Keys.clear();
140  Keys.push_back(C4KeyCodeEx(K_RETURN));
142  {
143  ControllerKeys::Ok(Keys);
144  }
145  pKeyConfirm = new C4KeyBinding(Keys, "GUIContextConfirm", KEYSCOPE_Gui,
146  new C4KeyCB<ContextMenu>(*this, &ContextMenu::KeyConfirm), C4CustomKey::PRIO_Context);
147 
148  pKeyHotkey = new C4KeyBinding(C4KeyCodeEx(KEY_Any), "GUIContextHotkey", KEYSCOPE_Gui,
149  new C4KeyCBPassKey<ContextMenu>(*this, &ContextMenu::KeyHotkey), C4CustomKey::PRIO_Context);
150  }
151 
153  {
154  // del any submenu
155  if (pSubmenu) { delete pSubmenu; pSubmenu=nullptr; }
156  // forward RemoveElement to screen
157  Screen *pScreen = GetScreen();
158  if (pScreen) pScreen->RemoveElement(this);
159  // clear key bindings
160  delete pKeySelUp;
161  delete pKeySelDown;
162  delete pKeySubmenu;
163  delete pKeyBack;
164  delete pKeyAbort;
165  delete pKeyConfirm;
166  delete pKeyHotkey;
167  // clear children to get appropriate callbacks
168  Clear();
169  }
170 
171  void ContextMenu::Abort(bool fByUser)
172  {
173  // effect
174  if (fByUser) GUISound("UI::Close");
175  // simply del menu: dtor will remove itself
176  delete this;
177  }
178 
180  {
181  // draw context menu bg
185  // context bg: mark selected item
186  if (pSelectedItem)
187  {
188  // get marked item bounds
189  C4Rect rcSelArea = pSelectedItem->GetBounds();
190  // do indent
191  rcSelArea.x += GetClientRect().x;
192  rcSelArea.y += GetClientRect().y;
193  // draw
194  pDraw->DrawBoxDw(cgo.Surface, rcSelArea.x+cgo.TargetX, rcSelArea.y+cgo.TargetY,
195  rcSelArea.x+rcSelArea.Wdt+cgo.TargetX-1, rcSelArea.y+rcSelArea.Hgt+cgo.TargetY-1,
197  }
198  // draw frame
199  Draw3DFrame(cgo);
200  }
201 
202  void ContextMenu::MouseInput(CMouse &rMouse, int32_t iButton, int32_t iX, int32_t iY, DWORD dwKeyParam)
203  {
204  // inherited
205  Window::MouseInput(rMouse, iButton, iX, iY, dwKeyParam);
206  // mouse is in client area?
207  if (GetClientRect().Contains(iX+rcBounds.x, iY+rcBounds.y))
208  {
209  // reset selection
210  Element *pPrevSelectedItem = pSelectedItem;
211  pSelectedItem = nullptr;
212  // get client component the mouse is over
213  iX -= GetMarginLeft(); iY -= GetMarginTop();
214  for (Element *pCurr = GetFirst(); pCurr; pCurr = pCurr->GetNext())
215  if (pCurr->GetBounds().Contains(iX, iY))
216  pSelectedItem = pCurr;
217  // selection change sound
218  if (pSelectedItem != pPrevSelectedItem)
219  {
220  SelectionChanged(true);
221  // selection by mouse: Check whether submenu can be opened
223  }
224  // check mouse click
225  if (iButton == C4MC_Button_LeftDown)
226  { DoOK(); return; }
227  }
228  }
229 
230  void ContextMenu::MouseLeaveEntry(CMouse &rMouse, Entry *pOldEntry)
231  {
232  // no submenu open? then deselect any selected item
233  if (pOldEntry==pSelectedItem && !pSubmenu)
234  {
235  pSelectedItem = nullptr;
236  SelectionChanged(true);
237  }
238  }
239 
240  bool ContextMenu::KeySelUp()
241  {
242  // not if focus is in submenu
243  if (pSubmenu) return false;
244  Element *pPrevSelectedItem = pSelectedItem;
245  // select prev
247  // nothing selected or beginning reached: cycle
249  // selection might have changed
250  if (pSelectedItem != pPrevSelectedItem) SelectionChanged(true);
251  return true;
252  }
253 
254  bool ContextMenu::KeySelDown()
255  {
256  // not if focus is in submenu
257  if (pSubmenu) return false;
258  Element *pPrevSelectedItem = pSelectedItem;
259  // select next
261  // nothing selected or end reached: cycle
263  // selection might have changed
264  if (pSelectedItem != pPrevSelectedItem) SelectionChanged(true);
265  return true;
266  }
267 
268  bool ContextMenu::KeySubmenu()
269  {
270  // not if focus is in submenu
271  if (pSubmenu) return false;
273  return true;
274  }
275 
276  bool ContextMenu::KeyBack()
277  {
278  // not if focus is in submenu
279  if (pSubmenu) return false;
280  // close submenu on keyboard input
281  if (IsSubmenu()) { Abort(true); return true; }
282  return false;
283  }
284 
285  bool ContextMenu::KeyAbort()
286  {
287  // not if focus is in submenu
288  if (pSubmenu) return false;
289  Abort(true);
290  return true;
291  }
292 
293  bool ContextMenu::KeyConfirm()
294  {
295  // not if focus is in submenu
296  if (pSubmenu) return false;
298  DoOK();
299  return true;
300  }
301 
302  bool ContextMenu::KeyHotkey(const C4KeyCodeEx &key)
303  {
304  // not if focus is in submenu
305  if (pSubmenu) return false;
306  Element *pPrevSelectedItem = pSelectedItem;
307  StdStrBuf sKey = C4KeyCodeEx::KeyCode2String(key.Key, true, true);
308  // do hotkey procs for standard alphanumerics only
309  if (sKey.getLength() != 1) return false;
310  WORD wKey = WORD(*sKey.getData());
311  if (Inside<C4KeyCode, C4KeyCode, C4KeyCode>(wKey, 'A', 'Z') || Inside<C4KeyCode, C4KeyCode, C4KeyCode>(wKey, '0', '9'))
312  {
313  // process hotkeys
314  uint32_t ch = wKey;
315  for (Element *pCurr = GetFirst(); pCurr; pCurr = pCurr->GetNext())
316  if (pCurr->OnHotkey(ch))
317  {
318  pSelectedItem = pCurr;
319  if (pSelectedItem != pPrevSelectedItem) SelectionChanged(true);
321  DoOK();
322  return true;
323  }
324  return false;
325  }
326  // unrecognized hotkey
327  return false;
328  }
329 
330  void ContextMenu::UpdateElementPositions()
331  {
332  // first item at zero offset
333  Element *pCurr = GetFirst();
334  if (!pCurr) return;
335  pCurr->GetBounds().y = 0;
336  int32_t iMinWdt = std::max<int32_t>(20, pCurr->GetBounds().Wdt);;
337  int32_t iOverallHgt = pCurr->GetBounds().Hgt;
338  // others stacked under it
339  while ((pCurr = pCurr->GetNext()))
340  {
341  iMinWdt = std::max(iMinWdt, pCurr->GetBounds().Wdt);
342  int32_t iYSpace = pCurr->GetListItemTopSpacing();
343  int32_t iNewY = iOverallHgt + iYSpace;
344  iOverallHgt += pCurr->GetBounds().Hgt + iYSpace;
345  if (iNewY != pCurr->GetBounds().y)
346  {
347  pCurr->GetBounds().y = iNewY;
348  pCurr->UpdateOwnPos();
349  }
350  }
351  // don't make smaller
352  iMinWdt = std::max(iMinWdt, rcBounds.Wdt - GetMarginLeft() - GetMarginRight());
353  // all entries same size
354  for (pCurr = GetFirst(); pCurr; pCurr = pCurr->GetNext())
355  if (pCurr->GetBounds().Wdt != iMinWdt)
356  {
357  pCurr->GetBounds().Wdt = iMinWdt;
358  pCurr->UpdateOwnPos();
359  }
360  // update own size
361  rcBounds.Wdt = iMinWdt + GetMarginLeft() + GetMarginRight();
362  rcBounds.Hgt = std::max<int32_t>(iOverallHgt, 8) + GetMarginTop() + GetMarginBottom();
363  UpdateSize();
364  }
365 
367  {
368  // inherited
369  Window::RemoveElement(pChild);
370  // target lost?
371  if (pChild == pTarget) { Abort(false); return; }
372  // submenu?
373  if (pChild == pSubmenu) pSubmenu = nullptr;
374  // clear selection var
375  if (pChild == pSelectedItem)
376  {
377  pSelectedItem = nullptr;
378  SelectionChanged(false);
379  }
380  // forward to any submenu
381  if (pSubmenu) pSubmenu->RemoveElement(pChild);
382  // forward to mouse
383  if (GetScreen())
384  GetScreen()->Mouse.RemoveElement(pChild);
385  // update positions
386  UpdateElementPositions();
387  }
388 
389  bool ContextMenu::AddElement(Element *pChild)
390  {
391  // add it
392  Window::AddElement(pChild);
393  // update own size and positions
394  UpdateElementPositions();
395  // success
396  return true;
397  }
398 
399  bool ContextMenu::InsertElement(Element *pChild, Element *pInsertBefore)
400  {
401  // insert it
402  Window::InsertElement(pChild, pInsertBefore);
403  // update own size and positions
404  UpdateElementPositions();
405  // success
406  return true;
407  }
408 
410  {
411  // inherited
412  Window::ElementSizeChanged(pOfElement);
413  // update positions of all list items
414  UpdateElementPositions();
415  }
416 
418  {
419  // inherited
420  Window::ElementSizeChanged(pOfElement);
421  // update positions of all list items
422  UpdateElementPositions();
423  }
424 
425  void ContextMenu::SelectionChanged(bool fByUser)
426  {
427  // any selection?
428  if (pSelectedItem)
429  {
430  // effect
431  if (fByUser) GUISound("UI::Select");
432  }
433  // close any submenu from prev selection
434  if (pSubmenu) pSubmenu->Abort(true);
435  }
436 
438  {
439  // context menus don't have a parent; get screen by static var
440  return Screen::GetScreenS();
441  }
442 
443  bool ContextMenu::CtxMouseInput(CMouse &rMouse, int32_t iButton, int32_t iScreenX, int32_t iScreenY, DWORD dwKeyParam)
444  {
445  // check submenu
446  if (pSubmenu)
447  if (pSubmenu->CtxMouseInput(rMouse, iButton, iScreenX, iScreenY, dwKeyParam)) return true;
448  // check bounds
449  if (!rcBounds.Contains(iScreenX, iScreenY)) return false;
450  // inside menu: do input in local coordinates
451  MouseInput(rMouse, iButton, iScreenX - rcBounds.x, iScreenY - rcBounds.y, dwKeyParam);
452  return true;
453  }
454 
455  bool ContextMenu::CharIn(const char * c)
456  {
457  // forward to submenu
458  if (pSubmenu) return pSubmenu->CharIn(c);
459  return false;
460  }
461 
463  {
464  // In editor mode, the surface is not assigned
465  // The menu is drawn directly by the dialogue, so just exit here.
466  if (!cgo.Surface) return;
467  // draw self
468  Window::Draw(cgo);
469  // draw submenus on top
470  if (pSubmenu) pSubmenu->Draw(cgo);
471  }
472 
473  void ContextMenu::Open(Element *pTarget, int32_t iScreenX, int32_t iScreenY)
474  {
475  // set pos
476  rcBounds.x = iScreenX; rcBounds.y = iScreenY;
477  UpdatePos();
478  // set target
479  this->pTarget = pTarget;
480  // effect :)
481  GUISound("UI::Open");
482  // done
483  }
484 
486  {
487  // safety
488  if (!GetScreen()) return;
489  // anything selected?
490  if (!pSelectedItem) return;
491  // get as entry
492  Entry *pSelEntry = (Entry *) pSelectedItem;
493  // has submenu handler?
494  ContextHandler *pSubmenuHandler = pSelEntry->pSubmenuHandler;
495  if (!pSubmenuHandler) return;
496  // create submenu then
497  if (pSubmenu) pSubmenu->Abort(false);
498  pSubmenu = pSubmenuHandler->OnSubcontext(pTarget);
499  // get open pos
500  int32_t iX = GetClientRect().x + pSelEntry->GetBounds().x + pSelEntry->GetBounds().Wdt;
501  int32_t iY = GetClientRect().y + pSelEntry->GetBounds().y + pSelEntry->GetBounds().Hgt/2;
502  int32_t iScreenWdt = GetScreen()->GetBounds().Wdt, iScreenHgt = GetScreen()->GetBounds().Hgt;
503  if (iY + pSubmenu->GetBounds().Hgt >= iScreenHgt)
504  {
505  // bottom too narrow: open to top, if height is sufficient
506  // otherwise, open to top from bottom screen pos
507  if (iY < pSubmenu->GetBounds().Hgt) iY = iScreenHgt;
508  iY -= pSubmenu->GetBounds().Hgt;
509  }
510  if (iX + pSubmenu->GetBounds().Wdt >= iScreenWdt)
511  {
512  // right too narrow: try opening left of this menu
513  // otherwise, open to left from right screen border
514  if (GetClientRect().x < pSubmenu->GetBounds().Wdt)
515  iX = iScreenWdt;
516  else
517  iX = GetClientRect().x;
518  iX -= pSubmenu->GetBounds().Wdt;
519  }
520  // open it
521  pSubmenu->Open(pTarget, iX, iY);
522  }
523 
525  {
526  return GetScreen() && GetScreen()->pContext!=this;
527  }
528 
530  {
531  // safety
532  if (!GetScreen()) return;
533  // anything selected?
534  if (!pSelectedItem) return;
535  // get as entry
536  Entry *pSelEntry = (Entry *) pSelectedItem;
537  // get CB; take over pointer
538  MenuHandler *pCallback = pSelEntry->GetAndZeroCallback();
539  Element *pTarget = this->pTarget;
540  if (!pCallback) return;
541  // close all menus (deletes this class!) w/o sound
542  GetScreen()->AbortContext(false);
543  // sound
544  GUISound("UI::Click");
545  // do CB
546  pCallback->OnOK(pTarget);
547  // free CB class
548  delete pCallback;
549  }
550 
551  void ContextMenu::SelectItem(int32_t iIndex)
552  {
553  // get item to be selected (may be nullptr on purpose!)
554  Element *pNewSelElement = GetElementByIndex(iIndex);
555  if (pNewSelElement != pSelectedItem) return;
556  // set new
557  pSelectedItem = pNewSelElement;
558  SelectionChanged(false);
559  }
560 
561 
562 // ----------------------------------------------------
563 // ContextButton
564 
565  ContextButton::ContextButton(C4Rect &rtBounds) : Control(rtBounds), iOpenMenu(0), fMouseOver(false)
566  {
567  RegisterContextKey();
568  }
569 
570  ContextButton::ContextButton(Element *pForEl, bool fAdd, int32_t iHIndent, int32_t iVIndent)
571  : Control(C4Rect(0,0,0,0)), iOpenMenu(0), fMouseOver(false)
572  {
573  SetBounds(pForEl->GetToprightCornerRect(16, 16, iHIndent, iVIndent));
574  // copy context handler
576  // add if desired
577  Container *pCont;
578  if (fAdd) if ((pCont = pForEl->GetContainer()))
579  pCont->AddElement(this);
580  RegisterContextKey();
581  }
582 
584  {
585  delete pKeyContext;
586  }
587 
588  void ContextButton::RegisterContextKey()
589  {
590  // reg keys for pressing the context button
591  C4CustomKey::CodeList ContextKeys;
592  ContextKeys.push_back(C4KeyCodeEx(K_RIGHT));
593  ContextKeys.push_back(C4KeyCodeEx(K_DOWN));
594  ContextKeys.push_back(C4KeyCodeEx(K_SPACE));
595  ContextKeys.push_back(C4KeyCodeEx(K_RIGHT, KEYS_Alt));
596  ContextKeys.push_back(C4KeyCodeEx(K_DOWN, KEYS_Alt));
597  ContextKeys.push_back(C4KeyCodeEx(K_SPACE, KEYS_Alt));
598  pKeyContext = new C4KeyBinding(ContextKeys, "GUIContextButtonPress", KEYSCOPE_Gui,
599  new ControlKeyCB<ContextButton>(*this, &ContextButton::KeyContext), C4CustomKey::PRIO_Ctrl);
600  }
601 
602  bool ContextButton::DoContext(int32_t iX, int32_t iY)
603  {
604  // get context pos
605  if (iX<0)
606  {
607  iX = rcBounds.Wdt/2;
608  iY = rcBounds.Hgt/2;
609  }
610  // do context
611  ContextHandler *pCtx = GetContextHandler();
612  if (!pCtx) return false;
613  if (!pCtx->OnContext(this, iX, iY)) return false;
614  // store menu
615  Screen *pScr = GetScreen();
616  if (!pScr) return false;
617  iOpenMenu = pScr->GetContextMenuIndex();
618  // return whether all was successful
619  return !!iOpenMenu;
620  }
621 
623  {
624  // recheck open menu
625  Screen *pScr = GetScreen();
626  if (!pScr || (iOpenMenu != pScr->GetContextMenuIndex())) iOpenMenu = 0;
627  // calc drawing bounds
628  int32_t x0 = cgo.TargetX + rcBounds.x, y0 = cgo.TargetY + rcBounds.y;
629  // draw button; down (phase 1) if a menu is open
630  ::GraphicsResource.fctContext.Draw(cgo.Surface, x0, y0, iOpenMenu ? 1 : 0);
631  // draw selection highlight
632  if (HasDrawFocus() || (fMouseOver && IsInActiveDlg(false)) || iOpenMenu)
633  {
636  pDraw->ResetBlitMode();
637  }
638  }
639 
640  void ContextButton::MouseInput(CMouse &rMouse, int32_t iButton, int32_t iX, int32_t iY, DWORD dwKeyParam)
641  {
642  // left-click activates menu
643  if ((iButton == C4MC_Button_LeftDown) || (iButton == C4MC_Button_RightDown))
644  if (DoContext()) return;
645  // inherited
646  Control::MouseInput(rMouse, iButton, iX, iY, dwKeyParam);
647  }
648 
650  {
651  Control::MouseEnter(rMouse);
652  // remember mouse state for button highlight
653  fMouseOver = true;
654  }
655 
657  {
658  Control::MouseLeave(rMouse);
659  // mouse left
660  fMouseOver = false;
661  }
662 
663 
664 
665 } // end of namespace
666 
const char * getData() const
Definition: StdBuf.h:450
virtual void OnOK(Element *pTarget)=0
void Open(Element *pTarget, int32_t iScreenX, int32_t iScreenY)
Definition: C4GuiMenu.cpp:473
virtual void MouseInput(CMouse &rMouse, int32_t iButton, int32_t iX, int32_t iY, DWORD dwKeyParam)
bool Contains(int32_t iX, int32_t iY) const
Definition: C4Rect.h:42
C4Config Config
Definition: C4Config.cpp:837
const int32_t C4MC_Button_LeftDown
int GetLineHeight() const
Definition: C4FontLoader.h:132
ContextButton(C4Rect &rtBounds)
Definition: C4GuiMenu.cpp:565
void GUISound(const char *szSound)
Definition: C4Gui.cpp:1178
void Up(T &keys)
void AbortContext(bool fByUser)
Definition: C4Gui.h:2654
StdStrBuf sText
Definition: C4Gui.h:1796
virtual ContextMenu * OnSubcontext(Element *pOnElement)=0
virtual void RemoveElement(Element *pChild)
Definition: C4GuiMenu.cpp:366
virtual int32_t GetMarginBottom()
Definition: C4Gui.h:1853
virtual Element * GetFirstContained()
Definition: C4Gui.h:773
virtual void RemoveElement(Element *pChild)
Definition: C4Gui.cpp:559
virtual Container * GetContainer()
Definition: C4Gui.h:410
virtual int32_t GetMarginRight()
Definition: C4Gui.h:1852
void Down(T &keys)
virtual void DrawElement(C4TargetFacet &cgo)
Definition: C4GuiMenu.cpp:622
void ResetBlitMode()
Definition: C4Draw.h:192
bool GetPhaseNum(int32_t &rX, int32_t &rY)
Definition: C4Facet.cpp:472
bool DoContext()
Definition: C4Gui.cpp:418
void Cancel(T &keys)
bool TextOut(const char *szText, CStdFont &rFont, float fZoom, C4Surface *sfcDest, float iTx, float iTy, DWORD dwFCol=0xffffffff, BYTE byForm=ALeft, bool fDoMarkup=true)
Definition: C4Draw.cpp:570
#define C4GFXBLIT_ADDITIVE
Definition: C4Surface.h:28
#define C4GUI_ContextFontClr
Definition: C4Gui.h:55
virtual void MouseInput(CMouse &rMouse, int32_t iButton, int32_t iX, int32_t iY, DWORD dwKeyParam)
Definition: C4GuiMenu.cpp:640
Definition: C4Rect.h:29
void Draw3DFrame(C4TargetFacet &cgo, bool fUp=false, int32_t iIndent=1, BYTE byAlpha=C4GUI_BorderAlpha, bool fDrawTop=true, int32_t iTopOff=0, bool fDrawLeft=true, int32_t iLeftOff=0)
Definition: C4Gui.cpp:292
Element * pSelectedItem
Definition: C4Gui.h:1830
bool GetTextExtent(const char *szText, int32_t &rsx, int32_t &rsy, bool fCheckMarkup=true)
static Screen * GetScreenS()
Definition: C4Gui.h:2626
virtual C4Rect & GetClientRect()
Definition: C4Gui.h:864
void AddElement(Element *pChild)
void MouseLeaveEntry(CMouse &rMouse, Entry *pOldEntry)
Definition: C4GuiMenu.cpp:230
#define C4GUI_ContextBGColor
Definition: C4Gui.h:65
virtual int32_t GetMarginLeft()
Definition: C4Gui.h:1851
void SelectionChanged(bool fByUser)
Definition: C4GuiMenu.cpp:425
virtual void UpdateSize()
Definition: C4Gui.cpp:186
MenuHandler * GetAndZeroCallback()
Definition: C4Gui.h:1805
C4GraphicsResource GraphicsResource
void Abort(bool fByUser)
Definition: C4GuiMenu.cpp:171
void SetBlitMode(DWORD dwBlitMode)
Definition: C4Draw.h:191
virtual void DrawElement(C4TargetFacet &cgo)
Definition: C4GuiMenu.cpp:38
virtual void DrawElement(C4TargetFacet &cgo)
Definition: C4GuiMenu.cpp:179
Element * pTarget
Definition: C4Gui.h:1829
virtual void RemoveElement(Element *pChild)
static StdStrBuf KeyCode2String(C4KeyCode wCode, bool fHumanReadable, bool fShort)
Entry(const char *szText, Icons icoIcon=Ico_None, MenuHandler *pMenuHandler=nullptr, ContextHandler *pSubmenuHandler=nullptr)
Definition: C4GuiMenu.cpp:63
int32_t Wdt
Definition: C4Rect.h:32
bool ExpandHotkeyMarkup(StdStrBuf &sText, uint32_t &rcHotkey, bool for_tooltip)
Definition: C4Gui.cpp:39
std::vector< C4KeyCodeEx > CodeList
virtual bool CharIn(const char *c)
Definition: C4GuiMenu.cpp:455
int32_t y
Definition: C4Rect.h:32
Element * GetFirst()
Definition: C4Gui.h:829
void DrawX(C4Surface *sfcTarget, float iX, float iY, float iWdt, float iHgt, int32_t iPhaseX=0, int32_t iPhaseY=0) const
Definition: C4Facet.cpp:358
void DrawBoxDw(C4Surface *sfcDest, int iX1, int iY1, int iX2, int iY2, DWORD dwClr)
Definition: C4Draw.cpp:849
Definition: C4Gui.h:1790
C4Rect GetToprightCornerRect(int32_t iWidth=16, int32_t iHeight=16, int32_t iHIndent=4, int32_t iVIndent=4, int32_t iIndexX=0)
Definition: C4Gui.cpp:400
C4Rect rcBounds
Definition: C4Gui.h:385
virtual void MouseInput(CMouse &rMouse, int32_t iButton, int32_t iX, int32_t iY, DWORD dwKeyParam)
void SelectItem(int32_t iIndex)
Definition: C4GuiMenu.cpp:551
#define C4GUI_ContextSelColor
Definition: C4Gui.h:64
void Draw(C4Facet &cgo, bool fAspect=true, int32_t iPhaseX=0, int32_t iPhaseY=0, bool fTransparent=true)
Definition: C4Facet.cpp:154
void InsertElement(Element *pChild, Element *pInsertBefore)
virtual void ElementSizeChanged(Element *pOfElement)
Definition: C4Gui.h:753
virtual ContextHandler * GetContextHandler()
Definition: C4Gui.cpp:430
C4Draw * pDraw
Definition: C4Draw.cpp:45
void SetContextHandler(ContextHandler *pNewHd)
Definition: C4Gui.h:465
virtual Screen * GetScreen()
Definition: C4GuiMenu.cpp:437
virtual void MouseLeave(CMouse &rMouse)
Definition: C4GuiMenu.cpp:656
ContextMenu * pContext
Definition: C4Gui.h:2591
C4Rect & GetBounds()
Definition: C4Gui.h:445
Icons icoIcon
Definition: C4Gui.h:1798
const int32_t C4MC_Button_RightDown
Icons
Definition: C4Gui.h:637
virtual void ElementPosChanged(Element *pOfElement)
Definition: C4GuiMenu.cpp:417
C4KeyCode Key
int32_t x
Definition: C4Rect.h:32
void Right(T &keys)
virtual int32_t GetMarginTop()
Definition: C4Gui.h:1850
int32_t GamepadGuiControl
Definition: C4Config.h:230
ContextMenu * pSubmenu
Definition: C4Gui.h:1832
Element * GetNext() const
Definition: C4Gui.h:449
float TargetX
Definition: C4Facet.h:167
void Ok(T &keys)
C4ConfigControls Controls
Definition: C4Config.h:260
int32_t GetContextMenuIndex()
Definition: C4Gui.h:2655
Element * GetElementByIndex(int32_t i)
float Hgt
Definition: C4Facet.h:120
void SetBounds(const C4Rect &rcNewBound)
Definition: C4Gui.h:446
virtual void MouseInput(CMouse &rMouse, int32_t iButton, int32_t iX, int32_t iY, DWORD dwKeyParam)
Definition: C4GuiMenu.cpp:202
const int ALeft
Definition: C4Surface.h:43
const C4KeyCode KEY_Any
virtual void Draw(C4TargetFacet &cgo)
Element * GetPrev() const
Definition: C4Gui.h:450
size_t getLength() const
Definition: StdBuf.h:453
uint32_t cHotkey
Definition: C4Gui.h:1797
virtual void UpdatePos()
Definition: C4Gui.cpp:194
void RemoveElement(Element *pChild)
Definition: C4Gui.cpp:537
virtual Screen * GetScreen()
Definition: C4Gui.cpp:290
int32_t Hgt
Definition: C4Rect.h:32
CMouse Mouse
Definition: C4Gui.h:2587
virtual Element * GetLastContained()
Definition: C4Gui.h:774
C4Surface * Surface
Definition: C4Facet.h:119
float TargetY
Definition: C4Facet.h:167
void Left(T &keys)
uint32_t DWORD
virtual void ElementSizeChanged(Element *pOfElement)
Definition: C4GuiMenu.cpp:409
void Copy()
Definition: StdBuf.h:475
float Wdt
Definition: C4Facet.h:120
C4Facet GetPhase(int iPhaseX=0, int iPhaseY=0)
Definition: C4Facet.cpp:59
bool CtxMouseInput(CMouse &rMouse, int32_t iButton, int32_t iScreenX, int32_t iScreenY, DWORD dwKeyParam)
Definition: C4GuiMenu.cpp:443
virtual void Draw(C4TargetFacet &cgo)
Definition: C4GuiMenu.cpp:462
uint16_t WORD
virtual void MouseEnter(CMouse &rMouse)
Definition: C4Gui.h:413
virtual void MouseEnter(CMouse &rMouse)
Definition: C4GuiMenu.cpp:649
bool IsInActiveDlg(bool fForKeyboard)
Definition: C4Gui.cpp:436
virtual void MouseLeave(CMouse &rMouse)
Definition: C4Gui.h:414
ContextHandler * pSubmenuHandler
Definition: C4Gui.h:1800