#include "GUIWindow.h"
#include "GUIExceptions.h"
#include "GUIWindowManager.h"
#include "GUISystem.h"
#include "GUIFontManager.h"
#include "GUIImagesetManager.h"
#include "GUIImageset.h"
#include "GUIMouseCursor.h"
#include "GUICoordConverter.h"
#include "GUIWindowRendererManager.h"
#include "../element/GUITooltip.h"
#include "../falagard/GUIFalWidgetLookManager.h"
#include "../falagard/GUIFalWidgetLookFeel.h"
#include "../falagard/GUIFalWidgetComponent.h"
#include "dch.h"
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace dch::dchsdk;
namespace DCH{ namespace GUI2D{
const string Window::EventNamespace("Window");
/*************************************************************************
Definitions for Window base class Properties
*************************************************************************/
WindowProperties::Alpha Window::d_alphaProperty;
WindowProperties::AlwaysOnTop Window::d_alwaysOnTopProperty;
WindowProperties::ClippedByParent Window::d_clippedByParentProperty;
WindowProperties::DestroyedByParent Window::d_destroyedByParentProperty;
WindowProperties::Disabled Window::d_disabledProperty;
WindowProperties::Font Window::d_fontProperty;
WindowProperties::ID Window::d_IDProperty;
WindowProperties::InheritsAlpha Window::d_inheritsAlphaProperty;
WindowProperties::MouseCursorImage Window::d_mouseCursorProperty;
WindowProperties::RestoreOldCapture Window::d_restoreOldCaptureProperty;
WindowProperties::Text Window::d_textProperty;
WindowProperties::Visible Window::d_visibleProperty;
WindowProperties::ZOrderChangeEnabled Window::d_zOrderChangeProperty;
WindowProperties::WantsMultiClickEvents Window::d_wantsMultiClicksProperty;
WindowProperties::EMouseButtonDownAutoRepeat Window::d_autoRepeatProperty;
WindowProperties::AutoRepeatDelay Window::d_autoRepeatDelayProperty;
WindowProperties::AutoRepeatRate Window::d_autoRepeatRateProperty;
WindowProperties::DistributeCapturedInputs Window::d_distInputsProperty;
WindowProperties::CustomTooltipType Window::d_tooltipTypeProperty;
WindowProperties::Tooltip Window::d_tooltipProperty;
WindowProperties::InheritsTooltipText Window::d_inheritsTooltipProperty;
WindowProperties::RiseOnClick Window::d_riseOnClickProperty;
WindowProperties::VerticalAlignment Window::d_vertAlignProperty;
WindowProperties::HorizontalAlignment Window::d_horzAlignProperty;
WindowProperties::UnifiedAreaRect Window::d_unifiedAreaRectProperty;
WindowProperties::UnifiedPosition Window::d_unifiedPositionProperty;
WindowProperties::UnifiedXPosition Window::d_unifiedXPositionProperty;
WindowProperties::UnifiedYPosition Window::d_unifiedYPositionProperty;
WindowProperties::UnifiedSize Window::d_unifiedSizeProperty;
WindowProperties::UnifiedWidth Window::d_unifiedWidthProperty;
WindowProperties::UnifiedHeight Window::d_unifiedHeightProperty;
WindowProperties::UnifiedMinSize Window::d_unifiedMinSizeProperty;
WindowProperties::UnifiedMaxSize Window::d_unifiedMaxSizeProperty;
WindowProperties::MousePassThroughEnabled Window::d_mousePassThroughEnabledProperty;
WindowProperties::WindowRenderer Window::d_windowRendererProperty;
WindowProperties::LookNFeel Window::d_lookNFeelProperty;
WindowProperties::DragDropTarget Window::d_dragDropTargetProperty;
/*************************************************************************
static data definitions
*************************************************************************/
Window* Window::d_captureWindow = 0;
/*************************************************************************
事件消息名常量
*************************************************************************/
const string Window::EventWindowUpdated ( "WindowUpdate" );
const string Window::EventParentSized( "ParentSized" );
const string Window::EventSized( "Sized" );
const string Window::EventMoved( "Moved" );
const string Window::EventTextChanged( "TextChanged" );
const string Window::EventFontChanged( "FontChanged" );
const string Window::EventAlphaChanged( "AlphaChanged" );
const string Window::EventIDChanged( "IDChanged" );
const string Window::EventActivated( "Activated" );
const string Window::EventDeactivated( "Deactivated" );
const string Window::EventShown( "Shown" );
const string Window::EventHidden( "Hidden" );
const string Window::EventEnabled( "Enabled" );
const string Window::EventDisabled( "Disabled" );
const string Window::EventClippedByParentChanged( "ClippingChanged" );
const string Window::EventDestroyedByParentChanged( "DestroyedByParentChanged" );
const string Window::EventInheritsAlphaChanged( "InheritAlphaChanged" );
const string Window::EventAlwaysOnTopChanged( "AlwaysOnTopChanged" );
const string Window::EventInputCaptureGained( "CaptureGained" );
const string Window::EventInputCaptureLost( "CaptureLost" );
const string Window::EventRenderingStarted( "StartRender" );
const string Window::EventRenderingEnded( "EndRender" );
const string Window::EventChildAdded( "AddedChild" );
const string Window::EventChildRemoved( "RemovedChild" );
const string Window::EventDestructionStarted( "DestructStart" );
const string Window::EventZOrderChanged( "ZChanged" );
const string Window::EventDragDropItemEnters("DragDropItemEnters");
const string Window::EventDragDropItemLeaves("DragDropItemLeaves");
const string Window::EventDragDropItemDropped("DragDropItemDropped");
const string Window::EventVerticalAlignmentChanged("VerticalAlignmentChanged");
const string Window::EventHorizontalAlignmentChanged("HorizontalAlignmentChanged");
const string Window::EventWindowRendererAttached("WindowRendererAttached");
const string Window::EventWindowRendererDetached("WindowRendererDetached");
const string Window::EventMouseEnters( "MouseEnter" );
const string Window::EventMouseLeaves( "MouseLeave" );
const string Window::EventMouseMove( "MouseMove" );
const string Window::EventMouseWheel( "MouseWheel" );
const string Window::EventMouseButtonDown( "EMouseButtonDown" );
const string Window::EventMouseButtonUp( "EMouseButtonUp" );
const string Window::EventMouseClick( "MouseClick" );
const string Window::EventMouseDoubleClick( "MouseDoubleClick" );
const string Window::EventMouseTripleClick( "MouseTripleClick" );
const string Window::EventKeyDown( "KeyDown" );
const string Window::EventKeyUp( "KeyUp" );
const string Window::EventCharacterKey( "CharacterKey" );
/*************************************************************************
Child Widget name suffix constants
*************************************************************************/
const string Window::TooltipNameSuffix( "__auto_tooltip__" );
const string Window::AutoWidgetNameSuffix( "__auto_" );
/*************************************************************************
Constructor
*************************************************************************/
Window::Window(const string& type, const string& name) :
d_type(type),
d_name(name)
{
// basic set-up
d_parent = 0;
d_font = 0;
d_ID = 0;
d_alpha = 1.0f;
d_mouseCursor = (const Image*)DefaultMouseCursor;
d_userData = 0;
d_needsRedraw = true;
// basic settings
d_enabled = true;
d_visible = true;
d_active = false;
d_clippedByParent = true;
d_destroyedByParent = true;
d_alwaysOnTop = false;
d_inheritsAlpha = true;
d_restoreOldCapture = false;
d_zOrderingEnabled = true;
d_wantsMultiClicks = true;
d_distCapturedInputs = false;
d_riseOnClick = true;
d_dragDropTarget = true;
// initialise mouse button auto-repeat state
d_repeatButton = NoButton;
d_autoRepeat = false;
d_repeating = false;
d_repeatDelay = 0.3f;
d_repeatRate = 0.06f;
// Tooltip setup
d_customTip = 0;
d_weOwnTip = false;
d_inheritsTipText = false;
// set initial min/max sizes. These should normally be re-set in derived classes to something appropriate.
d_minSize = UVector2(gui_reldim(0), gui_reldim(0));
d_maxSize = UVector2(gui_reldim(1), gui_reldim(1)