1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010-2020 Winch Gate Property Limited
4 // This source file has been modified by the following contributors:
5 // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) <dfighter1985@gmail.com>
6 // Copyright (C) 2014-2020 Jan BOON (Kaetemi) <jan.boon@kaetemi.be>
8 // This program is free software: you can redistribute it and/or modify
9 // it under the terms of the GNU Affero General Public License as
10 // published by the Free Software Foundation, either version 3 of the
11 // License, or (at your option) any later version.
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU Affero General Public License for more details.
18 // You should have received a copy of the GNU Affero General Public License
19 // along with this program. If not, see <http://www.gnu.org/licenses/>.
23 #include "nel/gui/group_container.h"
24 #include "nel/gui/interface_options.h"
25 #include "nel/misc/xml_auto_ptr.h"
26 #include "nel/gui/action_handler.h"
27 #include "nel/gui/group_editbox.h"
28 #include "nel/gui/view_text_formated.h"
29 #include "nel/gui/view_text_id.h"
30 #include "nel/gui/lua_ihm.h"
31 #include "nel/gui/group_list.h"
32 #include "nel/gui/ctrl_button.h"
33 #include "nel/gui/ctrl_scroll.h"
34 #include "nel/gui/view_text.h"
35 #include "nel/gui/view_bitmap.h"
36 #include "nel/gui/view_renderer.h"
37 #include "nel/gui/widget_manager.h"
38 #include "nel/gui/view_pointer_base.h"
39 #include "nel/misc/i18n.h"
40 #include "nel/misc/algo.h"
44 using namespace NLMISC
;
52 const sint SIZE_W_LEFT
= 16;
53 const sint DELTA_BEFORE_POPUP
= 32;
54 const sint DELTA_BEFORE_MOVING_IN_PARENT_LIST
= 16;
60 bool CGroupContainer::_ValidateCanDeactivate
= true;
62 //#define DRAW_GC_TEST_QUADS
65 #ifdef DRAW_GC_TEST_QUADS
66 static void drawGCTestQuad(sint renderLayer
, sint32 xreal
, sint32 yreal
, sint32 wreal
, sint32 hreal
, CRGBA color
)
68 CViewRenderer
&rVR
= *CViewRenderer::getInstance();
72 rVR
.getClipWindow(x
, y
, w
, h
);
74 rVR
.getScreenSize(sw
, sh
);
75 rVR
.setClipWindow(0, 0, (sint32
)sw
, (sint32
)sh
);
76 rVR
.drawRotFlipBitmap (renderLayer
, xreal
, yreal
, wreal
, hreal
, 0, false, rVR
.getBlankTextureId(), color
);
77 rVR
.setClipWindow(x
, y
, w
,h
);
82 // ***************************************************************************
83 const string
CGroupContainer::_OptionLayerName
[CGroupContainer::NumLayerName
]=
98 // ***************************************************************************
100 // ***************************************************************************
102 // ***************************************************************************
103 CCtrlResizer::CCtrlResizer(const TCtorParam
¶m
)
108 _ResizerPos
= Hotspot_BR
;
117 // ***************************************************************************
118 THotSpot
CCtrlResizer::getRealResizerPos() const
120 CGroupContainer
*parent
= dynamic_cast<CGroupContainer
*>(getParent());
123 THotSpot resizerPos
= _ResizerPos
;
124 if (!IsMaxH
&& parent
->getPopupMinH() == parent
->getPopupMaxH())
126 resizerPos
= (THotSpot
) (resizerPos
& ~(Hotspot_Bx
| Hotspot_Mx
| Hotspot_Tx
));
128 if (parent
->getPopupMinW() == parent
->getPopupMaxW())
130 resizerPos
= (THotSpot
) (resizerPos
& ~(Hotspot_xR
| Hotspot_xM
| Hotspot_xL
));
137 // ***************************************************************************
138 void CCtrlResizer::draw ()
140 #ifdef DRAW_GC_TEST_QUADS
144 case Hotspot_TR
: col
= CRGBA::Yellow
; break;
145 case Hotspot_MR
: col
= CRGBA::Blue
; break;
146 case Hotspot_BR
: col
= CRGBA::Yellow
; break;
147 case Hotspot_BM
: col
= CRGBA::Blue
; break;
148 case Hotspot_BL
: col
= CRGBA::Yellow
; break;
149 case Hotspot_ML
: col
= CRGBA::Blue
; break;
150 case Hotspot_TL
: col
= CRGBA::Yellow
; break;
151 case Hotspot_TM
: col
= CRGBA::Blue
; break;
154 drawGCTestQuad(_RenderLayer
, _XReal
, _YReal
, _WReal
, _HReal
, col
);
158 // ***************************************************************************
159 bool CCtrlResizer::handleEvent (const NLGUI::CEventDescriptor
&event
)
161 if (CCtrlBase::handleEvent(event
)) return true;
162 if (!_Active
|| !_Parent
)
165 if (event
.getType() == NLGUI::CEventDescriptor::system
)
167 const NLGUI::CEventDescriptorSystem
&eds
= (const NLGUI::CEventDescriptorSystem
&) event
;
168 if (eds
.getEventTypeExtended() == NLGUI::CEventDescriptorSystem::setfocus
)
170 const NLGUI::CEventDescriptorSetFocus
&edsf
= (const NLGUI::CEventDescriptorSetFocus
&) eds
;
171 if (edsf
.hasFocus() == false && _MouseDown
)
174 _Parent
->invalidateCoords();
180 if (event
.getType() == NLGUI::CEventDescriptor::mouse
)
182 const NLGUI::CEventDescriptorMouse
&eventDesc
= (const NLGUI::CEventDescriptorMouse
&)event
;
183 if ((CWidgetManager::getInstance()->getCapturePointerLeft() != this) && !isIn(eventDesc
.getX(), eventDesc
.getY()))
186 CGroupContainer
*gc
= dynamic_cast<CGroupContainer
*>(_Parent
);
188 if (eventDesc
.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouseleftdown
)
190 // must check that parent isn't closed
194 if (!gc
->isOpen()) return false;
195 if (gc
->getLayerSetup() != 0) return false;
196 if (gc
->isLocked()) return true;
198 gc
->setPopupMaxH(gc
->getH());
201 _MouseDownX
= eventDesc
.getX();
202 _MouseDownY
= eventDesc
.getY();
208 if (eventDesc
.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouseleftup
)
211 _Parent
->invalidateCoords();
214 if (eventDesc
.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mousemove
)
218 //nlinfo("x = %d, y = %d", eventDesc.getX() + _XReal, eventDesc.getY() + _YReal);
219 sint32 dx
= eventDesc
.getX() - _MouseDownX
;
220 sint32 dy
= eventDesc
.getY() - _MouseDownY
;
223 THotSpot resizerPos
= getRealResizerPos();
254 if (resizerPos
& Hotspot_xR
)
256 sint32 effectiveDX
= resizeW (dx
);
257 if (effectiveDX
!= 0 && gc
) gc
->touch();
258 if (_Parent
->getPosRef() & Hotspot_xR
)
260 _Parent
->setX(_Parent
->getX() + effectiveDX
);
262 _XBias
+= dx
- effectiveDX
;
264 else if (resizerPos
& Hotspot_xL
)
266 sint32 effectiveDX
= resizeW (- dx
);
267 if (effectiveDX
!= 0 && gc
) gc
->touch();
268 if (_Parent
->getPosRef() & Hotspot_xL
)
270 _Parent
->setX(_Parent
->getX() - effectiveDX
);
272 _XBias
+= dx
+ effectiveDX
;
305 if (resizerPos
& Hotspot_Tx
)
307 sint32 effectiveDY
= resizeH (dy
);
308 if (effectiveDY
!= 0 && gc
) gc
->touch();
309 if (_Parent
->getPosRef() & Hotspot_Tx
)
311 _Parent
->setY(_Parent
->getY() + effectiveDY
);
313 _YBias
+= dy
- effectiveDY
;
315 else if (resizerPos
& Hotspot_Bx
)
317 sint32 effectiveDY
= resizeH (- dy
);
318 if (effectiveDY
!= 0 && gc
) gc
->touch();
319 if (_Parent
->getPosRef() & Hotspot_Bx
)
321 _Parent
->setY(_Parent
->getY() + effectiveDY
);
323 _YBias
+= dy
+ effectiveDY
;
327 _Parent
->invalidateCoords();
330 _MouseDownX
= eventDesc
.getX();
331 _MouseDownY
= eventDesc
.getY();
334 // call resize handler of parent container if any
335 if (gc
&& gc
->getAHOnResizePtr() != NULL
)
337 CAHManager::getInstance()->runActionHandler(gc
->getAHOnResize(), gc
, gc
->getAHOnResizeParams());
346 // ***************************************************************************
347 sint32
CCtrlResizer::resizeW (sint32 dx
)
349 sint32 newW
= _Parent
->getW();
351 sint32 clippedNewW
= newW
;
352 NLMISC::clamp(clippedNewW
, WMin
, WMax
);
355 CViewRenderer
&vr
= *CViewRenderer::getInstance();
356 vr
.getScreenSize(sw
, sh
);
357 if (_Parent
->getPosRef() & Hotspot_xR
)
359 if (_ResizerPos
& Hotspot_xR
)
361 clippedNewW
= std::min((sint32
)sw
+ _Parent
->getW() - _Parent
->getXReal(), clippedNewW
);
365 clippedNewW
= std::min(clippedNewW
, _Parent
->getXReal());
370 if (_ResizerPos
& Hotspot_xL
)
372 clippedNewW
= std::min(clippedNewW
, _Parent
->getXReal() + _Parent
->getW());
376 clippedNewW
= std::min((sint32
)sw
- _Parent
->getXReal(), clippedNewW
);
380 dx
= clippedNewW
- _Parent
->getW();
381 _Parent
->setW (clippedNewW
);
385 // ***************************************************************************
386 sint32
CCtrlResizer::resizeH (sint32 dy
)
388 // if the owner is a container, special resize applied
389 CGroupContainer
*gc
= NULL
;
390 gc
= dynamic_cast<CGroupContainer
*>(_Parent
);
394 // resize popupmaxh or h, according to IsMaxH.
397 oldH
= gc
->getPopupMaxH();
399 oldH
= _Parent
->getH();
402 sint32 clippedNewH
= oldH
+ dy
;
403 // if IsMaxH, don't clamp by HMax
405 clippedNewH
= std::max(clippedNewH
, HMin
);
407 NLMISC::clamp(clippedNewH
, HMin
, HMax
);
412 CViewRenderer
&vr
= *CViewRenderer::getInstance();
413 vr
.getScreenSize(sw
, sh
);
414 if (_Parent
->getPosRef() & Hotspot_Tx
)
416 if (_ResizerPos
& Hotspot_Tx
)
418 clippedNewH
= std::min((sint32
) sh
+ oldH
- _Parent
->getY(), clippedNewH
);
422 clippedNewH
= std::min(clippedNewH
, _Parent
->getY());
427 if (_ResizerPos
& Hotspot_Tx
)
429 clippedNewH
= std::min((sint32
) sh
- _Parent
->getY(), clippedNewH
);
433 clippedNewH
= std::min(clippedNewH
, _Parent
->getY() + oldH
);
438 dy
= clippedNewH
- oldH
;
440 gc
->setPopupMaxH(clippedNewH
);
442 gc
->setH(clippedNewH
);
447 // ***************************************************************************
449 // ***************************************************************************
451 // ***************************************************************************
452 CCtrlMover::CCtrlMover(const TCtorParam
¶m
, bool canMove
, bool canOpen
)
459 _MovingInParentList
= false;
460 _ParentScrollingUp
= false;
461 _ParentScrollingDown
= false;
462 _WaitToOpenClose
= false;
465 // ***************************************************************************
466 CCtrlMover::~CCtrlMover()
470 // ***************************************************************************
471 COptionsContainerInsertion
*CCtrlMover::getInsertionOptions()
473 static NLMISC::CRefPtr
<COptionsContainerInsertion
> insertionOptions
;
474 if (insertionOptions
) return insertionOptions
;
475 insertionOptions
= (COptionsContainerInsertion
*) CWidgetManager::getInstance()->getOptions("container_insertion_opt");
476 return insertionOptions
;
480 // ***************************************************************************
481 void CCtrlMover::draw ()
483 #ifdef DRAW_GC_TEST_QUADS
484 drawGCTestQuad(_RenderLayer
, _XReal
, _YReal
, _WReal
, _HReal
, CRGBA(255, 0, 0, 127));
487 // No Op if window is minimized
488 if(CViewRenderer::getInstance()->isMinimized())
491 // draw insertion position if moving in parent list
492 if (_MovingInParentList
)
494 COptionsContainerInsertion
*options
= getInsertionOptions();
495 if (!options
) return;
496 CViewRenderer
&rVR
= *CViewRenderer::getInstance();
497 sint32 oldSciX
, oldSciY
, oldSciW
, oldSciH
;
498 rVR
.getClipWindow (oldSciX
, oldSciY
, oldSciW
, oldSciH
);
500 rVR
.getScreenSize(sw
, sh
);
501 rVR
.setClipWindow (0, 0, (sint32
) sw
, (sint32
) sh
);
502 CViewRenderer
&vr
= *CViewRenderer::getInstance();
504 CGroupContainer
*gc
= dynamic_cast<CGroupContainer
*>(_Parent
);
506 CGroupList
*gl
= gc
->getPreviousParentList();
509 sint32 arrowWidth
, arrowHeight
;
511 if (_ParentScrollingUp
)
513 sint32 topPosY
= gl
->getChild(0)->getYReal();
514 if (gc
->getYReal() < topPosY
)
516 vr
.getTextureSizeFromId(options
->TxId_T_Arrow
, arrowWidth
, arrowHeight
);
517 // insertion position is too high, just draw an arrow pointing to top
518 sint32 px
= gl
->getXReal() + (gl
->getWReal() >> 1) - (arrowWidth
>> 1);
519 vr
.drawRotFlipBitmap(gc
->getRenderLayer(), px
, _ParentListTop
- arrowHeight
- 2, arrowWidth
, arrowHeight
, 0, 0, options
->TxId_T_Arrow
);
523 if (_ParentScrollingDown
)
525 sint32 bottomPosY
= gl
->getChild(gl
->getNumChildren() - 1)->getYReal() - gl
->getChild(gl
->getNumChildren() - 1)->getHReal();
526 if (gc
->getYReal() - gc
->getHReal() > bottomPosY
)
528 vr
.getTextureSizeFromId(options
->TxId_B_Arrow
, arrowWidth
, arrowHeight
);
529 // draw an arrow pointing at bottom
530 // insertion position is too high, just draw an arrow pointing to top
531 sint32 px
= gl
->getXReal() + (gl
->getWReal() >> 1) - (arrowWidth
>> 1);
532 vr
.drawRotFlipBitmap(gc
->getRenderLayer(), px
, _ParentListBottom
+ 2, arrowWidth
, arrowHeight
, 0, 0, options
->TxId_B_Arrow
);
537 if (!_ParentScrollingUp
&& !_ParentScrollingDown
)
540 if (_InsertionIndex
== (sint32
) gl
->getNumChildren())
542 posY
= gl
->getChild(_InsertionIndex
- 1)->getYReal();
546 posY
= gl
->getChild(_InsertionIndex
)->getYReal() + gl
->getChild(_InsertionIndex
)->getHReal();
549 // draw insertion bar
551 sint32 barWidth
, barHeight
;
552 vr
.getTextureSizeFromId(options
->TxId_InsertionBar
, barWidth
, barHeight
);
553 if (posY
>= _ParentListBottom
&& posY
<= _ParentListTop
)
555 sint32 py
= posY
- (barHeight
>> 1) - 3;
556 vr
.drawRotFlipBitmap(gc
->getRenderLayer(), gl
->getXReal(), py
, gl
->getWReal(), barHeight
, 0, 0, options
->TxId_InsertionBar
);
559 rVR
.setClipWindow(oldSciX
, oldSciY
, oldSciW
, oldSciH
);
563 // ***************************************************************************
564 bool CCtrlMover::handleEvent (const NLGUI::CEventDescriptor
&event
)
566 if (CCtrlBase::handleEvent(event
)) return true;
570 const CWidgetManager::SInterfaceTimes
×
= CWidgetManager::getInstance()->getInterfaceTimes();
572 if (event
.getType() == NLGUI::CEventDescriptor::system
)
574 const NLGUI::CEventDescriptorSystem
&eds
= (const NLGUI::CEventDescriptorSystem
&) event
;
575 if (eds
.getEventTypeExtended() == NLGUI::CEventDescriptorSystem::setfocus
)
577 const NLGUI::CEventDescriptorSetFocus
&edsf
= (const NLGUI::CEventDescriptorSetFocus
&) eds
;
578 if (edsf
.hasFocus() == false && _Moving
)
586 if (event
.getType() == NLGUI::CEventDescriptor::mouse
)
588 const NLGUI::CEventDescriptorMouse
&eventDesc
= (const NLGUI::CEventDescriptorMouse
&)event
;
589 // the ctrl must have been captured
590 if (CWidgetManager::getInstance()->getCapturePointerLeft() != this)
593 CGroupContainer
*gc
= dynamic_cast<CGroupContainer
*>(_Parent
);
594 if (!gc
) return false;
595 if (gc
->isLockable())
599 return false; // do nothing
603 if (eventDesc
.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouseleftdown
&& _WaitToOpenClose
)
605 if (_WaitToOpenClose
)
607 _WaitToOpenClose
= false;
608 CWidgetManager::getInstance()->unregisterClockMsgTarget(this);
609 // _WaitToOpen can only be set if the container is popable
612 // A double click has been made
613 gc
->setHighLighted(false);
617 gc
->setPopupX(gc
->getX());
618 gc
->setPopupY(gc
->getY());
619 gc
->setPopupW(gc
->getW());
620 //sint32 currH, minH, maxH;
621 //gc->getResizableChildrenH(currH, minH, maxH);
622 //gc->setPopupChildrenH(currH);
629 gc
->popupCurrentPos();
630 gc
->forceRolloverAlpha();
631 if (gc
->getPopupW() != -1)
633 gc
->setX(gc
->getPopupX());
634 gc
->setY(gc
->getPopupY());
635 gc
->setW(gc
->getPopupW());
636 // must resize the children to get correct height
637 //gc->setChildrenH(gc->getPopupChildrenH());
641 gc
->setW(gc
->getRefW());
644 gc
->invalidateCoords(2);
646 CWidgetManager::getInstance()->setCapturePointerLeft(NULL
);
647 CWidgetManager::getInstance()->setCapturePointerRight(NULL
);
653 if (_WaitToOpenClose
)
655 _WaitToOpenClose
= false;
656 CWidgetManager::getInstance()->unregisterClockMsgTarget(this);
659 if (_CanOpen
|| gc
->isOpenWhenPopup())
661 if (eventDesc
.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouseleftup
)
663 if (!_Parent
) return false;
664 gc
->setHighLighted(false);
665 if (_HasMoved
|| _MovingInParentList
)
670 if (isIn(eventDesc
.getX(), eventDesc
.getY()))
675 _WaitToOpenClose
= true;
676 CWidgetManager::getInstance()->registerClockMsgTarget(this);
677 _WaitToOpenCloseDate
= times
.thisFrameMs
;
682 if (gc
->isOpenable() && !gc
->isOpenWhenPopup())
684 gc
->setOpen(!gc
->isOpen());
688 return runTitleActionHandler();
703 if(!_Moving
&& !_MovingInParentList
)
708 if (eventDesc
.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouseleftdown
)
710 _MoveStartX
= _Parent
->getX()-eventDesc
.getX();
711 _MoveStartY
= _Parent
->getY()-eventDesc
.getY();
712 _MoveDeltaXReal
= _Parent
->getXReal() - _Parent
->getX();
713 _MoveDeltaYReal
= _Parent
->getYReal() - _Parent
->getY();
715 // set the window at top.
716 CWidgetManager::getInstance()->setTopWindow(_Parent
);
717 if (gc
->getAHOnBeginMovePtr())
719 CAHManager::getInstance()->runActionHandler(gc
->getAHOnBeginMove(), gc
, gc
->getAHOnBeginMoveParams());
728 if (eventDesc
.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouseleftup
)
734 if (eventDesc
.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mousemove
)
739 sint32 x
= eventDesc
.getX() + _MoveStartX
;
740 sint32 y
= eventDesc
.getY() + _MoveStartY
;
742 // if the father is a container and is popable (but not poped), move it only if the user has moved the mouse enough
743 if (_Parent
&& !_MovingInParentList
)
745 if (gc
&& gc
->getLayerSetup() != 0)
747 if (gc
->isMovableInParentList() && !gc
->isPopable())
749 if (abs(y
- _Parent
->getY()) > DELTA_BEFORE_MOVING_IN_PARENT_LIST
)
751 // There should be at least one other entry in the parent list
752 CGroupList
*parentList
= dynamic_cast<CGroupList
*>(gc
->getParent());
753 if (!parentList
) return false;
754 if (parentList
->getNbElement() == 1) return false;
755 setMovingInParent(gc
, x
, y
, eventDesc
);
756 updateInsertionIndex(parentList
, eventDesc
.getY());
763 if (!gc
->isMovableInParentList())
765 if (abs(x
- _Parent
->getX()) > DELTA_BEFORE_POPUP
|| abs(y
- _Parent
->getY()) > DELTA_BEFORE_POPUP
)
767 setPoped(gc
, x
, y
, eventDesc
);
773 if (abs(y
- _Parent
->getY()) > DELTA_BEFORE_MOVING_IN_PARENT_LIST
)
775 // There should be at least one other entry in the parent list
776 CGroupList
*parentList
= dynamic_cast<CGroupList
*>(gc
->getParent());
777 if (!parentList
) return false;
778 if (parentList
->getNbElement() == 1) return false;
779 setMovingInParent(gc
, x
, y
, eventDesc
);
780 updateInsertionIndex(parentList
, eventDesc
.getY());
783 else // the mouse should move on the side of the container to turn it into a popup
784 //if (_Parent->getX() - x > DELTA_BEFORE_POPUP || x - (_Parent->getX() + _Parent->getWReal()) > DELTA_BEFORE_POPUP)
785 if (abs(x
- _Parent
->getX()) > DELTA_BEFORE_POPUP
)
787 setPoped(gc
, x
, y
, eventDesc
);
793 if (abs(x
- _Parent
->getX()) > 1 || abs(y
- _Parent
->getY()) > 1)
795 gc
->setHighLighted(true);
800 gc
->setHighLighted(false);
801 return true; // mouse has not moved enough
806 if (!_MovingInParentList
)
808 // clip, in real coords space
809 uint32 wScreen
, hScreen
;
810 CViewRenderer::getInstance()->getScreenSize(wScreen
, hScreen
);
814 clamp(x
, 0, (sint32
)wScreen
-_Parent
->getWReal());
815 clamp(y
, 0, (sint32
)hScreen
-_Parent
->getHReal());
822 CWidgetManager::getInstance()->snapIfClose(_Parent
);
824 // if some action handler to call when moving
825 if(gc
->getAHOnMovePtr())
827 // udpate XReal/YReal coords only of the container
828 gc
->CInterfaceElement::updateCoords();
830 CAHManager::getInstance()->runActionHandler(gc
->getAHOnMovePtr(), this, gc
->getAHOnMoveParams());
835 if (!gc
) return false;
836 const CGroupList
*gl
= gc
->getPreviousParentList();
839 updateInsertionIndex(gl
, eventDesc
.getY());
840 // compute visible portion of list
841 sint32 glSciX
, glSciY
, glSciW
, glSciH
;
842 gl
->getClip(glSciX
, glSciY
, glSciW
, glSciH
);
843 _ParentListTop
= glSciY
+ glSciH
;
844 _ParentListBottom
= glSciY
;
845 // the control is moving in its parent list, so the x coordinate doesn't change
846 y
+= _MoveDeltaYReal
;
847 // if the group is at the bottom of screen or at the bottom of the list, must clamp & scroll down
848 if (y
< _ParentListBottom
)
850 if (_ParentScrollingUp
)
852 _ParentScrollingUp
= false;
853 CWidgetManager::getInstance()->registerClockMsgTarget(this); // want to now when time pass
855 if (glSciY
> gl
->getYReal()) // is there need for scroll ?
857 if (!_ParentScrollingDown
)
859 _ParentScrollingDown
= true;
860 CWidgetManager::getInstance()->registerClockMsgTarget(this); // want to now when time pass
866 if (_ParentScrollingDown
)
868 _ParentScrollingDown
= false;
869 CWidgetManager::getInstance()->unregisterClockMsgTarget(this); // want to now when time pass
872 y
= _ParentListBottom
;
876 if (_ParentScrollingDown
)
878 _ParentScrollingDown
= false;
879 CWidgetManager::getInstance()->registerClockMsgTarget(this); // want to now when time pass
881 sint32 topY
= y
+ _Parent
->getHReal();
882 if (topY
> _ParentListTop
)
885 if (glSciY
+ glSciH
< gl
->getYReal() + gl
->getHReal()) // is there need for scroll ?
887 if (!_ParentScrollingUp
)
889 _ParentScrollingUp
= true;
890 CWidgetManager::getInstance()->registerClockMsgTarget(this); // want to now when time pass
896 if (_ParentScrollingUp
)
898 _ParentScrollingDown
= false;
899 CWidgetManager::getInstance()->unregisterClockMsgTarget(this); // want to now when time pass
902 y
= _ParentListTop
- _Parent
->getHReal();
905 y
-= _MoveDeltaYReal
;
910 // just invalidate position (1 pass)
911 _Parent
->invalidateCoords(1);
916 if (event
.getType() == NLGUI::CEventDescriptor::system
)
918 const NLGUI::CEventDescriptorSystem
&systemEvent
= (const NLGUI::CEventDescriptorSystem
&) event
;
919 if (systemEvent
.getEventTypeExtended() == NLGUI::CEventDescriptorSystem::clocktick
)
921 if (_WaitToOpenClose
)
923 uint dbclickDelay
= CWidgetManager::getInstance()->getUserDblClickDelay();
924 if ((times
.thisFrameMs
- _WaitToOpenCloseDate
) > dbclickDelay
)
926 CGroupContainer
*gc
= dynamic_cast<CGroupContainer
*>(_Parent
);
927 if (!gc
) return false;
928 _WaitToOpenClose
= false;
929 CWidgetManager::getInstance()->unregisterClockMsgTarget(this);
930 // do the open action
931 if (gc
->isOpenable() && !gc
->isOpenWhenPopup())
933 gc
->setOpen(!gc
->isOpen());
937 // if can't open, just call the action handler
938 return runTitleActionHandler();
942 else if (_ParentScrollingDown
|| _ParentScrollingUp
)
951 // ***************************************************************************
952 void CCtrlMover::handleScrolling()
954 const uint pixPerMS
= 7; // the number of millisecond to move of one pixel in the parent scrollbar
955 CGroupContainer
*gc
= dynamic_cast<CGroupContainer
*>(_Parent
);
957 CGroupList
*gl
= gc
->getPreviousParentList();
960 const CWidgetManager::SInterfaceTimes
×
= CWidgetManager::getInstance()->getInterfaceTimes();
962 if (_ParentScrollingUp
)
964 sint32 topPosY
= gl
->getChild(0)->getYReal();
965 // check if we are really at the end of the list, if this is not the case, we should perform scroll on parent container with a scroll bar
966 if (gc
->getYReal() < topPosY
)
968 _ScrollTime
+= times
.frameDiffMs
;
969 sint32 deltaY
= (sint32
) (_ScrollTime
/ pixPerMS
);
972 CGroupContainer
*currGC
= gc
->getPreviousContainer();
975 CCtrlScroll
*cs
= currGC
->getScroll();
978 sint32 dy
= cs
->moveTrackY(deltaY
);
981 currGC
= currGC
->getFatherContainer();
983 gl
->invalidateCoords();
984 gc
->invalidateCoords();
985 _ScrollTime
= _ScrollTime
% (sint64
) pixPerMS
;
990 _ParentScrollingUp
= false;
991 CWidgetManager::getInstance()->unregisterClockMsgTarget(this);
996 if (_ParentScrollingDown
)
998 // check if we are really at the end of the list, if this is not the case, we should perform scroll on parent container with a scroll bar
999 sint32 bottomPosY
= gl
->getChild(gl
->getNumChildren() - 1)->getYReal() - gl
->getChild(gl
->getNumChildren() - 1)->getHReal();
1000 if (gc
->getYReal() - gc
->getHReal() > bottomPosY
)
1002 _ScrollTime
+= times
.frameDiffMs
;
1003 sint32 deltaY
= - (sint32
) (_ScrollTime
/ pixPerMS
);
1006 CGroupContainer
*currGC
= gc
->getPreviousContainer();
1009 CCtrlScroll
*cs
= currGC
->getScroll();
1012 sint32 dy
= cs
->moveTrackY(deltaY
);
1015 currGC
= currGC
->getFatherContainer();
1017 gl
->invalidateCoords();
1018 gc
->invalidateCoords();
1019 _ScrollTime
= _ScrollTime
% pixPerMS
;
1024 _ParentScrollingDown
= false;
1025 CWidgetManager::getInstance()->unregisterClockMsgTarget(this);
1026 _InsertionIndex
= gl
->getNumChildren();
1031 // ***************************************************************************
1032 bool CCtrlMover::runTitleActionHandler()
1034 CGroupContainer
*gc
= dynamic_cast<CGroupContainer
*>(_Parent
);
1035 if (!gc
) return false;
1036 CInterfaceGroup
*gr
= gc
->isOpen() ? gc
->getHeaderOpened() : gc
->getHeaderClosed();
1037 if (gr
&& !gr
->getLeftClickHandler().empty())
1039 CAHManager::getInstance()->runActionHandler(gr
->getLeftClickHandler(), this, gr
->getLeftClickHandlerParams());
1042 // try with the main group
1043 if (!gc
->getLeftClickHandler().empty())
1045 CAHManager::getInstance()->runActionHandler(gc
->getLeftClickHandler(), this, gc
->getLeftClickHandlerParams());
1051 // ***************************************************************************
1052 void CCtrlMover::setPoped(CGroupContainer
*gc
, sint32 x
, sint32 y
, const NLGUI::CEventDescriptorMouse
&eventDesc
)
1054 gc
->setHighLighted(false);
1055 sint32 deltaX
= x
- _Parent
->getX();
1056 sint32 deltaY
= y
- _Parent
->getY();
1057 // pop up the window
1058 gc
->popupCurrentPos(); // NB : this has the side effect of destroying this object during the call to CGroupContainer::update(), because the mover is recreated during the setup !
1059 // So from now we shouldn't use anything that use the 'this' pointer
1060 // TODO : maybe there a more clean way to do that ? (except that we may not call update() in popupCurrentPos() )
1061 if (gc
->isLockable())
1063 gc
->setLocked(false);
1065 gc
->setW(gc
->getRefW());
1069 // now the window is in screen coordinates
1070 sint32 newX
= gc
->getXReal() + deltaX
;
1071 sint32 newY
= gc
->getYReal() + deltaY
;
1072 uint32 wScreen
, hScreen
;
1073 CViewRenderer::getInstance()->getScreenSize(wScreen
, hScreen
);
1074 clamp(newX
, 0, (sint32
)wScreen
- gc
->getWReal());
1075 clamp(newY
, 0, (sint32
)hScreen
- gc
->getHReal());
1078 gc
->setY(newY
+ gc
->getHReal());
1079 // just invalidate position (1 pass)
1082 // delegate to the new created control mover
1083 CCtrlMover
*cm
= gc
->getCtrlMover();
1084 cm
->_MoveStartX
= gc
->getX()-eventDesc
.getX();
1085 cm
->_MoveStartY
= gc
->getY()-eventDesc
.getY();
1086 cm
->_MoveDeltaXReal
= gc
->getXReal() - gc
->getX();
1087 cm
->_MoveDeltaYReal
= gc
->getYReal() - gc
->getY();
1089 CWidgetManager::getInstance()->setCapturePointerLeft(cm
);
1090 CWidgetManager::getInstance()->setCapturePointerRight(NULL
);
1093 // ***************************************************************************
1094 void CCtrlMover::setMovingInParent(CGroupContainer
*gc
, sint32
/* x */, sint32 y
, const NLGUI::CEventDescriptorMouse
&eventDesc
)
1097 sint32 deltaY
= y
- gc
->getY();
1098 CGroupList
*parentList
= dynamic_cast<CGroupList
*>(gc
->getParent());
1099 if (!parentList
) return;
1100 // sint32 startIndex = parentList->getElementIndex(gc);
1101 gc
->setHighLighted(false);
1102 sint32 oldX
= _Parent
->getXReal();
1103 gc
->setMovingInParentList(true);
1104 sint32 gcWidth
= gc
->getWReal();
1105 // pop up the window
1106 gc
->popupCurrentPos(); // this doesn't change the order in setup
1113 // now the window is in screen coordinates
1114 sint32 newY
= gc
->getYReal() + deltaY
;
1116 parentList
->updateCoords();
1117 // get clip rect from parent list
1118 sint32 glSciX
, glSciY
, glSciW
, glSciH
;
1119 parentList
->getClip(glSciX
, glSciY
, glSciW
, glSciH
);
1120 _ParentListTop
= glSciY
+ glSciH
;
1121 _ParentListBottom
= glSciY
;
1122 // clip by parent list coords
1123 clamp(newY
, _ParentListBottom
, _ParentListTop
- gc
->getHReal());
1125 gc
->setY(newY
+ gc
->getHReal());
1126 // just invalidate position (1 pass)
1130 _MoveStartY
= gc
->getY()-eventDesc
.getY();
1131 _MoveDeltaYReal
= gc
->getYReal() - gc
->getY();
1133 CWidgetManager::getInstance()->setCapturePointerLeft(this);
1134 CWidgetManager::getInstance()->setCapturePointerRight(NULL
);
1136 _MovingInParentList
= true;
1138 // register to get time events
1141 // ***************************************************************************
1142 void CCtrlMover::updateInsertionIndex(const CGroupList
*gl
, sint32 posY
)
1145 for(uint k
= 0; k
< gl
->getNumChildren(); ++k
)
1147 CViewBase
*child
= gl
->getChild(k
);
1148 if (child
->getYReal() <= posY
)
1150 if (posY
< child
->getYReal() + (child
->getHReal() >> 1))
1152 _InsertionIndex
= k
+ 1;
1157 _InsertionIndex
= k
;
1162 _InsertionIndex
= gl
->getNumChildren();
1165 // ***************************************************************************
1166 void CCtrlMover::stopMove()
1168 _ParentScrollingUp
= false;
1169 _ParentScrollingDown
= false;
1170 CWidgetManager::getInstance()->setCapturePointerLeft(NULL
);
1178 _MovingInParentList
= false;
1179 // insert at good position in the parent list
1180 CGroupContainer
*gc
= dynamic_cast<CGroupContainer
*>(_Parent
);
1182 gc
->popin(_InsertionIndex
);
1183 if (gc
->getChildrenObs())
1185 gc
->getChildrenObs()->childrenMoved(_StartIndex
, _InsertionIndex
, gc
);
1191 // ***************************************************************************
1193 // ***************************************************************************
1195 NLMISC_REGISTER_OBJECT(CViewBase
, CGroupContainer
, std::string
, "container");
1197 // ***************************************************************************
1198 CGroupContainer::CGroupContainer(const TCtorParam
¶m
)
1199 : CGroupContainerBase(param
)
1201 // faster than a virual call
1202 _IsGroupContainer
= true;
1204 _CurrentRolloverAlphaContainer
= 0.f
;
1205 _CurrentRolloverAlphaContent
= 0.f
;
1210 _HeaderOpened
= NULL
;
1211 _HeaderClosed
= NULL
;
1212 _TitleOpened
= NULL
;
1213 _TitleClosed
= NULL
;
1214 _TitleDeltaMaxW
= 0;
1215 _ViewOpenState
= NULL
;
1216 _RightButton
= NULL
;
1221 _OldFatherContainer
= NULL
;
1222 _InsertionOrder
= 0;
1233 _ChildrenObs
= NULL
;
1244 _OpenWhenPopup
= false;
1245 _OpenAtStart
= false;
1246 _OpenedBeforePopup
= false;
1250 _EnabledResizer
= true;
1251 _ResizerTopSize
= -1;
1253 _MovableInParentList
= false;
1256 _HighLighted
= false;
1258 _BlinkState
= false;
1259 _MovingInParentList
= false;
1260 _ActiveSavable
= true;
1262 _TitleClass
= TitleText
;
1264 _PositionBackuped
= false;
1267 _HeaderActive
= true;
1268 _EnabledRightButton
= true;
1269 _EnabledHelpButton
= true;
1270 _TitleOverExtendViewText
= false;
1276 _AHOnCloseButton
= NULL
;
1278 _AHOnDeactiveCheck
= NULL
;
1280 _AHOnAlphaSettingsChanged
= NULL
;
1281 _AHOnBeginMove
= NULL
;
1283 std::fill(_Resizer
, _Resizer
+ NumResizers
, (CCtrlResizer
*) 0);
1285 _ContentYOffset
= 0;
1288 // ***************************************************************************
1289 CGroupContainer::~CGroupContainer()
1293 // ***************************************************************************
1294 CGroupContainer::TTileClass
CGroupContainer::convertTitleClass(const char *ptr
)
1296 if(nlstricmp(ptr
, "formated")==0)
1297 return TitleTextFormated
;
1298 if(nlstricmp(ptr
, "text_id")==0)
1300 if(nlstricmp(ptr
, "text_dyn_string")==0)
1301 return TitleTextDynString
;
1306 std::string
CGroupContainer::getProperty( const std::string
&name
) const
1308 if( name
== "localize" )
1310 return toString( _Localize
);
1313 if( name
== "title_class" )
1315 switch( _TitleClass
)
1317 case TitleTextFormated
:
1325 case TitleTextDynString
:
1326 return "text_dyn_string";
1333 if( name
== "content_y_offset" )
1335 return toString( _ContentYOffset
);
1338 if( name
== "title" )
1340 if( _TitleTextOpened
== _TitleTextClosed
)
1341 return _TitleTextOpened
;
1346 if( name
== "title_opened" )
1348 return _TitleTextOpened
;
1351 if( name
== "title_closed" )
1353 return _TitleTextClosed
;
1356 if( name
== "header_active" )
1358 return toString( _HeaderActive
);
1361 if( name
== "header_color" )
1363 if( _HeaderColor
.getNodePtr() != NULL
)
1364 return _HeaderColor
.getNodePtr()->getFullName();
1369 if( name
== "right_button" )
1371 return toString( _EnabledRightButton
);
1374 if( name
== "help_button" )
1376 return toString( _EnabledHelpButton
);
1379 if( name
== "movable" )
1381 return toString( _Movable
);
1384 if( name
== "popable" )
1386 return toString( _Popable
);
1389 if( name
== "lockable" )
1391 return toString( _Lockable
);
1394 if( name
== "locked" )
1396 return toString( _Locked
);
1399 if( name
== "openable" )
1401 return toString( _Openable
);
1404 if( name
== "opened" )
1406 return toString( _Opened
);
1409 if( name
== "modal" )
1411 return toString( _Modal
);
1414 if( name
== "open_when_popup" )
1416 return toString( _OpenWhenPopup
);
1419 if( name
== "resizer" )
1421 return toString( _EnabledResizer
);
1424 if( name
== "resizer_top_size" )
1426 return toString( _ResizerTopSize
);
1429 if( name
== "on_open" )
1431 return getAHString( name
);
1434 if( name
== "on_open_params" )
1436 return _AHOnOpenParams
.toString();
1439 if( name
== "on_close" )
1441 return getAHString( name
);
1444 if( name
== "on_close_params" )
1446 return _AHOnCloseParams
.toString();
1449 if( name
== "on_close_button" )
1451 return getAHString( name
);
1454 if( name
== "on_close_button_params" )
1456 return _AHOnCloseButtonParams
.toString();
1459 if( name
== "on_move" )
1461 return getAHString( name
);
1464 if( name
== "on_move_params" )
1466 return _AHOnMoveParams
.toString();
1469 if( name
== "on_deactive_check" )
1471 return getAHString( name
);
1474 if( name
== "on_deactive_check_params" )
1476 return _AHOnDeactiveCheckParams
.toString();
1479 if( name
== "on_resize" )
1481 return getAHString( name
);
1484 if( name
== "on_resize_params" )
1486 return _AHOnResizeParams
.toString();
1489 if( name
== "on_alpha_settings_changed" )
1491 return getAHString( name
);
1494 if( name
== "on_alpha_settings_changed_params" )
1496 return _AHOnAlphaSettingsChangedParams
.toString();
1499 if( name
== "on_begin_move" )
1501 return getAHString( name
);
1504 if( name
== "on_begin_move_params" )
1506 return _AHOnBeginMoveParams
.toString();
1509 if( name
== "max_w" )
1511 return toString( _MaxW
);
1514 if( name
== "min_w" )
1516 return toString( _MinW
);
1519 if( name
== "pop_max_w" )
1521 return toString( _PopupMaxW
);
1524 if( name
== "pop_min_w" )
1526 return toString( _PopupMinW
);
1529 if( name
== "pop_max_h" )
1531 return toString( _PopupMaxH
);
1534 if( name
== "pop_min_h" )
1536 return toString( _PopupMinH
);
1539 if( name
== "movable_in_parent_list" )
1541 return toString( _MovableInParentList
);
1544 if( name
== "savable" )
1546 return toString( _Savable
);
1549 if( name
== "active_savable" )
1551 return toString( _ActiveSavable
);
1554 if( name
== "modal_parent" )
1556 return _ModalParentNames
;
1559 if( name
== "options" )
1561 return _OptionsName
;
1564 if( name
== "title_delta_max_w" )
1566 return toString( _TitleDeltaMaxW
);
1569 if( name
== "title_over_extend_view_text" )
1571 return toString( _TitleOverExtendViewText
);
1574 if( name
== "help_page" )
1576 return _HelpPage
.toString();
1579 return CInterfaceGroup::getProperty( name
);
1583 void CGroupContainer::setProperty( const std::string
&name
, const std::string
&value
)
1585 if( name
== "localize" )
1588 if( fromString( value
, b
) )
1593 if( name
== "title_class" )
1595 if( value
== "formated" )
1596 _TitleClass
= TitleTextFormated
;
1598 if( value
== "text_id" )
1599 _TitleClass
= TitleTextId
;
1601 if( value
== "text_dyn_string" )
1602 _TitleClass
= TitleTextDynString
;
1604 _TitleClass
= TitleText
;
1610 if( name
== "content_y_offset" )
1613 if( fromString( value
, i
) )
1614 _ContentYOffset
= i
;
1618 if( name
== "title" )
1620 _TitleTextOpened
= _TitleTextClosed
= value
;
1624 if( name
== "title_opened" )
1626 _TitleTextOpened
= value
;
1630 if( name
== "title_closed" )
1632 _TitleTextClosed
= value
;
1636 if( name
== "header_active" )
1639 if( fromString( value
, b
) )
1644 if( name
== "header_color" )
1646 _HeaderColor
.link( value
.c_str() );
1650 if( name
== "right_button" )
1653 if( fromString( value
, b
) )
1654 _EnabledRightButton
= b
;
1658 if( name
== "help_button" )
1661 if( fromString( value
, b
) )
1662 _EnabledHelpButton
= b
;
1666 if( name
== "movable" )
1669 if( fromString( value
, b
) )
1674 if( name
== "popable" )
1677 if( fromString( value
, b
) )
1682 if( name
== "lockable" )
1685 if( fromString( value
, b
) )
1690 if( name
== "locked" )
1693 if( fromString( value
, b
) )
1698 if( name
== "openable" )
1701 if( fromString( value
, b
) )
1706 if( name
== "opened" )
1709 if( fromString( value
, b
) )
1714 if( name
== "modal" )
1717 if( fromString( value
, b
) )
1722 if( name
== "open_when_popup" )
1725 if( fromString( value
, b
) )
1730 if( name
== "resizer" )
1733 if( fromString( value
, b
) )
1734 _EnabledResizer
= b
;
1738 if( name
== "resizer_top_size" )
1741 if( fromString( value
, i
) )
1742 _ResizerTopSize
= i
;
1746 if( name
== "on_open" )
1749 _AHOnOpen
= CAHManager::getInstance()->getAH( value
, dummy
);
1750 mapAHString( name
, value
);
1754 if( name
== "on_open_params" )
1756 _AHOnOpenParams
= value
;
1760 if( name
== "on_close" )
1763 _AHOnClose
= CAHManager::getInstance()->getAH( value
, dummy
);
1764 mapAHString( name
, value
);
1768 if( name
== "on_close_params" )
1770 _AHOnCloseParams
= value
;
1774 if( name
== "on_close_button" )
1777 _AHOnCloseButton
= CAHManager::getInstance()->getAH( value
, dummy
);
1778 mapAHString( name
, value
);
1782 if( name
== "on_close_button_params" )
1784 _AHOnCloseButtonParams
= value
;
1788 if( name
== "on_move" )
1791 _AHOnMove
= CAHManager::getInstance()->getAH( value
, dummy
);
1792 mapAHString( name
, value
);
1796 if( name
== "on_move_params" )
1798 _AHOnMoveParams
= value
;
1802 if( name
== "on_deactive_check" )
1805 _AHOnDeactiveCheck
= CAHManager::getInstance()->getAH( value
, dummy
);
1806 mapAHString( name
, value
);
1810 if( name
== "on_deactive_check_params" )
1812 _AHOnDeactiveCheckParams
= value
;
1816 if( name
== "on_resize" )
1819 _AHOnResize
= CAHManager::getInstance()->getAH( value
, dummy
);
1820 mapAHString( name
, value
);
1824 if( name
== "on_resize_params" )
1826 _AHOnResizeParams
= value
;
1830 if( name
== "on_alpha_settings_changed" )
1833 _AHOnAlphaSettingsChanged
= CAHManager::getInstance()->getAH( value
, dummy
);
1834 mapAHString( name
, value
);
1838 if( name
== "on_alpha_settings_changed_params" )
1840 _AHOnAlphaSettingsChangedParams
= value
;
1844 if( name
== "on_begin_move" )
1847 _AHOnBeginMove
= CAHManager::getInstance()->getAH( value
, dummy
);
1848 mapAHString( name
, value
);
1852 if( name
== "on_begin_move_params" )
1854 _AHOnBeginMoveParams
= value
;
1858 if( name
== "max_w" )
1861 if( fromString( value
, i
) )
1866 if( name
== "min_w" )
1869 if( fromString( value
, i
) )
1874 if( name
== "pop_max_w" )
1877 if( fromString( value
, i
) )
1882 if( name
== "pop_min_w" )
1885 if( fromString( value
, i
) )
1890 if( name
== "pop_max_h" )
1893 if( fromString( value
, i
) )
1898 if( name
== "pop_min_h" )
1901 if( fromString( value
, i
) )
1906 if( name
== "movable_in_parent_list" )
1909 if( fromString( value
, b
) )
1910 _MovableInParentList
= b
;
1914 if( name
== "savable" )
1917 if( fromString( value
, b
) )
1922 if( name
== "active_savable" )
1925 if( fromString( value
, b
) )
1930 if( name
== "modal_parent" )
1932 _ModalParentNames
= value
;
1936 if( name
== "options" )
1938 _OptionsName
= value
;
1942 if( name
== "title_delta_max_w" )
1945 if( fromString( value
, i
) )
1946 _TitleDeltaMaxW
= i
;
1950 if( name
== "title_over_extend_view_text" )
1953 if( fromString( value
, b
) )
1954 _TitleOverExtendViewText
= b
;
1958 if( name
== "help_page" )
1964 CInterfaceGroup::setProperty( name
, value
);
1967 xmlNodePtr
CGroupContainer::serialize( xmlNodePtr parentNode
, const char *type
) const
1969 xmlNodePtr node
= CInterfaceGroup::serialize( parentNode
, type
);
1973 xmlSetProp( node
, BAD_CAST
"type", BAD_CAST
"container" );
1974 xmlSetProp( node
, BAD_CAST
"localize", BAD_CAST
toString( _Localize
).c_str() );
1976 std::string titleClass
;
1977 switch( _TitleClass
)
1979 case TitleTextFormated
:
1980 titleClass
= "formated";
1984 titleClass
= "text_id";
1987 case TitleTextDynString
:
1988 titleClass
= "text_dyn_string";
1992 titleClass
= "text";
1996 xmlSetProp( node
, BAD_CAST
"title_class", BAD_CAST titleClass
.c_str() );
1997 xmlSetProp( node
, BAD_CAST
"content_y_offset", BAD_CAST
toString( _ContentYOffset
).c_str() );
1999 if( _TitleTextOpened
== _TitleTextClosed
)
2000 xmlSetProp( node
, BAD_CAST
"title", BAD_CAST _TitleTextOpened
.c_str() );
2002 xmlSetProp( node
, BAD_CAST
"title", BAD_CAST
"" );
2004 xmlSetProp( node
, BAD_CAST
"title_opened", BAD_CAST _TitleTextOpened
.c_str() );
2005 xmlSetProp( node
, BAD_CAST
"title_closed", BAD_CAST _TitleTextClosed
.c_str() );
2006 xmlSetProp( node
, BAD_CAST
"header_active", BAD_CAST
toString( _HeaderActive
).c_str() );
2008 if( _HeaderColor
.getNodePtr() != NULL
)
2009 xmlSetProp( node
, BAD_CAST
"header_color", BAD_CAST _HeaderColor
.getNodePtr()->getFullName().c_str() );
2011 xmlSetProp( node
, BAD_CAST
"header_color", BAD_CAST
"" );
2013 xmlSetProp( node
, BAD_CAST
"right_button", BAD_CAST
toString( _EnabledRightButton
).c_str() );
2014 xmlSetProp( node
, BAD_CAST
"help_button", BAD_CAST
toString( _EnabledHelpButton
).c_str() );
2015 xmlSetProp( node
, BAD_CAST
"movable", BAD_CAST
toString( _Movable
).c_str() );
2016 xmlSetProp( node
, BAD_CAST
"popable", BAD_CAST
toString( _Popable
).c_str() );
2017 xmlSetProp( node
, BAD_CAST
"lockable", BAD_CAST
toString( _Lockable
).c_str() );
2018 xmlSetProp( node
, BAD_CAST
"locked", BAD_CAST
toString( _Locked
).c_str() );
2019 xmlSetProp( node
, BAD_CAST
"openable", BAD_CAST
toString( _Openable
).c_str() );
2020 xmlSetProp( node
, BAD_CAST
"opened", BAD_CAST
toString( _Opened
).c_str() );
2021 xmlSetProp( node
, BAD_CAST
"modal", BAD_CAST
toString( _Modal
).c_str() );
2022 xmlSetProp( node
, BAD_CAST
"open_when_popup", BAD_CAST
toString( _OpenWhenPopup
).c_str() );
2023 xmlSetProp( node
, BAD_CAST
"resizer", BAD_CAST
toString( _EnabledResizer
).c_str() );
2024 xmlSetProp( node
, BAD_CAST
"resizer_top_size", BAD_CAST
toString( _ResizerTopSize
).c_str() );
2026 xmlSetProp( node
, BAD_CAST
"on_open",
2027 BAD_CAST
getAHString( "on_open" ).c_str() );
2029 xmlSetProp( node
, BAD_CAST
"on_open_params",
2030 BAD_CAST _AHOnOpenParams
.toString().c_str() );
2032 xmlSetProp( node
, BAD_CAST
"on_close",
2033 BAD_CAST
getAHString( "on_close" ).c_str() );
2035 xmlSetProp( node
, BAD_CAST
"on_close_params",
2036 BAD_CAST _AHOnCloseParams
.toString().c_str() );
2038 xmlSetProp( node
, BAD_CAST
"on_close_button",
2039 BAD_CAST
getAHString( "on_close_button" ).c_str() );
2041 xmlSetProp( node
, BAD_CAST
"on_close_button_params",
2042 BAD_CAST _AHOnCloseButtonParams
.toString().c_str() );
2044 xmlSetProp( node
, BAD_CAST
"on_move",
2045 BAD_CAST
getAHString( "on_move" ).c_str() );
2047 xmlSetProp( node
, BAD_CAST
"on_close_params",
2048 BAD_CAST _AHOnMoveParams
.toString().c_str() );
2050 xmlSetProp( node
, BAD_CAST
"on_deactive_check",
2051 BAD_CAST
getAHString( "on_deactive_check" ).c_str() );
2053 xmlSetProp( node
, BAD_CAST
"on_deactive_check_params",
2054 BAD_CAST _AHOnDeactiveCheckParams
.toString().c_str() );
2056 xmlSetProp( node
, BAD_CAST
"on_resize",
2057 BAD_CAST
getAHString( "on_resize" ).c_str() );
2059 xmlSetProp( node
, BAD_CAST
"on_resize_params",
2060 BAD_CAST _AHOnResizeParams
.toString().c_str() );
2062 xmlSetProp( node
, BAD_CAST
"on_alpha_settings_changed",
2063 BAD_CAST
getAHString( "on_alpha_settings_changed" ).c_str() );
2065 xmlSetProp( node
, BAD_CAST
"on_alpha_settings_changed_params",
2066 BAD_CAST _AHOnAlphaSettingsChangedParams
.toString().c_str() );
2068 xmlSetProp( node
, BAD_CAST
"on_begin_move",
2069 BAD_CAST
getAHString( "on_begin_move" ).c_str() );
2071 xmlSetProp( node
, BAD_CAST
"on_begin_move_params",
2072 BAD_CAST _AHOnBeginMoveParams
.toString().c_str() );
2074 xmlSetProp( node
, BAD_CAST
"max_w", BAD_CAST
toString( _MaxW
).c_str() );
2075 xmlSetProp( node
, BAD_CAST
"min_w", BAD_CAST
toString( _MinW
).c_str() );
2076 xmlSetProp( node
, BAD_CAST
"pop_max_w", BAD_CAST
toString( _PopupMaxW
).c_str() );
2077 xmlSetProp( node
, BAD_CAST
"pop_min_w", BAD_CAST
toString( _PopupMinW
).c_str() );
2078 xmlSetProp( node
, BAD_CAST
"pop_max_h", BAD_CAST
toString( _PopupMaxH
).c_str() );
2079 xmlSetProp( node
, BAD_CAST
"pop_min_h", BAD_CAST
toString( _PopupMinH
).c_str() );
2080 xmlSetProp( node
, BAD_CAST
"movable_in_parent_list", BAD_CAST
toString( _MovableInParentList
).c_str() );
2081 xmlSetProp( node
, BAD_CAST
"savable", BAD_CAST
toString( _Savable
).c_str() );
2082 xmlSetProp( node
, BAD_CAST
"active_savable", BAD_CAST
toString( _ActiveSavable
).c_str() );
2083 xmlSetProp( node
, BAD_CAST
"modal_parents", BAD_CAST _ModalParentNames
.c_str() );
2084 xmlSetProp( node
, BAD_CAST
"options", BAD_CAST _OptionsName
.toString().c_str() );
2085 xmlSetProp( node
, BAD_CAST
"title_delta_max_w", BAD_CAST
toString( _TitleDeltaMaxW
).c_str() );
2086 xmlSetProp( node
, BAD_CAST
"title_over_extend_view_text", BAD_CAST
toString( _TitleOverExtendViewText
).c_str() );
2087 xmlSetProp( node
, BAD_CAST
"help_page", BAD_CAST _HelpPage
.toString().c_str() );
2093 xmlNodePtr
CGroupContainer::serializeTreeData( xmlNodePtr parentNode
) const
2095 xmlNodePtr node
= CInterfaceGroup::serializeTreeData( parentNode
);
2102 CInterfaceGroup
*g
= NULL
;
2103 for( sint32 i
= 0; i
< _List
->getChildrenNb(); i
++ )
2105 g
= dynamic_cast< CInterfaceGroup
* >( _List
->getChild( i
) );
2109 if( g
->serializeTreeData( node
) == NULL
)
2116 // ***************************************************************************
2117 bool CGroupContainer::parse(xmlNodePtr cur
, CInterfaceGroup
* parentGroup
)
2119 if (!CInterfaceGroup::parse(cur
,parentGroup
))
2123 ptr
= xmlGetProp (cur
, (xmlChar
*)"localize");
2124 if (ptr
) _Localize
= convertBool((const char*)ptr
);
2126 // Type of the view text of the title
2127 ptr
= xmlGetProp (cur
, (xmlChar
*)"title_class");
2130 _TitleClass
= convertTitleClass((const char*)ptr
);
2131 // if textid, don't localize, because the title is a DB path
2132 if(_TitleClass
==TitleTextId
|| _TitleClass
==TitleTextDynString
)
2136 // y offset for content
2137 ptr
= xmlGetProp (cur
, (xmlChar
*)"content_y_offset");
2140 fromString((const char*)ptr
, _ContentYOffset
);
2143 // text of the title
2144 ptr
= xmlGetProp (cur
, (xmlChar
*)"title");
2147 _TitleTextOpened
= (const char *)ptr
;
2148 _TitleTextClosed
= (const char *)ptr
;
2151 ptr
= xmlGetProp (cur
, (xmlChar
*)"title_opened");
2154 _TitleTextOpened
= (const char*)ptr
;
2157 ptr
= xmlGetProp (cur
, (xmlChar
*)"title_closed");
2160 _TitleTextClosed
= (const char *)ptr
;
2163 ptr
= xmlGetProp (cur
, (xmlChar
*)"header_active");
2165 _HeaderActive
= convertBool(ptr
);
2167 ptr
= xmlGetProp (cur
, (xmlChar
*)"header_color");
2169 _HeaderColor
.link(ptr
);
2171 ptr
= xmlGetProp (cur
, (xmlChar
*)"right_button");
2174 _EnabledRightButton
= convertBool(ptr
);
2175 // Default; take same state than the right button
2176 _EnabledHelpButton
= _EnabledRightButton
;
2179 // but user may ovveride this case
2180 ptr
= xmlGetProp (cur
, (xmlChar
*)"help_button");
2182 _EnabledHelpButton
= convertBool(ptr
);
2184 ptr
= xmlGetProp (cur
, (xmlChar
*)"movable");
2186 _Movable
= convertBool(ptr
);
2188 ptr
= xmlGetProp (cur
, (xmlChar
*)"popable");
2190 _Popable
= convertBool(ptr
);
2192 ptr
= xmlGetProp (cur
, (xmlChar
*)"lockable");
2194 _Lockable
= convertBool(ptr
);
2196 ptr
= xmlGetProp (cur
, (xmlChar
*)"locked");
2198 _Locked
= convertBool(ptr
);
2200 ptr
= xmlGetProp (cur
, (xmlChar
*)"openable");
2202 _Openable
= convertBool(ptr
);
2204 ptr
= xmlGetProp (cur
, (xmlChar
*)"opened");
2206 _OpenAtStart
= convertBool(ptr
);
2208 ptr
= xmlGetProp (cur
, (xmlChar
*)"modal");
2210 _Modal
= convertBool(ptr
);
2212 ptr
= xmlGetProp (cur
, (xmlChar
*)"open_when_popup");
2215 _OpenWhenPopup
= convertBool(ptr
);
2217 _OpenAtStart
= false;
2220 ptr
= xmlGetProp (cur
, (xmlChar
*)"resizer");
2222 _EnabledResizer
= convertBool(ptr
);
2224 ptr
= xmlGetProp (cur
, (xmlChar
*)"resizer_top_size");
2225 _ResizerTopSize
= -1;
2227 fromString((const char*)ptr
, _ResizerTopSize
);
2229 CAHManager::getInstance()->parseAH(cur
, "on_open", "on_open_params", _AHOnOpen
, _AHOnOpenParams
);
2230 CAHManager::getInstance()->parseAH(cur
, "on_close", "on_close_params", _AHOnClose
, _AHOnCloseParams
);
2231 CAHManager::getInstance()->parseAH(cur
, "on_close_button", "on_close_button_params", _AHOnCloseButton
, _AHOnCloseButtonParams
);
2232 CAHManager::getInstance()->parseAH(cur
, "on_move", "on_move_params", _AHOnMove
, _AHOnMoveParams
);
2233 CAHManager::getInstance()->parseAH(cur
, "on_deactive_check", "on_deactive_check_params", _AHOnDeactiveCheck
, _AHOnDeactiveCheckParams
);
2234 CAHManager::getInstance()->parseAH(cur
, "on_resize", "on_resize_params", _AHOnResize
, _AHOnResizeParams
);
2235 CAHManager::getInstance()->parseAH(cur
, "on_alpha_settings_changed", "on_alpha_settings_changed_params", _AHOnAlphaSettingsChanged
, _AHOnAlphaSettingsChangedParams
);
2236 CAHManager::getInstance()->parseAH(cur
, "on_begin_move", "on_begin_move_params", _AHOnBeginMove
, _AHOnBeginMoveParams
);
2241 ptr
= xmlGetProp( cur
, BAD_CAST
"on_open" );
2243 mapAHString( "on_open", std::string( (const char*)ptr
) );
2245 ptr
= xmlGetProp( cur
, BAD_CAST
"on_close" );
2247 mapAHString( "on_close", std::string( (const char*)ptr
) );
2249 ptr
= xmlGetProp( cur
, BAD_CAST
"on_close_button" );
2251 mapAHString( "on_close_button", std::string( (const char*)ptr
) );
2253 ptr
= xmlGetProp( cur
, BAD_CAST
"on_move" );
2255 mapAHString( "on_move", std::string( (const char*)ptr
) );
2257 ptr
= xmlGetProp( cur
, BAD_CAST
"on_deactive_check" );
2259 mapAHString( "on_deactive_check", std::string( (const char*)ptr
) );
2261 ptr
= xmlGetProp( cur
, BAD_CAST
"on_resize" );
2263 mapAHString( "on_resize", std::string( (const char*)ptr
) );
2265 ptr
= xmlGetProp( cur
, BAD_CAST
"on_alpha_settings_changed" );
2267 mapAHString( "on_alpha_settings_changed", std::string( (const char*)ptr
) );
2269 ptr
= xmlGetProp( cur
, BAD_CAST
"on_begin_move" );
2271 mapAHString( "on_begin_move", std::string( (const char*)ptr
) );
2274 ptr
= xmlGetProp (cur
, (xmlChar
*)"max_w");
2276 fromString((const char*)ptr
, _MaxW
);
2277 ptr
= xmlGetProp (cur
, (xmlChar
*)"min_w");
2279 fromString((const char*)ptr
, _MinW
);
2281 ptr
= xmlGetProp (cur
, (xmlChar
*)"pop_max_w");
2283 fromString((const char*)ptr
, _PopupMaxW
);
2284 ptr
= xmlGetProp (cur
, (xmlChar
*)"pop_min_w");
2286 fromString((const char*)ptr
, _PopupMinW
);
2288 ptr
= xmlGetProp (cur
, (xmlChar
*)"pop_max_h");
2290 fromString((const char*)ptr
, _PopupMaxH
);
2291 ptr
= xmlGetProp (cur
, (xmlChar
*)"pop_min_h");
2293 fromString((const char*)ptr
, _PopupMinH
);
2295 ptr
= xmlGetProp (cur
, (xmlChar
*)"movable_in_parent_list");
2296 if (ptr
) _MovableInParentList
= convertBool(ptr
);
2298 ptr
= xmlGetProp (cur
, (xmlChar
*)"savable");
2299 if (ptr
) _Savable
= convertBool(ptr
);
2301 ptr
= xmlGetProp (cur
, (xmlChar
*)"active_savable");
2302 if (ptr
) _ActiveSavable
= convertBool(ptr
);
2304 ptr
= xmlGetProp (cur
, (xmlChar
*)"modal_parent");
2305 if (ptr
) _ModalParentNames
= (const char*)ptr
;
2307 ptr
= xmlGetProp (cur
, (xmlChar
*)"options");
2308 if (ptr
) _OptionsName
= (const char*)ptr
;
2310 ptr
= xmlGetProp (cur
, (xmlChar
*)"title_delta_max_w");
2311 if (ptr
) fromString((const char*)ptr
, _TitleDeltaMaxW
);
2313 ptr
= xmlGetProp (cur
, (xmlChar
*)"title_over_extend_view_text");
2314 _TitleOverExtendViewText
= false;
2315 if (ptr
) _TitleOverExtendViewText
= convertBool(ptr
);
2318 ptr
= xmlGetProp (cur
, (xmlChar
*)"help_page");
2319 if (ptr
) _HelpPage
= (const char*)ptr
;
2325 // ***************************************************************************
2326 void CGroupContainer::updateCoords()
2328 if (_Mover
&& _Mover
->isMovingInParentList())
2330 // must clamp by parent coords, now it has been updated
2331 CGroupList
*gl
= getPreviousParentList();
2334 sint32 cx
, cy
, cw
, ch
;
2335 gl
->getClip(cx
, cy
, cw
, ch
);
2336 sint32 currYReal
= getYReal();
2337 clamp(currYReal
, cy
, cy
+ ch
- getHReal());
2338 if (currYReal
!= getYReal())
2340 setY(getY() + currYReal
- getYReal());
2347 bool bHasChild
= (_List
->getNbElement() > 0);
2349 // clamp popupmaxh if resizemax mode
2350 if ((_LayerSetup
== 0) && bHasChild
&& _EnabledResizer
)
2354 CViewRenderer
&vr
= *CViewRenderer::getInstance();
2355 vr
.getScreenSize(sw
, sh
);
2356 // ensure the maxH is > minH and < sh (prioritary > minH, in case of sh<minh)
2357 _PopupMaxH
= min(_PopupMaxH
, (sint32
)sh
);
2358 _PopupMaxH
= max(_PopupMaxH
, _PopupMinH
);
2361 // clamp w/h if standard resizer
2362 if ((_LayerSetup
== 0) && (!bHasChild
) && _EnabledResizer
)
2364 clamp(_W
, _PopupMinW
, _PopupMaxW
);
2365 clamp(_H
, _PopupMinH
, _PopupMaxH
);
2366 // Clip by screen (but minw/minh is prioritary)
2368 CViewRenderer
&vr
= *CViewRenderer::getInstance();
2369 vr
.getScreenSize(sw
, sh
);
2370 if((sint32
)sw
>_PopupMinW
&& _W
>(sint32
)sw
) _W
= sw
;
2371 if((sint32
)sh
>_PopupMinH
&& _H
>(sint32
)sh
) _H
= sh
;
2374 COptionsLayer
*pLayer
= getContainerOptions();
2377 // Get base header size
2378 if (_LayerSetup
== 0)
2380 setMaxH(_PopupMaxH
);
2381 // _W is given by scripter-man
2382 newH
= (pLayer
->H_T
- pLayer
->InsetT
);
2388 _W
= _Parent
->getW();
2390 setMaxH (std::numeric_limits
<sint32
>::max()); // No scrollbar for container of layer > 0
2391 newH
= (pLayer
->H_T
- pLayer
->InsetT
);
2396 if (_HeaderOpened
!= NULL
)
2398 if (_HeaderOpened
->getPosRef()&Hotspot_xR
)
2399 _HeaderOpened
->setX (-pLayer
->W_R
);
2400 if (_HeaderOpened
->getPosRef()&Hotspot_xL
)
2401 _HeaderOpened
->setX (pLayer
->W_L
);
2402 _HeaderOpened
->setY (- newH
);
2403 _HeaderOpened
->setW (_W
-(pLayer
->W_L
+pLayer
->W_R
));
2404 _HeaderOpened
->updateCoords();
2405 newH
+= max (_HeaderOpened
->getHReal(), pLayer
->HeaderH
);
2409 newH
+= pLayer
->HeaderH
;
2412 newH
-= (sint32
) _ContentYOffset
;
2414 // Calculate content size part
2415 if (_Content
!= NULL
)
2417 if (_Content
->getPosRef()&Hotspot_xR
)
2418 _Content
->setX (-pLayer
->W_R
);
2419 else if (_Content
->getPosRef()&Hotspot_xL
)
2420 _Content
->setX (pLayer
->W_L
);
2421 _Content
->setY (-newH
);
2422 _Content
->setW (-(pLayer
->W_L
+pLayer
->W_R
));
2423 if ((bHasChild
) || (!_EnabledResizer
) || (_LayerSetup
>0)) // Content is constant in H
2425 _Content
->setSizeRef (1); // w
2426 _Content
->updateCoords();
2427 newH
+= _Content
->getHReal();
2431 _Content
->setSizeRef (3); // wh
2432 _Content
->setH (-newH
- pLayer
->H_B
); // Sub header and top, bottom bitmaps
2437 newH
+= pLayer
->H_B_Open
;
2439 newH
+= pLayer
->H_B
;
2441 if (_LayerSetup
== 0)
2443 _List
->setX (pLayer
->W_M_Open
);
2444 _ScrollBar
->setX (pLayer
->Scrollbar_Offset_X
);
2445 _ScrollBar
->setY(-newH
);
2451 _List
->setY (-newH
);
2453 // Calculate list max height if top container
2454 if (_LayerSetup
== 0)
2456 // zeH is the height to substract to total height of the container to obtain height of the list
2457 sint32 zeH
= (pLayer
->H_T
- pLayer
->InsetT
) + pLayer
->H_B_Open
+ pLayer
->H_EM_Open
;
2459 if (_HeaderOpened
!= NULL
)
2460 zeH
+= max (_HeaderOpened
->getHReal(), pLayer
->HeaderH
);
2462 zeH
+= pLayer
->HeaderH
;
2464 if (_Content
!= NULL
)
2465 zeH
+= _Content
->getHReal();
2468 _List
->setMaxH (max((sint32
)0, _MaxH
-zeH
));
2473 _List
->setMaxH (std::numeric_limits
<sint32
>::max());
2476 if (_LayerSetup
== 0)
2478 _List
->forceSizeW(_W
- (pLayer
->W_M_Open
+ pLayer
->W_R
) );
2482 _List
->forceSizeW(_W
);
2486 //CInterfaceElement::updateCoords();
2487 CInterfaceGroup::updateCoords();
2489 newH
+= ((_List
->getHReal() < _List
->getMaxH()) ? _List
->getHReal() : _List
->getMaxH());
2491 if (_LayerSetup
== 0)
2493 if ((!bHasChild
) || (_List
->getHReal() < _List
->getMaxH()))
2494 _ScrollBar
->setActive (false);
2496 _ScrollBar
->setActive (true);
2499 if (_LayerSetup
== 0)
2501 if (_List
->getNbElement() > 0)
2503 newH
+= pLayer
->H_EM_Open
;
2507 if ((bHasChild
) || (!_EnabledResizer
) || (_LayerSetup
>0)) // H is depending on the header and content and list
2513 if (_HeaderClosed
!= NULL
)
2515 if (_HeaderClosed
->getPosRef()&Hotspot_xR
)
2516 _HeaderClosed
->setX (-pLayer
->W_R
);
2517 else if (_HeaderClosed
->getPosRef()&Hotspot_xL
)
2518 _HeaderClosed
->setX (pLayer
->W_L
);
2519 _HeaderClosed
->setY (-newH
);
2520 _HeaderClosed
->setW (_W
-(pLayer
->W_L
+pLayer
->W_R
));
2521 _HeaderClosed
->updateCoords();
2522 newH
+= max (_HeaderClosed
->getHReal(), pLayer
->HeaderH
);
2526 newH
+= pLayer
->HeaderH
;
2528 newH
+= pLayer
->H_B
;
2530 if ((bHasChild
) || (!_EnabledResizer
) || (_LayerSetup
>0)) // H is depending on the header and content and list
2533 CInterfaceGroup::updateCoords();
2539 _Mover
->setW (_W
+_MoverDeltaW
);
2540 _Mover
->updateCoords();
2543 // Set MaxW for title according to current Container Width
2544 _TitleOpened
->setLineMaxW(_W
+ _TitleDeltaMaxW
);
2545 _TitleClosed
->setLineMaxW(_W
+ _TitleDeltaMaxW
);
2547 _TitleOpened
->updateCoords();
2548 _TitleClosed
->updateCoords();
2549 if (_ViewOpenState
!= NULL
) _ViewOpenState
->updateCoords();
2550 if (_RightButton
!= NULL
) _RightButton
->updateCoords();
2551 if (_HelpButton
!= NULL
) _HelpButton
->updateCoords();
2552 if (_ScrollBar
!= NULL
) _ScrollBar
->updateCoords();
2553 if (_Content
!= NULL
) _Content
->updateCoords();
2554 if (_HeaderClosed
!= NULL
) _HeaderClosed
->updateCoords();
2555 if (_HeaderOpened
!= NULL
) _HeaderOpened
->updateCoords();
2557 CInterfaceElement::updateCoords();
2559 if (_LayerSetup
== 0)
2561 // test if must clip
2562 uint32 wScreen
, hScreen
;
2563 CViewRenderer::getInstance()->getScreenSize(wScreen
, hScreen
);
2564 if (_WReal
<= (sint32
) wScreen
&& _HReal
<= (sint32
) hScreen
)
2566 sint32 newX
= _XReal
;
2567 sint32 newY
= _YReal
;
2568 clamp(newX
, 0, (sint32
)wScreen
- _WReal
);
2569 clamp(newY
, 0, (sint32
)hScreen
- _HReal
);
2570 if (newX
!= _XReal
|| newY
!= _YReal
)
2572 setX(_X
+ newX
- _XReal
);
2573 setY(_Y
+ newY
- _YReal
);
2574 CInterfaceGroup::updateCoords();
2580 for(uint k
= 0; k
< NumResizers
; ++k
)
2582 if (_Resizer
[k
]) updateResizerSize(_Resizer
[k
]);
2586 // ***************************************************************************
2587 void CGroupContainer::updateResizerSize(CCtrlResizer
*cr
)
2589 COptionsContainerMove
*options
= getMoveOptions();
2590 if (!options
) return;
2592 // Yoyo: The +1 stuff is important, maybe because of the HotSpot MiddleMiddle style...
2595 if (!(cr
->getResizerPos() & Hotspot_Tx
) && !(cr
->getResizerPos() & Hotspot_Bx
))
2597 // if no special topH size
2598 if(_ResizerTopSize
<0)
2599 cr
->setH (_H
- 2 * options
->ResizerSize
+ 1); // Bottom and Top same value
2601 cr
->setH (_H
- options
->ResizerSize
- _ResizerTopSize
+ 1); // Top different from bottom
2605 // if no special topH size, or if the resizer is not the top one
2606 if(_ResizerTopSize
<0 || !(cr
->getResizerPos() & Hotspot_Tx
))
2607 cr
->setH(options
->ResizerSize
+ 1);
2609 cr
->setH(_ResizerTopSize
+ 1);
2613 if (!(cr
->getResizerPos() & Hotspot_xR
) && !(cr
->getResizerPos() & Hotspot_xL
))
2615 cr
->setW (_W
- 2 * options
->ResizerSize
+ 1);
2619 cr
->setW(options
->ResizerSize
+ 1);
2622 // update coordinate
2626 // ***************************************************************************
2627 void CGroupContainer::draw ()
2629 H_AUTO( RZ_Interface_CGroupContainer_draw
)
2631 if (_LayerSetup
== -1) return;
2633 float speed
= CWidgetManager::getInstance()->getAlphaRolloverSpeed();
2634 const CWidgetManager::SInterfaceTimes
×
= CWidgetManager::getInstance()->getInterfaceTimes();
2636 CRGBA oldGlobalColor
= CWidgetManager::getInstance()->getGlobalColor();
2637 CRGBA oldGColForGrayed
= CWidgetManager::getInstance()->getGlobalColor();
2640 const uint blinkDuration
= 300;
2641 if (((_BlinkDT
/ 300) & 1) == 0)
2643 CRGBA newCol
= oldGlobalColor
;
2644 clamp(newCol
.R
, 64, 192);
2645 clamp(newCol
.G
, 64, 192);
2646 clamp(newCol
.B
, 64, 192);
2647 newCol
.R
= ~newCol
.R
;
2648 newCol
.G
= ~newCol
.G
;
2649 newCol
.B
= ~newCol
.B
;
2650 if (abs(newCol
.R
- oldGlobalColor
.R
) < 64) newCol
.R
= 192;
2651 if (abs(newCol
.G
- oldGlobalColor
.G
) < 64) newCol
.G
= 192;
2652 if (abs(newCol
.B
- oldGlobalColor
.B
) < 64) newCol
.B
= 192;
2653 CWidgetManager::getInstance()->setGlobalColor(newCol
);
2658 if (_BlinkState
) // was previously on ?
2660 if (_NumBlinks
!= 0) // if dont blink for ever
2663 if (_NumBlinks
== 0)
2669 _BlinkState
= false;
2671 _BlinkDT
+= std::min((uint
) times
.frameDiffMs
, blinkDuration
);
2674 CGroupContainer
*parentGC
= NULL
;
2675 if (getParent() && getParent()->getParent())
2677 if (getParent()->getParent()->isGroupContainer())
2679 parentGC
= static_cast<CGroupContainer
*>(getParent()->getParent());
2683 sint32 oldSciX
, oldSciY
, oldSciW
, oldSciH
;
2684 makeNewClip (oldSciX
, oldSciY
, oldSciW
, oldSciH
);
2686 // Draw the container
2687 CViewRenderer
&rVR
= *CViewRenderer::getInstance();
2688 CRGBA col
= CWidgetManager::getInstance()->getGlobalColor();
2690 bool bGrayed
= isGrayed();
2696 CWidgetManager::getInstance()->setGlobalColor(col
);
2697 oldGlobalColor
.R
= oldGlobalColor
.R
/ 2;
2698 oldGlobalColor
.G
= oldGlobalColor
.G
/ 2;
2699 oldGlobalColor
.B
= oldGlobalColor
.B
/ 2;
2702 if (_MovingInParentList
)
2704 // display half tone when moving in parent
2707 // if the father is a group container, do modulation too
2710 // _CurrentContainerAlpha = (uint8) (((uint16) parentGC->getCurrentContainerAlpha() * (uint16) _ContainerAlpha) >> 8);
2711 _CurrentContainerAlpha
= parentGC
->getCurrentContainerAlpha();
2715 _CurrentContainerAlpha
= _UseGlobalAlpha
? CWidgetManager::getInstance()->getGlobalContainerAlpha() : _ContainerAlpha
;
2717 // modulate by container alpha color
2718 col
.A
= (uint8
) (((uint16
) _CurrentContainerAlpha
* (uint16
) col
.A
) >> 8);
2719 // Modulate by parent rollover
2722 // _ICurrentRolloverAlpha = (uint8) (((uint16) parentGC->_ICurrentRolloverAlpha * (uint16) _ICurrentRolloverAlpha) >> 8);
2723 _ICurrentRolloverAlphaContent
= parentGC
->_ICurrentRolloverAlphaContent
;
2724 _ICurrentRolloverAlphaContainer
= parentGC
->_ICurrentRolloverAlphaContainer
;
2728 uint8 rolloverFactorContent
= _UseGlobalAlpha
? (255 - CWidgetManager::getInstance()->getGlobalRolloverFactorContent()) : _RolloverAlphaContent
;
2729 _ICurrentRolloverAlphaContent
= (uint8
) (255 - rolloverFactorContent
+ rolloverFactorContent
* _CurrentRolloverAlphaContent
);
2730 uint8 rolloverFactorContainer
= _UseGlobalAlpha
? (255 - CWidgetManager::getInstance()->getGlobalRolloverFactorContainer()) : _RolloverAlphaContainer
;
2731 _ICurrentRolloverAlphaContainer
= (uint8
) (255 - rolloverFactorContainer
+ rolloverFactorContainer
* _CurrentRolloverAlphaContainer
);
2733 // Modulate alpha by rollover alpha
2734 col
.A
= (uint8
) (((uint16
) _ICurrentRolloverAlphaContainer
* (uint16
) col
.A
) >> 8);
2736 COptionsLayer
*pLayer
= getContainerOptions();
2737 // h is the size of what is on top of the child list
2740 bool bHasChild
= (_List
->getNbElement() > 0);
2741 h
= (pLayer
->H_T
- pLayer
->InsetT
) + (((!_Opened
) || (!bHasChild
)) ? pLayer
->H_B
: pLayer
->H_B_Open
);
2745 if (_HeaderOpened
!= NULL
)
2746 h
+= max (_HeaderOpened
->getHReal(), pLayer
->HeaderH
);
2748 h
+= pLayer
->HeaderH
;
2750 if (_Content
!= NULL
)
2751 h
+= _Content
->getHReal();
2754 h
+= _List
->getHReal();
2756 h
-= _ContentYOffset
;
2764 y
= _YReal
+_HReal
-h
;
2766 sint8 rl
= _RenderLayer
;
2767 if (_LayerSetup
== 0)
2770 rVR
.drawRotFlipBitmap (rl
, x
, y
+h
-pLayer
->H_TL
, pLayer
->W_TL
, pLayer
->H_TL
, 0, false, pLayer
->TxId_TL
, col
);
2772 if (pLayer
->Tile_T
== 0) // Tiling ?
2773 rVR
.drawRotFlipBitmap (rl
, x
+pLayer
->W_TL
, y
+h
-pLayer
->H_T
, w
-(pLayer
->W_TL
+pLayer
->W_TR
), pLayer
->H_T
, 0, false, pLayer
->TxId_T
, col
);
2775 rVR
.drawRotFlipBitmapTiled (rl
, x
+pLayer
->W_TL
, y
+h
-pLayer
->H_T
, w
-(pLayer
->W_TL
+pLayer
->W_TR
), pLayer
->H_T
, 0, false, pLayer
->TxId_T
, pLayer
->Tile_T
-1, col
);
2777 rVR
.drawRotFlipBitmap (rl
, x
+w
-pLayer
->W_TR
, y
+h
-pLayer
->H_TR
, pLayer
->W_TR
, pLayer
->H_TR
, 0, false, pLayer
->TxId_TR
, col
);
2779 if ((!_Opened
) || (!bHasChild
))
2782 if (pLayer
->Tile_L
== 0) // Tiling ?
2783 rVR
.drawRotFlipBitmap (rl
, x
, y
+pLayer
->H_BL
, pLayer
->W_L
, h
-(pLayer
->H_BL
+pLayer
->H_TL
), 0, false, pLayer
->TxId_L
, col
);
2785 rVR
.drawRotFlipBitmapTiled (rl
, x
, y
+pLayer
->H_BL
, pLayer
->W_L
, h
-(pLayer
->H_BL
+pLayer
->H_TL
), 0, false, pLayer
->TxId_L
, pLayer
->Tile_L
-1, col
);
2787 if (pLayer
->Tile_R
== 0) // Tiling ?
2788 rVR
.drawRotFlipBitmap (rl
, x
+w
-pLayer
->W_R
, y
+pLayer
->H_BR
, pLayer
->W_R
, h
-(pLayer
->H_TR
+pLayer
->H_BR
), 0, false, pLayer
->TxId_R
, col
);
2790 rVR
.drawRotFlipBitmapTiled (rl
, x
+w
-pLayer
->W_R
, y
+pLayer
->H_BR
, pLayer
->W_R
, h
-(pLayer
->H_TR
+pLayer
->H_BR
), 0, false, pLayer
->TxId_R
, pLayer
->Tile_R
-1, col
);
2792 rVR
.drawRotFlipBitmap (rl
, x
, y
, pLayer
->W_BL
, pLayer
->H_BL
, 0, false, pLayer
->TxId_BL
, col
);
2794 if (pLayer
->Tile_B
== 0) // Tiling ?
2795 rVR
.drawRotFlipBitmap (rl
, x
+pLayer
->W_BL
, y
, w
-(pLayer
->W_BL
+pLayer
->W_BR
), pLayer
->H_B
, 0, false, pLayer
->TxId_B
, col
);
2797 rVR
.drawRotFlipBitmapTiled (rl
, x
+pLayer
->W_BL
, y
, w
-(pLayer
->W_BL
+pLayer
->W_BR
), pLayer
->H_B
, 0, false, pLayer
->TxId_B
, pLayer
->Tile_B
-1, col
);
2799 rVR
.drawRotFlipBitmap (rl
, x
+w
-pLayer
->W_BR
, y
, pLayer
->W_BR
, pLayer
->H_BR
, 0, false, pLayer
->TxId_BR
, col
);
2801 if (pLayer
->Tile_Blank
== 0) // Tiling ?
2802 rVR
.drawRotFlipBitmap (rl
, x
+pLayer
->W_L
, y
+pLayer
->H_B
, w
-(pLayer
->W_R
+pLayer
->W_L
), h
-(pLayer
->H_B
+pLayer
->H_T
), 0, false, pLayer
->TxId_Blank
, col
);
2804 rVR
.drawRotFlipBitmapTiled (rl
, x
+pLayer
->W_L
, y
+pLayer
->H_B
, w
-(pLayer
->W_R
+pLayer
->W_L
), h
-(pLayer
->H_B
+pLayer
->H_T
), 0, false, pLayer
->TxId_Blank
, pLayer
->Tile_Blank
-1, col
);
2809 if (pLayer
->Tile_L
== 0) // Tiling ?
2810 rVR
.drawRotFlipBitmap (rl
, x
, y
+pLayer
->H_BL_Open
, pLayer
->W_L
, h
-(pLayer
->H_BL_Open
+pLayer
->H_TL
), 0, false, pLayer
->TxId_L
, col
);
2812 rVR
.drawRotFlipBitmapTiled (rl
, x
, y
+pLayer
->H_BL_Open
, pLayer
->W_L
, h
-(pLayer
->H_BL_Open
+pLayer
->H_TL
), 0, false, pLayer
->TxId_L
, pLayer
->Tile_L
-1, col
);
2814 if (pLayer
->Tile_R
== 0) // Tiling ?
2815 rVR
.drawRotFlipBitmap (rl
, x
+w
-pLayer
->W_R
, y
+pLayer
->H_BR_Open
, pLayer
->W_R
, h
-(pLayer
->H_TR
+pLayer
->H_BR_Open
), 0, false, pLayer
->TxId_R
, col
);
2817 rVR
.drawRotFlipBitmapTiled (rl
, x
+w
-pLayer
->W_R
, y
+pLayer
->H_BR_Open
, pLayer
->W_R
, h
-(pLayer
->H_TR
+pLayer
->H_BR_Open
), 0, false, pLayer
->TxId_R
, pLayer
->Tile_R
-1, col
);
2819 rVR
.drawRotFlipBitmap (rl
, x
, y
, pLayer
->W_BL_Open
, pLayer
->H_BL_Open
, 0, false, pLayer
->TxId_BL_Open
, col
);
2821 if (pLayer
->Tile_B_Open
== 0) // Tiling ?
2822 rVR
.drawRotFlipBitmap (rl
, x
+pLayer
->W_BL_Open
, y
, w
-(pLayer
->W_BL_Open
+pLayer
->W_BR_Open
), pLayer
->H_B_Open
, 0, false, pLayer
->TxId_B_Open
, col
);
2824 rVR
.drawRotFlipBitmapTiled (rl
, x
+pLayer
->W_BL_Open
, y
, w
-(pLayer
->W_BL_Open
+pLayer
->W_BR_Open
), pLayer
->H_B_Open
, 0, false, pLayer
->TxId_B_Open
, pLayer
->Tile_B_Open
-1, col
);
2826 rVR
.drawRotFlipBitmap (rl
, x
+w
-pLayer
->W_BR_Open
, y
, pLayer
->W_BR_Open
, pLayer
->H_BR_Open
, 0, false, pLayer
->TxId_BR_Open
, col
);
2828 if (pLayer
->Tile_Blank
== 0) // Tiling ?
2829 rVR
.drawRotFlipBitmap (rl
, x
+pLayer
->W_L
, y
+pLayer
->H_B_Open
, w
-(pLayer
->W_R
+pLayer
->W_L
), h
-(pLayer
->H_B_Open
+pLayer
->H_T
), 0, false, pLayer
->TxId_Blank
, col
);
2831 rVR
.drawRotFlipBitmapTiled (rl
, x
+pLayer
->W_L
, y
+pLayer
->H_B_Open
, w
-(pLayer
->W_R
+pLayer
->W_L
), h
-(pLayer
->H_B_Open
+pLayer
->H_T
), 0, false, pLayer
->TxId_Blank
, pLayer
->Tile_Blank
-1, col
);
2832 // ScrollBar Placement
2833 if (pLayer
->Tile_M_Open
== 0) // Tiling ?
2834 rVR
.drawRotFlipBitmap (rl
, x
, _YReal
+pLayer
->H_EL_Open
, pLayer
->W_M_Open
, _HReal
-h
-pLayer
->H_EL_Open
, 0, false, pLayer
->TxId_M_Open
, col
);
2836 rVR
.drawRotFlipBitmapTiled (rl
, x
, _YReal
+pLayer
->H_EL_Open
, pLayer
->W_M_Open
, _HReal
-h
-pLayer
->H_EL_Open
, 0, false, pLayer
->TxId_M_Open
, pLayer
->Tile_M_Open
-1, col
);
2838 rVR
.drawRotFlipBitmap (rl
, x
, _YReal
, pLayer
->W_EL_Open
, pLayer
->H_EL_Open
, 0, false, pLayer
->TxId_EL_Open
, col
);
2840 if (pLayer
->Tile_EM_Open
== 0) // Tiling ?
2841 rVR
.drawRotFlipBitmap (rl
, x
+pLayer
->W_EL_Open
, _YReal
, w
-(pLayer
->W_EL_Open
+pLayer
->W_ER_Open
), pLayer
->H_EM_Open
, 0, false, pLayer
->TxId_EM_Open
, col
);
2843 rVR
.drawRotFlipBitmapTiled (rl
, x
+pLayer
->W_EL_Open
, _YReal
, w
-(pLayer
->W_EL_Open
+pLayer
->W_ER_Open
), pLayer
->H_EM_Open
, 0, false, pLayer
->TxId_EM_Open
, pLayer
->Tile_EM_Open
-1, col
);
2845 rVR
.drawRotFlipBitmap (rl
, x
+w
-pLayer
->W_ER_Open
, _YReal
, pLayer
->W_ER_Open
, pLayer
->H_ER_Open
, 0, false, pLayer
->TxId_ER_Open
, col
);
2848 else // Version for layer 1,2,3
2851 rVR
.drawRotFlipBitmap (rl
, x
, y
+h
-pLayer
->H_TL
, pLayer
->W_TL
, pLayer
->H_TL
, 0, false, pLayer
->TxId_TL
, col
);
2853 if (pLayer
->Tile_T
== 0) // Tiling ?
2854 rVR
.drawRotFlipBitmap (rl
, x
+pLayer
->W_TL
, y
+h
-pLayer
->H_T
, w
-(pLayer
->W_TL
+pLayer
->W_TR
), pLayer
->H_T
, 0, false, pLayer
->TxId_T
, col
);
2856 rVR
.drawRotFlipBitmapTiled (rl
, x
+pLayer
->W_TL
, y
+h
-pLayer
->H_T
, w
-(pLayer
->W_TL
+pLayer
->W_TR
), pLayer
->H_T
, 0, false, pLayer
->TxId_T
, pLayer
->Tile_T
-1, col
);
2858 rVR
.drawRotFlipBitmap (rl
, x
+w
-pLayer
->W_TR
, y
+h
-pLayer
->H_TR
, pLayer
->W_TR
, pLayer
->H_TR
, 0, false, pLayer
->TxId_TR
, col
);
2860 if ((!_Opened
) || (!bHasChild
))
2863 if (pLayer
->Tile_L
== 0) // Tiling ?
2864 rVR
.drawRotFlipBitmap (rl
, x
, y
+pLayer
->H_BL
, pLayer
->W_L
, h
-(pLayer
->H_BL
+pLayer
->H_TL
), 0, false, pLayer
->TxId_L
, col
);
2866 rVR
.drawRotFlipBitmapTiled (rl
, x
, y
+pLayer
->H_BL
, pLayer
->W_L
, h
-(pLayer
->H_BL
+pLayer
->H_TL
), 0, false, pLayer
->TxId_L
, pLayer
->Tile_L
-1, col
);
2868 if (pLayer
->Tile_R
== 0) // Tiling ?
2869 rVR
.drawRotFlipBitmap (rl
, x
+w
-pLayer
->W_R
, y
+pLayer
->H_BR
, pLayer
->W_R
, h
-(pLayer
->H_BL
+pLayer
->H_TL
), 0, false, pLayer
->TxId_R
, col
);
2871 rVR
.drawRotFlipBitmapTiled (rl
, x
+w
-pLayer
->W_R
, y
+pLayer
->H_BR
, pLayer
->W_R
, h
-(pLayer
->H_BL
+pLayer
->H_TL
), 0, false, pLayer
->TxId_R
, pLayer
->Tile_R
-1, col
);
2873 rVR
.drawRotFlipBitmap (rl
, x
, y
, pLayer
->W_BL
, pLayer
->H_BL
, 0, false, pLayer
->TxId_BL
, col
);
2875 if (pLayer
->Tile_B
== 0) // Tiling ?
2876 rVR
.drawRotFlipBitmap (rl
, x
+pLayer
->W_BL
, y
, w
-(pLayer
->W_BL
+pLayer
->W_BR
), pLayer
->H_B
, 0, false, pLayer
->TxId_B
, col
);
2878 rVR
.drawRotFlipBitmapTiled (rl
, x
+pLayer
->W_BL
, y
, w
-(pLayer
->W_BL
+pLayer
->W_BR
), pLayer
->H_B
, 0, false, pLayer
->TxId_B
, pLayer
->Tile_B
-1, col
);
2880 rVR
.drawRotFlipBitmap (rl
, x
+w
-pLayer
->W_BR
, y
, pLayer
->W_BR
, pLayer
->H_BR
, 0, false, pLayer
->TxId_BR
, col
);
2882 if (pLayer
->Tile_Blank
== 0) // Tiling ?
2883 rVR
.drawRotFlipBitmap (rl
, x
+pLayer
->W_L
, y
+pLayer
->H_B
, w
-(pLayer
->W_L
+pLayer
->W_R
), h
-(pLayer
->H_B
+pLayer
->H_T
), 0, false, pLayer
->TxId_Blank
, col
);
2885 rVR
.drawRotFlipBitmapTiled (rl
, x
+pLayer
->W_L
, y
+pLayer
->H_B
, w
-(pLayer
->W_L
+pLayer
->W_R
), h
-(pLayer
->H_B
+pLayer
->H_T
), 0, false, pLayer
->TxId_Blank
, pLayer
->Tile_Blank
-1, col
);
2890 if (pLayer
->Tile_L
== 0) // Tiling ?
2891 rVR
.drawRotFlipBitmap (rl
, x
, y
+pLayer
->H_BL_Open
, pLayer
->W_L
, h
-(pLayer
->H_BL_Open
+pLayer
->H_TL
), 0, false, pLayer
->TxId_L
, col
);
2893 rVR
.drawRotFlipBitmapTiled (rl
, x
, y
+pLayer
->H_BL_Open
, pLayer
->W_L
, h
-(pLayer
->H_BL_Open
+pLayer
->H_TL
), 0, false, pLayer
->TxId_L
, pLayer
->Tile_L
-1, col
);
2895 if (pLayer
->Tile_R
== 0) // Tiling ?
2896 rVR
.drawRotFlipBitmap (rl
, x
+w
-pLayer
->W_R
, y
+pLayer
->H_BR_Open
, pLayer
->W_R
, h
-(pLayer
->H_TR
+pLayer
->H_BR_Open
), 0, false, pLayer
->TxId_R
, col
);
2898 rVR
.drawRotFlipBitmapTiled (rl
, x
+w
-pLayer
->W_R
, y
+pLayer
->H_BR_Open
, pLayer
->W_R
, h
-(pLayer
->H_TR
+pLayer
->H_BR_Open
), 0, false, pLayer
->TxId_R
, pLayer
->Tile_R
-1, col
);
2900 rVR
.drawRotFlipBitmap (rl
, x
, y
, pLayer
->W_BL_Open
, pLayer
->H_BL_Open
, 0, false, pLayer
->TxId_BL_Open
, col
);
2902 if (pLayer
->Tile_B_Open
== 0) // Tiling ?
2903 rVR
.drawRotFlipBitmap (rl
, x
+pLayer
->W_BL_Open
, y
, w
-(pLayer
->W_BL_Open
+pLayer
->W_BR_Open
), pLayer
->H_B_Open
, 0, false, pLayer
->TxId_B_Open
, col
);
2905 rVR
.drawRotFlipBitmapTiled (rl
, x
+pLayer
->W_BL_Open
, y
, w
-(pLayer
->W_BL_Open
+pLayer
->W_BR_Open
), pLayer
->H_B_Open
, 0, false, pLayer
->TxId_B_Open
, pLayer
->Tile_B_Open
-1, col
);
2907 rVR
.drawRotFlipBitmap (rl
, x
+w
-pLayer
->W_BR_Open
, y
, pLayer
->W_BR_Open
, pLayer
->H_BR_Open
, 0, false, pLayer
->TxId_BR_Open
, col
);
2909 if (pLayer
->Tile_Blank
== 0)
2910 rVR
.drawRotFlipBitmap (rl
, x
+pLayer
->W_L
, y
+pLayer
->H_B_Open
, w
-(pLayer
->W_L
+pLayer
->W_R
), h
-(pLayer
->H_B_Open
+pLayer
->H_T
), 0, false, pLayer
->TxId_Blank
, col
);
2912 rVR
.drawRotFlipBitmapTiled (rl
, x
+pLayer
->W_L
, y
+pLayer
->H_B_Open
, w
-(pLayer
->W_L
+pLayer
->W_R
), h
-(pLayer
->H_B_Open
+pLayer
->H_T
), 0, false, pLayer
->TxId_Blank
, pLayer
->Tile_Blank
-1, col
);
2919 CWidgetManager::getInstance()->setGlobalColor(oldGlobalColor
);
2922 // Top window : title is highlighted
2923 if (_LayerSetup
== 0)
2925 CRGBA c
= CRGBA(255,255,255,255);
2926 // Display the header in white if we are the last clicked window
2927 if (CWidgetManager::getInstance()->getTopWindow(CWidgetManager::getInstance()->getLastTopWindowPriority()) != this)
2929 if (_HeaderColor
.getNodePtr() != NULL
)
2930 c
= _HeaderColor
.getRGBA();
2939 if (_TitleClosed
!= NULL
) _TitleClosed
->setColor(c
);
2940 if (_TitleOpened
!= NULL
) _TitleOpened
->setColor(c
);
2941 if (_ViewOpenState
!= NULL
) _ViewOpenState
->setColor(c
);
2942 if (_RightButton
!= NULL
)
2944 _RightButton
->setColor(c
);
2945 _RightButton
->setColorPushed(c
);
2946 _RightButton
->setColorOver(c
);
2948 if (_HelpButton
!= NULL
)
2950 _HelpButton
->setColor(c
);
2951 _HelpButton
->setColorPushed(c
);
2952 _HelpButton
->setColorOver(c
);
2956 // Render inside window
2958 uint8 oldAlphaContent
= CWidgetManager::getInstance()->getContentAlpha();
2959 uint8 oldAlphaContainer
= _CurrentContainerAlpha
;
2962 // _CurrentContentAlpha = (uint8) (((uint16) _ContentAlpha * (uint16) parentGC->getCurrentContentAlpha()) >> 8);
2963 _CurrentContentAlpha
= parentGC
->getCurrentContentAlpha();
2964 _CurrentContainerAlpha
= parentGC
->getCurrentContainerAlpha();
2968 _CurrentContentAlpha
= _UseGlobalAlpha
? CWidgetManager::getInstance()->getGlobalContentAlpha() : _ContentAlpha
;
2969 _CurrentContainerAlpha
= _UseGlobalAlpha
? CWidgetManager::getInstance()->getGlobalContainerAlpha() : _ContainerAlpha
;
2971 // set content alpha multiplied by rollover alpha
2972 CWidgetManager::getInstance()->setContentAlpha((uint8
) (((uint16
) _CurrentContentAlpha
* (uint16
) _ICurrentRolloverAlphaContent
) >> 8));
2973 // set content alpha multiplied by rollover alpha
2974 _CurrentContainerAlpha
= (uint8
) (((uint16
) _CurrentContainerAlpha
* (uint16
) _ICurrentRolloverAlphaContainer
) >> 8);
2976 // Display the color title bar (if the header is active)
2977 if (_LayerSetup
== 0)
2981 CRGBA
c(255,255,255,255);
2982 if (_HeaderColor
.getNodePtr() != NULL
)
2983 c
= _HeaderColor
.getRGBA();
2990 c
.A
= (uint8
) (((uint16
) _CurrentContentAlpha
* (uint16
) _ICurrentRolloverAlphaContent
) >> 8);
2992 rVR
.drawRotFlipBitmap (rl
, x
, y
+h
-pLayer
->H_L_Header
, pLayer
->W_L_Header
, pLayer
->H_L_Header
, 0, false, pLayer
->TxId_L_Header
, c
);
2994 if (pLayer
->Tile_M_Header
== 0) // Tiling ?
2995 rVR
.drawRotFlipBitmap (rl
, x
+pLayer
->W_L_Header
, y
+h
-pLayer
->H_M_Header
, w
-(pLayer
->W_L_Header
+pLayer
->W_R_Header
), pLayer
->H_M_Header
, 0, false, pLayer
->TxId_M_Header
, c
);
2997 rVR
.drawRotFlipBitmapTiled (rl
, x
+pLayer
->W_L_Header
, y
+h
-pLayer
->H_M_Header
, w
-(pLayer
->W_L_Header
+pLayer
->W_R_Header
), pLayer
->H_M_Header
, 0, false, pLayer
->TxId_M_Header
, pLayer
->Tile_M_Header
-1, c
);
2999 rVR
.drawRotFlipBitmap (rl
, x
+w
-pLayer
->W_R_Header
, y
+h
-pLayer
->H_R_Header
, pLayer
->W_R_Header
, pLayer
->H_R_Header
, 0, false, pLayer
->TxId_R_Header
, c
);
3004 CInterfaceGroup::draw();
3007 if (_LayerSetup
== 0)
3008 if ((_HighLighted
) || (_CurrentContainerAlpha
<= 128))
3010 uint8 nInverted
= (128-_CurrentContainerAlpha
)/2;
3014 col
.A
= max(_HighLightedAlpha
, nInverted
);
3016 rVR
.drawRotFlipBitmap (_RenderLayer
, x
, y
+ h
- pLayer
->H_T_HighLight
, pLayer
->W_TL_HighLight
, pLayer
->H_TL_HighLight
, 0, false, pLayer
->TxId_TL_HighLight
, col
);
3017 rVR
.drawRotFlipBitmap (_RenderLayer
, x
+ _WReal
- pLayer
->W_TR_HighLight
, y
+ h
- pLayer
->H_T_HighLight
, pLayer
->W_TR_HighLight
, pLayer
->H_TR_HighLight
, 0, false, pLayer
->TxId_TR_HighLight
, col
);
3018 rVR
.drawRotFlipBitmap (_RenderLayer
, x
, _YReal
, pLayer
->W_BL_HighLight
, pLayer
->H_BL_HighLight
, 0, false, pLayer
->TxId_BL_HighLight
, col
);
3019 rVR
.drawRotFlipBitmap (_RenderLayer
, x
+ _WReal
- pLayer
->W_BR_HighLight
, _YReal
, pLayer
->W_BR_HighLight
, pLayer
->H_BR_HighLight
, 0, false, pLayer
->TxId_BR_HighLight
, col
);
3021 rVR
.drawRotFlipBitmap (_RenderLayer
, x
+ pLayer
->W_TL_HighLight
, y
+ h
- pLayer
->H_T_HighLight
, _WReal
- pLayer
->W_TL_HighLight
- pLayer
->W_TR_HighLight
, pLayer
->H_T_HighLight
, 0, false, pLayer
->TxId_T_HighLight
, col
);
3022 rVR
.drawRotFlipBitmap (_RenderLayer
, x
+ pLayer
->W_BL_HighLight
, _YReal
, _WReal
- pLayer
->W_BL_HighLight
- pLayer
->W_BR_HighLight
, pLayer
->H_B_HighLight
, 0, false, pLayer
->TxId_B_HighLight
, col
);
3023 rVR
.drawRotFlipBitmap (_RenderLayer
, x
, _YReal
+ pLayer
->H_B_HighLight
, pLayer
->W_L_HighLight
, _HReal
- pLayer
->H_T_HighLight
- pLayer
->H_B_HighLight
, 0, false, pLayer
->TxId_L_HighLight
, col
);
3024 rVR
.drawRotFlipBitmap (_RenderLayer
, x
+ _WReal
- pLayer
->W_R_HighLight
, _YReal
+ pLayer
->H_B_HighLight
, pLayer
->W_R_HighLight
, _HReal
- pLayer
->H_T_HighLight
- pLayer
->H_B_HighLight
, 0, false, pLayer
->TxId_R_HighLight
, col
);
3028 CWidgetManager::getInstance()->setContentAlpha(oldAlphaContent
);
3029 _CurrentContainerAlpha
= oldAlphaContainer
;
3033 CViewPointerBase
*mousePointer
= CWidgetManager::getInstance()->getPointer();
3036 bool dontFade
= false;
3037 // bool alphaUp = false;
3038 // should not applied if the container is being resized
3039 if (CWidgetManager::getInstance()->getCapturePointerLeft() != NULL
)
3041 CInterfaceGroup
*ig
= CWidgetManager::getInstance()->getCapturePointerLeft()->getParent();
3049 ig
= ig
->getParent();
3053 if (hasKeyboardFocus()) dontFade
=true;
3055 bool isOver
= false;
3057 if (CWidgetManager::getInstance()->getCapturePointerLeft() == NULL
)
3058 if (isIn(mousePointer
->getX(), mousePointer
->getY()))
3060 CInterfaceGroup
*ig
= CWidgetManager::getInstance()->getCurrentWindowUnder();
3068 ig
= ig
->getParent();
3071 if (dontFade
|| isOver
)
3073 _CurrentRolloverAlphaContent
+= (float) (speed
* times
.frameDiffMs
);
3074 _CurrentRolloverAlphaContent
= std::min(1.f
, _CurrentRolloverAlphaContent
);
3076 _CurrentRolloverAlphaContainer
+= (float) (speed
* times
.frameDiffMs
);
3077 _CurrentRolloverAlphaContainer
= std::min(1.f
, _CurrentRolloverAlphaContainer
);
3081 _CurrentRolloverAlphaContent
-= (float) (speed
* times
.frameDiffMs
);
3082 _CurrentRolloverAlphaContent
= std::max(0.f
, _CurrentRolloverAlphaContent
);
3084 _CurrentRolloverAlphaContainer
-= (float) (speed
* times
.frameDiffMs
);
3085 _CurrentRolloverAlphaContainer
= std::max(0.f
, _CurrentRolloverAlphaContainer
);
3091 CWidgetManager::getInstance()->setGlobalColor(oldGColForGrayed
);
3095 // Restore the old clip window
3096 restoreClip (oldSciX
, oldSciY
, oldSciW
, oldSciH
);
3099 // ***************************************************************************
3100 void CGroupContainer::clearViews()
3102 CInterfaceGroup::clearViews();
3105 // ***************************************************************************
3106 bool CGroupContainer::handleEvent (const NLGUI::CEventDescriptor
& event
)
3111 if (_MovingInParentList
)
3116 if (!checkIfModal(event
))
3119 if (!CInterfaceGroup::handleEvent(event
))
3121 if (event
.getType() == NLGUI::CEventDescriptor::mouse
)
3123 const NLGUI::CEventDescriptorMouse
&eventDesc
= (const NLGUI::CEventDescriptorMouse
&)event
;
3125 if ((_LayerSetup
== 0) && (isIn(eventDesc
.getX(), eventDesc
.getY())))
3127 if (eventDesc
.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mousewheel
)
3129 if (_ScrollBar
!= NULL
)
3130 _ScrollBar
->moveTrackY (eventDesc
.getWheel()*12);
3141 // ***************************************************************************
3142 void CGroupContainer::open()
3146 _OpenAtStart
= true;
3147 if (_TitleOpened
!= NULL
) _TitleOpened
->setActive(true);
3148 if (_TitleClosed
!= NULL
) _TitleClosed
->setActive(false);
3150 if ((_Openable
) && (_LayerSetup
>= 0))
3152 COptionsLayer
*pLayer
= getContainerOptions();
3153 if (_ViewOpenState
!= NULL
) _ViewOpenState
->setTexture(pLayer
->getValStr ("open_state_tx_opened"));
3156 if (_List
!= NULL
) _List
->setActive(true);
3158 if (_ScrollBar
!= NULL
) _ScrollBar
->setActive(true);
3159 if (_Content
!= NULL
) _Content
->setActive(true);
3160 if (_HeaderClosed
!= NULL
) _HeaderClosed
->setActive(false);
3161 if (_HeaderOpened
!= NULL
) _HeaderOpened
->setActive(true);
3165 // call action handler if any
3166 if (_AHOnOpen
!= NULL
)
3168 CAHManager::getInstance()->runActionHandler(_AHOnOpen
, this, _AHOnOpenParams
);
3173 // ***************************************************************************
3174 void CGroupContainer::close()
3177 if (_TitleOpened
!= NULL
) _TitleOpened
->setActive(false);
3178 if (_TitleClosed
!= NULL
) _TitleClosed
->setActive(true);
3179 if ((_Openable
) && (_LayerSetup
>= 0))
3181 COptionsLayer
*pLayer
= getContainerOptions();
3182 if (_ViewOpenState
!= NULL
) _ViewOpenState
->setTexture(pLayer
->getValStr ("open_state_tx_closed"));
3184 if (_List
!= NULL
) _List
->setActive(false);
3186 if (_ScrollBar
!= NULL
) _ScrollBar
->setActive(false);
3187 if (_Content
!= NULL
) _Content
->setActive(false);
3188 if (_HeaderClosed
!= NULL
) _HeaderClosed
->setActive(true);
3189 if (_HeaderOpened
!= NULL
) _HeaderOpened
->setActive(false);
3192 // call action handler if any
3193 if (_AHOnClose
!= NULL
)
3195 CAHManager::getInstance()->runActionHandler(_AHOnClose
, this, _AHOnCloseParams
);
3199 // ***************************************************************************
3200 void CGroupContainer::attachContainer (CGroupContainer
*pIC
, sint insertionOrder
/* = -1 */)
3204 _List
= new CGroupList(CViewBase::TCtorParam());
3205 _List
->setId (_Id
+":list");
3206 _List
->setParent (this);
3209 // Remove from the list if already inserted
3210 _List
->delChild (pIC
, true);
3211 if (insertionOrder
== -1)
3213 _List
->addChild (pIC
, false); // Do not delete it on remove !
3218 for(k
= 0; k
< (uint
) _List
->getNbElement(); ++k
)
3220 if (_List
->getOrder(k
) > (uint
) insertionOrder
) break;
3222 _List
->addChildAtIndex(pIC
, k
, false);
3223 _List
->setOrder(k
, insertionOrder
);
3226 // Create MaxH Resizer if not already created
3227 createResizerMaxH();
3231 // ***************************************************************************
3232 bool CGroupContainer::attachContainerAtIndex(CGroupContainer
*pIC
, uint index
)
3236 _List
= new CGroupList(CViewBase::TCtorParam());
3237 _List
->setId (_Id
+":list");
3238 _List
->setParent (this);
3240 if (index
> (uint
) _List
->getNbElement())
3242 nlwarning("Bad index");
3246 if (index
== (uint
) _List
->getNbElement())
3248 if (_List
->getNbElement() == 0)
3254 eltOrder
= _List
->getOrder(index
- 1);
3259 eltOrder
= _List
->getOrder(index
);
3262 for(k
= index
; k
< (uint
) _List
->getNbElement(); ++k
)
3264 _List
->setOrder(k
, _List
->getOrder(k
) + 1);
3266 // change insertion order of poped containers
3267 for(k
= 0; k
< _PopedCont
.size(); ++k
)
3269 if (_PopedCont
[k
]->_InsertionOrder
>= eltOrder
)
3271 ++ _PopedCont
[k
]->_InsertionOrder
;
3274 attachContainer(pIC
, eltOrder
);
3279 // ***************************************************************************
3280 void CGroupContainer::detachContainer (CGroupContainer
*pIC
)
3283 nlassert(_List
!= NULL
);
3284 nlassert(pIC
->getProprietaryContainer() == this); // should be a son of that container
3285 nlassert(!pIC
->isPopuped()); // if the container is poped, should pop it in before detaching it!
3286 _List
->delChild (pIC
);
3287 _List
->invalidateCoords(2);
3289 // Remove MaxH Resizer if exist
3290 if (_List
->getNumChildren() == 0)
3292 removeResizerMaxH();
3297 // ***************************************************************************
3298 void CGroupContainer::removeAllContainers()
3301 _List
->deleteAllChildren();
3304 // ***************************************************************************
3305 void CGroupContainer::setMovable(bool b
)
3310 if (_LayerSetup
!= -1)
3318 // ***************************************************************************
3319 void CGroupContainer::setup()
3321 sint32 nNewLayer
= getLayer();
3322 if (_LayerSetup
== nNewLayer
)
3325 _LayerSetup
= nNewLayer
;
3327 if ((_LayerSetup
== 0) && _Popable
)
3337 COptionsLayer
*pLayer
= getContainerOptions(_LayerSetup
);
3339 if (_LayerSetup
== 0)
3341 setParentPosRef(Hotspot_BL
);
3342 setPosRef(Hotspot_TL
);
3346 setParentPosRef(Hotspot_TL
);
3347 setPosRef(Hotspot_TL
);
3350 // At start, consider all closed.
3352 // Title when the container is opened
3355 // Opened state view (tells the user if the container is openable (if the view appears) and if its opened/closed
3356 updateViewOpenState();
3358 // Multi usage button
3359 updateRightButton();
3364 // if the window is popable,
3367 _List
= new CGroupList(CViewBase::TCtorParam());
3368 _List
->setId(_Id
+":list");
3369 _List
->setParent (this);
3370 _List
->setParentPos (this);
3371 _List
->setParentPosRef (Hotspot_TL
);
3372 _List
->setPosRef (Hotspot_TL
);
3373 _List
->setActive (_Opened
);
3375 if (_LayerSetup
== 0)
3377 _ScrollBar
= new CCtrlScroll(CViewBase::TCtorParam());
3378 _ScrollBar
->setId (_Id
+":sb");
3379 _ScrollBar
->setParent (this);
3380 _ScrollBar
->setParentPos (this);
3381 _ScrollBar
->setParentPosRef (Hotspot_TL
);
3382 _ScrollBar
->setPosRef (Hotspot_TL
);
3383 _ScrollBar
->setTarget(_List
);
3384 _ScrollBar
->setW (pLayer
->Scrollbar_W
); // TODO read this from somewhere
3385 _ScrollBar
->setAlign (3); // Top
3386 _ScrollBar
->setTextureBottomOrLeft (pLayer
->TxId_B_Scrollbar
);
3387 _ScrollBar
->setTextureMiddle (pLayer
->TxId_M_Scrollbar
);
3388 _ScrollBar
->setTextureTopOrRight (pLayer
->TxId_T_Scrollbar
);
3389 _ScrollBar
->setTextureMiddleTile ((uint8
)pLayer
->Tile_M_Scrollbar
);
3390 _ScrollBar
->setActive (false);
3398 // del all previous resizers
3400 for(k
= 0; k
< NumResizers
; ++k
)
3404 delCtrl (toString("rz%d", (int) k
));
3412 // Remove previous controls / views
3414 delGroup ("list", true);
3417 COptionsContainerMove
*options
= getMoveOptions();
3420 if ((_LayerSetup
== 0) && (_EnabledResizer
))
3425 // if no specific top Size specified
3426 if(_ResizerTopSize
<0)
3427 yOffset
= -options
->ResizerSize
;
3429 yOffset
= -_ResizerTopSize
;
3430 // create the resizers
3431 createResizer(0, Hotspot_TL
, Hotspot_TM
, options
->ResizerSize
, 0, false);
3432 createResizer(1, Hotspot_TR
, Hotspot_TR
, 0, 0, false);
3433 createResizer(2, Hotspot_TR
, Hotspot_MR
, 0, yOffset
, false);
3434 createResizer(3, Hotspot_BR
, Hotspot_BR
, 0, 0, false);
3435 createResizer(4, Hotspot_BR
, Hotspot_BM
, -options
->ResizerSize
, 0, false);
3436 createResizer(5, Hotspot_BL
, Hotspot_BL
, 0, 0, false);
3437 createResizer(6, Hotspot_TL
, Hotspot_ML
, 0, yOffset
, false);
3438 createResizer(7, Hotspot_TL
, Hotspot_TL
, 0, 0, false);
3442 if ((_LayerSetup
== 0) && (options
))
3444 createResizerMaxH();
3448 if (_ScrollBar
!= NULL
) addCtrl (_ScrollBar
);
3452 _Content
= getGroup ("content");
3453 if (_Content
!= NULL
)
3455 // Content must be (TL TL), (TR TR) or (TM TM)
3456 _Content
->setPosRef( (THotSpot
)((_Content
->getPosRef() & (Hotspot_xL
|Hotspot_xM
|Hotspot_xR
)) | Hotspot_Tx
) );
3457 _Content
->setParentPosRef(_Content
->getPosRef());
3458 _Content
->setActive (false);
3461 _HeaderOpened
= getGroup ("header_opened");
3462 if (_HeaderOpened
!= NULL
)
3464 // Header opened must be (TL TL), (TR TR) or (TM TM)
3465 _HeaderOpened
->setPosRef( (THotSpot
)((_HeaderOpened
->getPosRef() & (Hotspot_xL
|Hotspot_xM
|Hotspot_xR
)) | Hotspot_Tx
) );
3466 _HeaderOpened
->setParentPosRef(_HeaderOpened
->getPosRef());
3467 _HeaderOpened
->setActive (_Opened
);
3470 _HeaderClosed
= getGroup ("header_closed");
3471 if (_HeaderClosed
!= NULL
)
3473 // Header closed must be (TL TL), (TR TR) or (TM TM)
3474 _HeaderClosed
->setPosRef( (THotSpot
)((_HeaderClosed
->getPosRef() & (Hotspot_xL
|Hotspot_xM
|Hotspot_xR
)) | Hotspot_Tx
) );
3475 _HeaderClosed
->setParentPosRef(_HeaderClosed
->getPosRef());
3476 _HeaderClosed
->setActive (!_Opened
);
3479 _List
->setActive(_Opened
);
3480 if (_ScrollBar
!= NULL
) _ScrollBar
->setActive(_Opened
);
3481 if (_Content
!= NULL
) _Content
->setActive(_Opened
);
3483 if (!_ModalParentNames
.empty())
3485 // reassign the first setup time
3486 setModalParentList(_ModalParentNames
);
3489 invalidateCoords ();
3493 // ***************************************************************************
3494 // Update right button depending on pop, popable, layer and locked
3495 void CGroupContainer::updateRightButton()
3497 if ((_EnabledRightButton
) && (!((_LayerSetup
>0)&&(!_Popable
))))
3499 COptionsLayer
*pLayer
= getContainerOptions();
3501 // Create right button
3502 if (_RightButton
== NULL
)
3504 _RightButton
= new CCtrlButton(CViewBase::TCtorParam());
3505 _RightButton
->setId(_Id
+":rightbut");
3506 _RightButton
->setType(CCtrlBaseButton::PushButton
);
3507 _RightButton
->setParent (this);
3508 _RightButton
->setParentPos (this);
3509 _RightButton
->setParentPosRef (Hotspot_TR
);
3510 _RightButton
->setPosRef (Hotspot_TR
);
3511 _RightButton
->setModulateGlobalColorAll (getModulateGlobalColor());
3512 _RightButton
->setModulateGlobalColorOver (true);
3513 addCtrl (_RightButton
);
3515 _RightButton
->setX(pLayer
->getValSInt32 ("right_button_offset_x"));
3516 _RightButton
->setY(pLayer
->getValSInt32 ("right_button_offset_y"));
3518 if (_LayerSetup
== 0)
3522 _RightButton
->setTexture (pLayer
->getValStr ("right_button_tx_locked"));
3523 _RightButton
->setTexturePushed (pLayer
->getValStr ("right_button_tx_locked"));
3524 _RightButton
->setTextureOver ("");
3525 _RightButton
->setActionOnLeftClick ("");
3526 _RightButton
->setDefaultContextHelp(string(""));
3530 // If the container is normally a layer>0 and is poped ? popin button
3531 if (_OldFatherContainer
!= NULL
)
3533 _RightButton
->setTexture (pLayer
->getValStr ("right_button_tx_popin"));
3534 _RightButton
->setTexturePushed (pLayer
->getValStr ("right_button_tx_popin"));
3535 _RightButton
->setTextureOver (pLayer
->getValStr ("right_button_tx_over"));
3536 _RightButton
->setActionOnLeftClick ("ic_popin");
3537 _RightButton
->setDefaultContextHelp(CI18N::get("uiPopinWindow"));
3539 else // else the container can be deactivated ? deactivate button
3541 _RightButton
->setTexture (pLayer
->getValStr ("right_button_tx_deactive"));
3542 _RightButton
->setTexturePushed (pLayer
->getValStr ("right_button_tx_deactive"));
3543 _RightButton
->setTextureOver (pLayer
->getValStr ("right_button_tx_over"));
3544 _RightButton
->setActionOnLeftClick ("ic_deactive");
3545 _RightButton
->setDefaultContextHelp(CI18N::get("uiClose"));
3551 // If the container can be a popup ? popup button
3554 _RightButton
->setTexture (pLayer
->getValStr ("right_button_tx_popup"));
3555 _RightButton
->setTexturePushed (pLayer
->getValStr ("right_button_tx_popup"));
3556 _RightButton
->setTextureOver (pLayer
->getValStr ("right_button_tx_over"));
3557 _RightButton
->setActionOnLeftClick ("ic_popup");
3558 _RightButton
->setDefaultContextHelp(CI18N::get("uiPopupWindow"));
3560 _RightButton
->setActive(!_Locked
);
3565 // Delete right button
3566 delCtrl ("rightbut");
3567 _RightButton
= NULL
;
3572 // ***************************************************************************
3573 void CGroupContainer::updateHelpButton()
3575 // enable the help button only if has some help page
3576 if ( _EnabledHelpButton
&& !_HelpPage
.empty() )
3578 COptionsLayer
*pLayer
= getContainerOptions();
3580 // Create Help button
3581 if (_HelpButton
== NULL
)
3583 _HelpButton
= new CCtrlButton(CViewBase::TCtorParam());
3584 _HelpButton
->setId(_Id
+":helpbut");
3585 _HelpButton
->setType(CCtrlBaseButton::PushButton
);
3586 _HelpButton
->setParent (this);
3587 _HelpButton
->setParentPos (this);
3588 _HelpButton
->setParentPosRef (Hotspot_TR
);
3589 _HelpButton
->setPosRef (Hotspot_TR
);
3590 _HelpButton
->setModulateGlobalColorAll (getModulateGlobalColor());
3591 _HelpButton
->setModulateGlobalColorOver (true);
3592 addCtrl (_HelpButton
);
3594 _HelpButton
->setX(pLayer
->getValSInt32 ("help_button_offset_x"));
3595 _HelpButton
->setY(pLayer
->getValSInt32 ("help_button_offset_y"));
3597 _HelpButton
->setTexture (pLayer
->getValStr ("help_button_tx"));
3598 _HelpButton
->setTexturePushed (pLayer
->getValStr ("help_button_tx"));
3599 _HelpButton
->setTextureOver (pLayer
->getValStr ("help_button_tx_over"));
3600 _HelpButton
->setActionOnLeftClick ("ic_help");
3601 _HelpButton
->setDefaultContextHelp(CI18N::get("uiHelp"));
3605 if (_LayerSetup
> 0)
3607 // if locked, the right button is not displayed => take its pos instead
3610 _HelpButton
->setX(pLayer
->getValSInt32 ("help_button_offset_x"));
3611 _HelpButton
->setY(pLayer
->getValSInt32 ("help_button_offset_y"));
3615 _HelpButton
->setX(pLayer
->getValSInt32 ("right_button_offset_x"));
3616 _HelpButton
->setY(pLayer
->getValSInt32 ("right_button_offset_y"));
3622 // Delete help button
3623 delCtrl ("helpbut");
3629 // ***************************************************************************
3630 void CGroupContainer::updateMover()
3632 if (_Movable
|| _Popable
|| _Openable
)
3634 COptionsContainerMove
*options
= getMoveOptions();
3635 _Mover
= new CCtrlMover(CViewText::TCtorParam(), _Movable
|| _Popable
|| _MovableInParentList
, _Openable
);
3636 _Mover
->setId (_Id
+":mover");
3637 _Mover
->setParent (this);
3638 _Mover
->setParentPos (this);
3639 _Mover
->setParentPosRef (Hotspot_TM
);
3640 _Mover
->setPosRef (Hotspot_TM
);
3641 if (_Poped
&& _EnabledResizer
)
3642 _Mover
->setY (options
->TrackYWithTopResizer
);
3644 _Mover
->setY (options
->TrackY
);
3645 _Mover
->setH (options
->TrackH
);
3646 _MoverDeltaW
= options
->TrackW
;
3654 addCtrl (_Mover
, 0);
3658 // ***************************************************************************
3659 void CGroupContainer::updateViewOpenState()
3663 COptionsLayer
*pLayer
= getContainerOptions();
3664 if (_ViewOpenState
== NULL
)
3666 _ViewOpenState
= new CViewBitmap(CViewBase::TCtorParam());
3667 _ViewOpenState
->setId(_Id
+":open_state");
3668 _ViewOpenState
->setParent (this);
3669 _ViewOpenState
->setParentPos (this);
3670 _ViewOpenState
->setParentPosRef (Hotspot_TL
);
3671 _ViewOpenState
->setPosRef (Hotspot_TL
);
3672 _ViewOpenState
->setModulateGlobalColor (getModulateGlobalColor());
3673 addView (_ViewOpenState
);
3675 _ViewOpenState
->setX(pLayer
->getValSInt32 ("open_state_offset_x"));
3676 _ViewOpenState
->setY(pLayer
->getValSInt32 ("open_state_offset_y"));
3679 _ViewOpenState
->setTexture (pLayer
->getValStr ("open_state_tx_opened"));
3681 _ViewOpenState
->setTexture (pLayer
->getValStr ("open_state_tx_closed"));
3682 _ViewOpenState
->setActive(!_Locked
);
3686 _ViewOpenState
= NULL
;
3687 delView ("open_state");
3691 // ***************************************************************************
3692 void CGroupContainer::updateTitle()
3694 COptionsLayer
*pLayer
= getContainerOptions();
3695 if (_TitleOpened
== NULL
)
3699 case TitleTextFormated
:
3701 CViewTextFormated
*vtf
= new CViewTextFormated(CViewBase::TCtorParam());
3702 vtf
->setFormatString(_TitleTextOpened
);
3707 case TitleTextDynString
:
3709 CViewTextID
*vti
= new CViewTextID(CViewBase::TCtorParam());
3710 // the title here is actually the DB path
3711 vti
->setDBTextID(_TitleTextOpened
);
3712 vti
->setDynamicString(_TitleClass
==TitleTextDynString
);
3717 _TitleOpened
= new CViewText(CViewBase::TCtorParam());
3719 _TitleOpened
->setId(_Id
+":titopen");
3720 _TitleOpened
->setParent (this);
3721 _TitleOpened
->setParentPos (this);
3722 _TitleOpened
->setParentPosRef (Hotspot_TL
);
3723 _TitleOpened
->setPosRef (Hotspot_TL
);
3724 _TitleOpened
->setShadow (true);
3725 _TitleOpened
->setShadowOutline (false);
3726 _TitleOpened
->setColor (CRGBA(255,255,255,255));
3727 _TitleOpened
->setModulateGlobalColor(getModulateGlobalColor());
3728 _TitleOpened
->setOverExtendViewText(_TitleOverExtendViewText
);
3729 addView (_TitleOpened
);
3734 _TitleOpened
->setX (pLayer
->getValSInt32 ("title_offset_openable_x"));
3735 _TitleOpened
->setY (pLayer
->getValSInt32 ("title_offset_openable_y"));
3739 _TitleOpened
->setX (pLayer
->getValSInt32 ("title_offset_x"));
3740 _TitleOpened
->setY (pLayer
->getValSInt32 ("title_offset_y"));
3742 _TitleOpened
->setFontSize (pLayer
->getValSInt32 ("title_font_size"));
3743 if (_TitleClass
== TitleText
) setTitledOpenedViewText();
3744 _TitleOpened
->setActive (_Opened
);
3746 // Title when the container is closed
3747 if (_TitleClosed
== NULL
)
3751 case TitleTextFormated
:
3753 CViewTextFormated
*vtf
= new CViewTextFormated(CViewBase::TCtorParam());
3754 vtf
->setFormatString(_TitleTextClosed
);
3759 case TitleTextDynString
:
3761 CViewTextID
*vti
= new CViewTextID(CViewBase::TCtorParam());
3762 // the title here is actually the DB path
3763 vti
->setDBTextID(_TitleTextClosed
);
3764 vti
->setDynamicString(_TitleClass
==TitleTextDynString
);
3769 _TitleClosed
= new CViewText(CViewBase::TCtorParam());
3771 _TitleClosed
->setId(_Id
+":titclose");
3772 _TitleClosed
->setParent (this);
3773 _TitleClosed
->setParentPos (this);
3774 _TitleClosed
->setParentPosRef (Hotspot_TL
);
3775 _TitleClosed
->setPosRef (Hotspot_TL
);
3776 _TitleClosed
->setShadow (true);
3777 _TitleClosed
->setShadowOutline (false);
3778 _TitleClosed
->setColor (CRGBA(255,255,255,255));
3779 _TitleClosed
->setModulateGlobalColor(getModulateGlobalColor());
3780 _TitleClosed
->setOverExtendViewText(_TitleOverExtendViewText
);
3781 addView (_TitleClosed
);
3786 _TitleClosed
->setX (pLayer
->getValSInt32 ("title_offset_openable_x"));
3787 _TitleClosed
->setY (pLayer
->getValSInt32 ("title_offset_openable_y"));
3791 _TitleClosed
->setX (pLayer
->getValSInt32 ("title_offset_x"));
3792 _TitleClosed
->setY (pLayer
->getValSInt32 ("title_offset_y"));
3794 _TitleClosed
->setFontSize (pLayer
->getValSInt32 ("title_font_size"));
3795 if (_TitleClass
== TitleText
) setTitledClosedViewText();
3796 _TitleClosed
->setActive(!_Opened
);
3801 // ***************************************************************************
3802 // bMaxH is a boolean to know if the resizer act on the content or on the child list
3803 void CGroupContainer::createResizer(uint index
, THotSpot posRef
, THotSpot type
, sint32 offsetX
, sint32 offsetY
, bool bMaxH
)
3805 CCtrlResizer
*cr
= new CCtrlResizer(CViewText::TCtorParam());
3806 cr
->setId (_Id
+toString(":rz%d", (int) index
));
3807 cr
->setParent (this);
3808 cr
->setParentPos (this);
3809 cr
->setResizerPos(type
);
3811 if (_LayerSetup
!= 0)
3818 cr
->WMin
= _PopupMinW
;
3819 cr
->WMax
= _PopupMaxW
;
3820 cr
->HMin
= _PopupMinH
;
3821 cr
->HMax
= _PopupMaxH
;
3824 cr
->setParentPosRef (posRef
);
3825 cr
->setPosRef (posRef
);
3832 updateResizerSize(cr
);
3833 _Resizer
[index
] = cr
;
3834 addCtrl (_Resizer
[index
], 0);
3837 // ***************************************************************************
3838 void CGroupContainer::createResizerMaxH()
3840 if (_LayerSetup
!= 0) return;
3841 if (_List
== NULL
) return;
3842 if (_List
->getNumChildren() == 0) return;
3844 COptionsContainerMove
*options
= getMoveOptions();
3846 // Create corner resizer if we asked for all resizer
3847 if (_EnabledResizer
)
3849 if (_Resizer
[1] == NULL
) createResizer(1, Hotspot_TR
, Hotspot_TR
, 0, 0, true);
3850 if (_Resizer
[3] == NULL
) createResizer(3, Hotspot_BR
, Hotspot_BR
, 0, 0, true);
3851 if (_Resizer
[5] == NULL
) createResizer(5, Hotspot_BL
, Hotspot_BL
, 0, 0, true);
3852 if (_Resizer
[7] == NULL
) createResizer(7, Hotspot_TL
, Hotspot_TL
, 0, 0, true);
3853 _Resizer
[1]->IsMaxH
= true;
3854 _Resizer
[3]->IsMaxH
= true;
3855 _Resizer
[5]->IsMaxH
= true;
3856 _Resizer
[7]->IsMaxH
= true;
3859 if (_Resizer
[0] == NULL
) createResizer(0, Hotspot_TL
, Hotspot_TM
, options
->ResizerSize
, 0, true);
3860 if (_Resizer
[4] == NULL
) createResizer(4, Hotspot_BR
, Hotspot_BM
, -options
->ResizerSize
, 0, true);
3861 _Resizer
[0]->IsMaxH
= true;
3862 _Resizer
[4]->IsMaxH
= true;
3865 // ***************************************************************************
3866 void CGroupContainer::removeResizerMaxH()
3868 if (_LayerSetup
!= 0) return;
3869 if (_List
== NULL
) return;
3870 if (_List
->getNumChildren() != 0) return;
3872 for (uint i
= 0; i
< NumResizers
; ++i
)
3873 if ((i
!= 6) && (i
!= 2)) // 6 == right and 2 == left
3874 if (_Resizer
[i
] != NULL
)
3876 delCtrl ( toString(":rz%d", (int) i
) );
3881 // ***************************************************************************
3882 sint32
CGroupContainer::getLayer()
3884 if (_MovingInParentList
)
3886 // keep the previous layer
3891 // Count Nb of Parent
3892 CInterfaceGroup
*pIG
= this;
3893 sint32 nNbParent
= 0;
3896 pIG
= pIG
->getParent();
3900 return (nNbParent
-1)/2;
3904 // ***************************************************************************
3905 COptionsLayer
*CGroupContainer::getContainerOptions(sint32 ls
)
3911 const string
*sLayerName
;
3912 if (_OptionsName
.empty())
3914 nlassert((uint32
)ls
<NumLayerName
);
3915 sLayerName
= &_OptionLayerName
[ls
];
3919 sTmp
= _OptionsName
;
3923 COptionsLayer
*pLayer
= (COptionsLayer
*)CWidgetManager::getInstance()->getOptions(*sLayerName
);
3924 nlassert(pLayer
!= NULL
);
3928 // ***************************************************************************
3929 void CGroupContainer::setContent (CInterfaceGroup
*pC
)
3931 if (_Content
!= NULL
)
3932 delGroup (_Content
);
3936 _Content
->setId (_Id
+":content");
3937 _Content
->setActive (false);
3938 _Content
->setParentPosRef (Hotspot_TL
);
3939 _Content
->setPosRef (Hotspot_TL
);
3940 _Content
->setParent (this);
3941 addGroup (_Content
);
3945 // ***************************************************************************
3946 void CGroupContainer::setLocalize(bool localize
)
3948 _Localize
= localize
;
3951 _TitleOpened
->setLocalized(localize
);
3955 _TitleClosed
->setLocalized(localize
);
3960 // ***************************************************************************
3961 std::string
CGroupContainer::getTitle () const
3963 return _TitleTextOpened
;
3966 // ***************************************************************************
3967 void CGroupContainer::setTitle (const std::string
&title
)
3969 setTitleOpened(title
);
3970 setTitleClosed(title
);
3973 // ***************************************************************************
3974 std::string
CGroupContainer::getTitleOpened () const
3976 return _TitleTextOpened
;
3979 // ***************************************************************************
3980 void CGroupContainer::setTitleOpened (const std::string
&title
)
3982 _TitleTextOpened
= title
;
3983 setTitledOpenedViewText();
3987 // ***************************************************************************
3988 std::string
CGroupContainer::getTitleClosed () const
3990 return _TitleTextClosed
;
3993 // ***************************************************************************
3994 void CGroupContainer::setTitleClosed (const std::string
&title
)
3996 _TitleTextClosed
= title
;
3997 setTitledClosedViewText();
4001 // ***************************************************************************
4002 void CGroupContainer::setTitledOpenedViewText()
4004 if (_TitleOpened
!= NULL
)
4006 _TitleOpened
->setTextLocalized(_TitleTextOpened
, _Localize
);
4010 // ***************************************************************************
4011 void CGroupContainer::setTitledClosedViewText()
4013 if (_TitleClosed
!= NULL
)
4015 _TitleClosed
->setTextLocalized(_TitleTextClosed
, _Localize
);
4019 #ifdef RYZOM_LUA_UCSTRING
4020 // ***************************************************************************
4021 void CGroupContainer::setUCTitleOpened(const ucstring
&title
)
4023 setTitleOpened(title
.toUtf8());
4026 // ***************************************************************************
4027 void CGroupContainer::setUCTitleClosed(const ucstring
&title
)
4029 setTitleClosed(title
.toUtf8());
4032 // ***************************************************************************
4033 void CGroupContainer::setUCTitle(const ucstring
&title
)
4035 setTitle(title
.toUtf8());
4038 // ***************************************************************************
4039 ucstring
CGroupContainer::getUCTitle () const
4041 return ucstring::makeFromUtf8(getTitle());
4044 // ***************************************************************************
4045 ucstring
CGroupContainer::getUCTitleOpened () const
4047 return ucstring::makeFromUtf8(getTitleOpened());
4050 // ***************************************************************************
4051 ucstring
CGroupContainer::getUCTitleClosed () const
4053 return ucstring::makeFromUtf8(getTitleClosed());
4057 // ***************************************************************************
4058 void CGroupContainer::launch ()
4063 CInterfaceGroup::launch();
4066 // ***************************************************************************
4067 void CGroupContainer::setActive (bool state
)
4069 if(state
!= getActive() && getLayer()==0)
4072 CWidgetManager::getInstance()->setTopWindow(this);
4074 CWidgetManager::getInstance()->setBackWindow(this);
4076 CAHManager::getInstance()->submitEvent((state
?"show:":"hide:")+getId());
4078 CInterfaceGroup::setActive(state
);
4081 // ***************************************************************************
4082 /*bool CGroupContainer::isWindowUnder (sint32 x, sint32 y)
4084 bool bGrayed = false;
4085 CGroupContainer *pSon = _ModalSon;
4086 if ((pSon != NULL) && pSon->getActive())
4089 if (bGrayed) return NULL;
4090 return CInterfaceGroup::isWindowUnder(x,y);
4093 // ***************************************************************************
4094 bool CGroupContainer::getViewsUnder (sint32 x
, sint32 y
, sint32 clipX
, sint32 clipY
, sint32 clipW
, sint32 clipH
, std::vector
<CViewBase
*> &vVB
)
4096 bool bGrayed
= isGrayed();
4097 if (bGrayed
) return false;
4098 return CInterfaceGroup::getViewsUnder(x
, y
, clipX
, clipY
, clipW
, clipH
, vVB
);
4101 // ***************************************************************************
4102 bool CGroupContainer::getCtrlsUnder (sint32 x
, sint32 y
, sint32 clipX
, sint32 clipY
, sint32 clipW
, sint32 clipH
, std::vector
<CCtrlBase
*> &vICL
)
4104 bool bGrayed
= isGrayed();
4105 if (bGrayed
) return false;
4106 return CInterfaceGroup::getCtrlsUnder(x
,y
,clipX
,clipY
,clipW
,clipH
,vICL
);
4109 // ***************************************************************************
4110 void CGroupContainer::popupCurrentPos()
4112 if (!_Popable
&& !_MovableInParentList
)
4114 nlwarning("<CGroupContainer::popup> The window is not popable or cannot move in parent list.");
4117 if (_LayerSetup
== 0)
4119 nlwarning("<CGroupContainer::popup> The window is already poped.");
4122 if (!_Parent
|| !_Parent
->getParent())
4124 nlwarning("<CGroupContainer::popup> Window has not parent.");
4127 // remove the group from its father
4128 CGroupContainer
*parentContainer
= dynamic_cast<CGroupContainer
*>(_Parent
->getParent());
4129 if (!parentContainer
)
4131 nlwarning("<CGroupContainer::popup> Container is not son of another container");
4134 _OldFatherContainer
= parentContainer
;
4135 sint32 eltIndex
= parentContainer
->_List
->getElementIndex(this);
4138 nlwarning("<CGroupContainer::popup> Can't get index in owner group");
4141 _InsertionOrder
= parentContainer
->_List
->getOrder(eltIndex
);
4142 parentContainer
->detachContainer(this);
4144 parentContainer
->_PopedCont
.push_back(this);
4146 // put at the base of hierarchy
4147 CInterfaceGroup
*parent
= _Parent
;
4148 if (!parent
) return;
4149 while (parent
->getParent())
4151 parent
= parent
->getParent();
4154 _ParentPos
= parent
;
4156 CWidgetManager::getInstance()->makeWindow(this);
4157 CWidgetManager::getInstance()->setTopWindow(this);
4158 CWidgetManager::getInstance()->clearViewUnders();
4159 CWidgetManager::getInstance()->clearCtrlsUnders();
4161 // update coords (put coords in world)
4163 setY(getYReal() + getHReal());
4164 setParentPosRef(Hotspot_BL
);
4165 setPosRef(Hotspot_TL
);
4170 clamp(w
, _PopupMinW
, _PopupMaxW
);
4175 // setup the new controls
4177 _OpenedBeforePopup
= _Opened
;
4183 // ***************************************************************************
4184 void CGroupContainer::popin(sint32 insertPos
/* = -1 */, bool putBackInFatherContainer
/*= true*/)
4186 if (!_OldFatherContainer
)
4188 nlwarning("<popin> The window wasn't previously attached.(%s)",this->_Id
.c_str());
4192 if (!_Popable
&& !_MovableInParentList
)
4194 nlwarning("<popin> The window is not popable or cannot move in parent list.(%s)",this->_Id
.c_str());
4197 if (!_MovingInParentList
&& _LayerSetup
!= 0)
4199 nlwarning("<popin> The window should be in layer 0.(%s)",this->_Id
.c_str());
4204 nlwarning("<popin> The window has no parent.(%s)",this->_Id
.c_str());
4211 _MovingInParentList
= false;
4212 CWidgetManager::getInstance()->unMakeWindow(this);
4213 CWidgetManager::getInstance()->clearViewUnders();
4214 CWidgetManager::getInstance()->clearCtrlsUnders();
4217 std::vector
<CGroupContainer
*>::iterator it
= std::find(_PopedCont
.begin(), _PopedCont
.end(), this);
4218 if (it
!= _PopedCont
.end())
4220 // replace by last element
4221 *it
= _PopedCont
.back();
4222 _PopedCont
.pop_back();
4224 if (putBackInFatherContainer
)
4226 bool active
= getActive();
4228 if (insertPos
== -1)
4230 _OldFatherContainer
->attachContainer(this, _InsertionOrder
);
4234 if (!_OldFatherContainer
->attachContainerAtIndex(this, insertPos
))
4236 nlwarning("Couldn't attach to previous container");
4241 _OldFatherContainer
= NULL
;
4248 setOpen(_OpenedBeforePopup
);
4254 _OldFatherContainer
= NULL
;
4258 // ***************************************************************************
4259 void CGroupContainer::enableBlink(uint numBlinks
/*=0*/)
4262 _NumBlinks
= numBlinks
;
4267 // ***************************************************************************
4268 void CGroupContainer::disableBlink()
4273 _BlinkState
= false;
4277 // ***************************************************************************
4278 void CGroupContainer::setMovingInParentList(bool enable
)
4280 _MovingInParentList
= enable
;
4283 // ***************************************************************************
4284 void CGroupContainer::popup()
4288 setHighLighted(false);
4291 if (getPopupW() != -1)
4300 setW(getRefW()); // Do not know what we need to do that ...
4302 invalidateCoords(2);
4305 // ***************************************************************************
4306 COptionsContainerMove
*CGroupContainer::getMoveOptions()
4308 static NLMISC::CRefPtr
<COptionsContainerMove
> moveOptions
;
4309 if (moveOptions
) return moveOptions
;
4310 moveOptions
= (COptionsContainerMove
*) CWidgetManager::getInstance()->getOptions("container_move_opt");
4315 // ***************************************************************************
4317 // ***************************************************************************
4319 // ***************************************************************************
4320 class CICOpen
: public IActionHandler
4323 virtual void execute (CCtrlBase
*pCaller
, const std::string
&/* Params */)
4325 CInterfaceGroup
*pIG
= pCaller
->getParent();
4326 if (pIG
== NULL
) return;
4327 CGroupContainer
*pIC
= dynamic_cast<CGroupContainer
*>(pIG
);
4328 if (pIC
== NULL
) return;
4332 REGISTER_ACTION_HANDLER (CICOpen
, "ic_open");
4334 // ***************************************************************************
4335 class CICClose
: public IActionHandler
4338 virtual void execute (CCtrlBase
*pCaller
, const std::string
&/* Params */)
4340 CInterfaceGroup
*pIG
= pCaller
->getParent();
4341 if (pIG
== NULL
) return;
4342 CGroupContainer
*pIC
= dynamic_cast<CGroupContainer
*>(pIG
);
4343 if (pIC
== NULL
) return;
4347 REGISTER_ACTION_HANDLER (CICClose
, "ic_close");
4349 // ***************************************************************************
4350 class CICDeactive
: public IActionHandler
4353 virtual void execute (CCtrlBase
*pCaller
, const std::string
&/* Params */)
4355 CInterfaceGroup
*pIG
= pCaller
->getParent();
4356 if (pIG
== NULL
) return;
4357 CGroupContainer
*pIC
= dynamic_cast<CGroupContainer
*>(pIG
);
4358 if (pIC
== NULL
) return;
4359 if (pIC
->isLocked()) return;
4361 // check if the window can be really closed
4362 CGroupContainer::_ValidateCanDeactivate
= true;
4363 if (!pIC
->getAHOnDeactiveCheck().empty())
4365 CAHManager::getInstance()->runActionHandler(pIC
->getAHOnDeactiveCheck(), pCaller
, pIC
->getAHOnDeactiveCheckParams());
4368 if (CGroupContainer::_ValidateCanDeactivate
)
4370 // send close button msg
4371 if (!pIC
->getAHOnCloseButton().empty())
4373 CAHManager::getInstance()->runActionHandler(pIC
->getAHOnCloseButton(), pCaller
, pIC
->getAHOnCloseButtonParams());
4375 CWidgetManager::getInstance()->setBackWindow(pIC
);
4376 pIC
->setActive(false);
4380 REGISTER_ACTION_HANDLER (CICDeactive
, "ic_deactive");
4382 // ***************************************************************************
4383 class CICPopup
: public IActionHandler
4386 virtual void execute (CCtrlBase
*pCaller
, const std::string
&/* Params */)
4388 CInterfaceGroup
*pIG
= pCaller
->getParent();
4389 if (pIG
== NULL
) return;
4390 CGroupContainer
*pIC
= dynamic_cast<CGroupContainer
*>(pIG
);
4391 if (pIC
== NULL
) return;
4392 if (pIC
->isLocked()) return;
4397 CWidgetManager::getInstance()->setCapturePointerLeft(NULL
);
4398 CWidgetManager::getInstance()->setCapturePointerRight(NULL
);
4401 REGISTER_ACTION_HANDLER (CICPopup
, "ic_popup");
4403 // ***************************************************************************
4404 class CICPopin
: public IActionHandler
4407 virtual void execute (CCtrlBase
*pCaller
, const std::string
&/* Params */)
4409 CInterfaceGroup
*pIG
= pCaller
->getParent();
4410 if (pIG
== NULL
) return;
4411 CGroupContainer
*pIC
= dynamic_cast<CGroupContainer
*>(pIG
);
4412 if (pIC
== NULL
) return;
4413 if (pIC
->isLocked()) return;
4414 // memorize popup position
4415 pIC
->setPopupX(pIC
->getX());
4416 pIC
->setPopupY(pIC
->getY());
4417 pIC
->setPopupW(pIC
->getW());
4418 pIC
->setPopupH(pIC
->getH());
4422 CWidgetManager::getInstance()->setCapturePointerLeft(NULL
);
4423 CWidgetManager::getInstance()->setCapturePointerRight(NULL
);
4426 REGISTER_ACTION_HANDLER (CICPopin
, "ic_popin");
4428 // ***************************************************************************
4429 class CICLock
: public IActionHandler
4431 virtual void execute (CCtrlBase
*pCaller
, const std::string
&/* Params */)
4433 CInterfaceGroup
*pIG
= pCaller
->getParent();
4434 if (pIG
== NULL
) return;
4435 CGroupContainer
*pIC
= dynamic_cast<CGroupContainer
*>(pIG
);
4436 if (pIC
== NULL
) return;
4437 pIC
->setLocked(!pIC
->isLocked());
4440 REGISTER_ACTION_HANDLER(CICLock
, "ic_lock");
4442 // ***************************************************************************
4443 class CICHelp
: public IActionHandler
4445 virtual void execute (CCtrlBase
*pCaller
, const std::string
&/* Params */)
4447 // get the container to get help
4450 CGroupContainer
*pIC
= dynamic_cast<CGroupContainer
*>(pCaller
->getRootWindow());
4451 if (pIC
== NULL
) return;
4453 // if found the help page
4454 const std::string
&helpPage
= pIC
->getHelpPage();
4455 if(!helpPage
.empty())
4458 // open the web browser, and point to the page
4459 CAHManager::getInstance()->runActionHandler("launch_help", NULL
, "url=" + helpPage
);
4463 REGISTER_ACTION_HANDLER(CICHelp
, "ic_help");
4465 // ***************************************************************************
4466 CGroupContainer
*CGroupContainer::getFatherContainer() const
4468 if (_Parent
&& _Parent
->getParent())
4470 return dynamic_cast<CGroupContainer
*>(_Parent
->getParent());
4475 // ***************************************************************************
4476 CGroupContainer
*CGroupContainer::getProprietaryContainer() const
4478 if (_Parent
&& _Parent
->getParent())
4480 return dynamic_cast<CGroupContainer
*>(_Parent
->getParent());
4484 return _OldFatherContainer
;
4488 // ***************************************************************************
4489 void CGroupContainer::setOpenable(bool openable
)
4491 // COptionsLayer *pLayer = getContainerOptions();
4492 // COptionsContainerMove *options = getMoveOptions();
4493 _Openable
= openable
;
4496 updateViewOpenState();
4500 // ***************************************************************************
4501 void CGroupContainer::rollOverAlphaUp()
4504 CViewPointerBase
*vp
= CWidgetManager::getInstance()->getPointer();
4505 float speed
= CWidgetManager::getInstance()->getAlphaRolloverSpeed();
4506 if (!isIn(vp
->getX(), vp
->getY()))
4508 const CWidgetManager::SInterfaceTimes
×
= CWidgetManager::getInstance()->getInterfaceTimes();
4510 _CurrentRolloverAlphaContainer
+= (float) (speed
* times
.frameDiffMs
);
4511 _CurrentRolloverAlphaContainer
= std::min(1.f
, _CurrentRolloverAlphaContainer
);
4513 _CurrentRolloverAlphaContent
+= (float) (speed
* times
.frameDiffMs
);
4514 _CurrentRolloverAlphaContent
= std::min(1.f
, _CurrentRolloverAlphaContent
);
4518 // ***************************************************************************
4519 void CGroupContainer::forceRolloverAlpha()
4521 _CurrentRolloverAlphaContent
= hasKeyboardFocus() ? 1.0f
: 0.f
;
4522 _CurrentRolloverAlphaContainer
= hasKeyboardFocus() ? 1.0f
: 0.f
;
4525 // ***************************************************************************
4526 bool CGroupContainer::hasKeyboardFocus() const
4529 if (CWidgetManager::getInstance()->getCaptureKeyboard() != NULL
)
4531 const CGroupEditBox
*geb
= dynamic_cast<const CGroupEditBox
*>(CWidgetManager::getInstance()->getCaptureKeyboard());
4534 const CInterfaceGroup
*gr
= geb
->getParent();
4541 gr
= gr
->getParent();
4548 // ***************************************************************************
4549 void CGroupContainer::setLockable(bool lockable
)
4551 if (lockable
== _Lockable
) return;
4555 // ***************************************************************************
4556 void CGroupContainer::setLocked(bool locked
)
4560 nlwarning("Container is not lockable");
4563 if (locked
== _Locked
) return;
4565 if (_LayerSetup
== 0)
4567 updateRightButton();
4569 if (_ViewOpenState
!= NULL
) _ViewOpenState
->setActive(!_Locked
);
4570 if (_Mover
!= NULL
) _Mover
->setActive(!_Locked
);
4574 // ***************************************************************************
4575 std::string
CGroupContainer::getTitleColorAsString() const
4577 // return one of the title opened....
4579 return std::string();
4581 return _TitleOpened
->getColorAsString();
4584 // ***************************************************************************
4585 void CGroupContainer::setTitleColorAsString(const std::string
&col
)
4589 _TitleOpened
->setColorAsString(col
);
4591 _TitleClosed
->setColorAsString(col
);
4594 // ***************************************************************************
4595 void CGroupContainer::setModalParentList (const std::string
&name
)
4597 _ModalParentNames
= name
;
4599 // can have multiple parent
4600 vector
<string
> modalParents
;
4601 NLMISC::splitString(name
, "|", modalParents
);
4602 // add each of them (if possible)
4603 for(uint i
=0;i
<modalParents
.size();i
++)
4605 CGroupContainer
*pGC
= dynamic_cast<CGroupContainer
*>(CWidgetManager::getInstance()->getElementFromId(modalParents
[i
]));
4607 pGC
= dynamic_cast<CGroupContainer
*>(CWidgetManager::getInstance()->getElementFromId("ui:interface:"+modalParents
[i
]));
4609 nlwarning("<setModalParentList> not found %s",modalParents
[i
].c_str());
4611 addModalParent (pGC
);
4615 // ***************************************************************************
4616 void CGroupContainer::addModalParent (CGroupContainer
*pParent
)
4618 if(pParent
==NULL
) return;
4619 // Look if parent not already added
4620 for(uint i
=0;i
<_ModalParents
.size();++i
)
4621 if(_ModalParents
[i
] == pParent
)
4623 // add me to the parent
4624 pParent
->addModalSon(this);
4625 _ModalParents
.push_back(pParent
);
4628 // ***************************************************************************
4629 void CGroupContainer::addModalSon (CGroupContainer
*pSon
)
4631 if (pSon
== NULL
) return;
4632 // Look if the son not already added
4633 for (uint i
= 0; i
< _ModalSons
.size(); ++i
)
4634 if (_ModalSons
[i
] == pSon
)
4636 _ModalSons
.push_back(pSon
);
4639 // ***************************************************************************
4640 bool CGroupContainer::checkIfModal(const NLGUI::CEventDescriptor
& event
)
4643 if (event
.getType() == NLGUI::CEventDescriptor::mouse
)
4645 const NLGUI::CEventDescriptorMouse
&eventDesc
= (const NLGUI::CEventDescriptorMouse
&)event
;
4646 if ((eventDesc
.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouseleftdown
) ||
4647 (eventDesc
.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouserightdown
))
4649 bRet
= blinkAllSons();
4651 // Additionaly, if it is a UP, don't blink, but return false if some son active
4653 (eventDesc
.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouseleftup
) ||
4654 (eventDesc
.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouserightup
))
4663 // ***************************************************************************
4664 bool CGroupContainer::isGrayed() const
4666 bool bGrayed
= false;
4667 for (uint i
= 0; i
< _ModalSons
.size(); ++i
)
4669 CGroupContainer
*pSon
= _ModalSons
[i
];
4670 if (pSon
->getActive())
4676 // ***************************************************************************
4677 bool CGroupContainer::blinkAllSons()
4680 vector
<CGroupContainer
*> allSons
= _ModalSons
;
4682 // Recurs all sons (because allSons grow while sons are added). NB: if there is a graph, it will freeze....
4683 for (i
= 0; i
< allSons
.size(); ++i
)
4685 CGroupContainer
*pSon
= allSons
[i
];
4686 for (j
= 0; j
< pSon
->_ModalSons
.size(); ++j
)
4687 allSons
.push_back(pSon
->_ModalSons
[j
]);
4689 // Then for all sons and descendants, blink
4690 for (i
= 0; i
< allSons
.size(); ++i
)
4692 CGroupContainer
*pSon
= allSons
[i
];
4693 if (pSon
->getActive())
4695 pSon
->enableBlink(3);
4703 // ***************************************************************************
4704 void CGroupContainer::forceOpen()
4706 // Force open the container.
4708 // Ensure it is Active too
4712 // ***************************************************************************
4713 void CGroupContainer::backupPosition()
4717 _PositionBackuped
= true;
4720 // ***************************************************************************
4721 void CGroupContainer::restorePosition()
4723 if (!_PositionBackuped
) return;
4726 _PositionBackuped
= false;
4729 // ***************************************************************************
4730 bool CGroupContainer::getTouchFlag(bool clearFlag
) const
4732 bool touchFlag
= _TouchFlag
;
4740 // ***************************************************************************
4741 void CGroupContainer::setBackupPosition(sint32 x
, sint32 y
)
4745 _PositionBackuped
= true;
4748 // ***************************************************************************
4749 void CGroupContainer::setPopupMinW(sint32 minW
)
4752 // TODO : avoid this stupid copy (issue in CCtrResizer..)
4753 for(uint k
= 0; k
< NumResizers
; ++k
)
4755 if (_Resizer
[k
]) _Resizer
[k
]->WMin
= minW
;
4759 // ***************************************************************************
4760 void CGroupContainer::setPopupMaxW(sint32 maxW
)
4763 // TODO : avoid this stupid copy (issue in CCtrResizer..)
4764 for(uint k
= 0; k
< NumResizers
; ++k
)
4766 if (_Resizer
[k
]) _Resizer
[k
]->WMax
= maxW
;
4770 // ***************************************************************************
4771 void CGroupContainer::setPopupMinH(sint32 minH
)
4774 // TODO : avoid this stupid copy (issue in CCtrResizer..)
4775 for(uint k
= 0; k
< NumResizers
; ++k
)
4777 if (_Resizer
[k
]) _Resizer
[k
]->HMin
= minH
;
4781 // ***************************************************************************
4782 void CGroupContainer::setPopupMaxH(sint32 maxH
)
4785 // TODO : avoid this stupid copy (issue in CCtrResizer..)
4786 for(uint k
= 0; k
< NumResizers
; ++k
)
4788 if (_Resizer
[k
]) _Resizer
[k
]->HMax
= maxH
;
4792 // ***************************************************************************
4793 int CGroupContainer::luaSetHeaderColor(CLuaState
&ls
)
4795 const char *funcName
= "setHeaderColor";
4796 CLuaIHM::checkArgCount(ls
, funcName
, 1);
4797 CLuaIHM::checkArgType(ls
, funcName
, 1, LUA_TSTRING
);
4798 _HeaderColor
.link(ls
.toString(1));
4802 // ***************************************************************************
4803 int CGroupContainer::luaSetModalParentList(CLuaState
&ls
)
4805 const char *funcName
= "setModalParentList";
4806 CLuaIHM::checkArgCount(ls
, funcName
, 1);
4807 CLuaIHM::checkArgType(ls
, funcName
, 1, LUA_TSTRING
);
4808 setModalParentList(ls
.toString(1));
4812 // ***************************************************************************
4813 CRGBA
CGroupContainer::getDrawnHeaderColor () const
4815 CRGBA c
= CRGBA(255,255,255,255);
4817 // Display the header in white if we are the last clicked window
4818 if (CWidgetManager::getInstance()->getTopWindow(CWidgetManager::getInstance()->getLastTopWindowPriority()) != static_cast<const CInterfaceGroup
*>(this))
4820 if (_HeaderColor
.getNodePtr() != NULL
)
4821 c
= _HeaderColor
.getRGBA();
4834 // ***************************************************************************
4835 void CGroupContainer::setHelpPage(const std::string
&newPage
)
4840 // ***************************************************************************
4841 void CGroupContainer::requireAttention()
4845 // Window have headers opened => blink it if is not the top window
4848 if (getId() != CWidgetManager::getInstance()->getTopWindow()->getId())
4853 // Window have headers closed => change color of header
4856 setHeaderColor("UI:SAVE:WIN:COLORS:INFOS");
4861 // Must open this window everytime someone tell something on it
4867 // ***************************************************************************
4868 int CGroupContainer::luaBlink(CLuaState
&ls
)
4870 const char *funcName
= "blink";
4871 CLuaIHM::checkArgCount(ls
, funcName
, 1);
4872 CLuaIHM::checkArgType(ls
, funcName
, 1, LUA_TNUMBER
);
4873 enableBlink((uint
) ls
.toInteger(1));
4877 // ***************************************************************************
4878 void CGroupContainer::setRightButtonEnabled(bool enabled
)
4880 if (_EnabledRightButton
== enabled
) return;
4881 _EnabledRightButton
= enabled
;
4882 updateRightButton();
4885 // ***************************************************************************
4886 void CGroupContainer::setContentYOffset(sint32 value
)
4889 nlassert(value
<= 127 && value
>= -128);
4891 if (value
> 127 || value
< -128)
4893 // for lua exported value, let know the user that there was some problem
4894 throw NLMISC::Exception("y_offset must be in the [-128, 127] range");
4896 _ContentYOffset
= (sint8
) value
;