Example #1
0
VisualEditor::~VisualEditor()
{
    m_AuiScaner.Stop();

    AppData()->RemoveHandler( this->GetEventHandler() );
    DeleteAbstractObjects();

    ClearAui();
    ClearWizard();
    ClearComponents( m_back->GetFrameContentPanel() );
}
Example #2
0
void VisualEditor::ClearComponents( wxWindow* parent )
{
    wxLogNull stopTheLogging;
    const wxWindowList& children = parent->GetChildren();
    for ( wxWindowList::const_reverse_iterator child = children.rbegin(); child != children.rend(); ++child )
    {
        ClearComponents( *child );

        PObjectBase obj = GetObjectBase( *child );
        if ( obj )
        {
            PObjectInfo obj_info = obj->GetObjectInfo();
            IComponent* comp = obj_info->GetComponent();
            if ( comp )
            {
                comp->Cleanup( *child );
            }
        }
    }
}
Example #3
0
/**
* Crea la vista preliminar borrando la previa.
*/
void VisualEditor::Create()
{
	if ( IsShown() )
	{
		Freeze(); // Prevent flickering
	}

	// Delete objects which had no parent
	DeleteAbstractObjects();

	// Clear selections, delete objects
	m_back->SetSelectedItem(NULL);
	m_back->SetSelectedSizer(NULL);
	m_back->SetSelectedObject(PObjectBase());
	ClearComponents( m_back->GetFrameContentPanel() );
	m_back->GetFrameContentPanel()->DestroyChildren();
	m_back->GetFrameContentPanel()->SetSizer( NULL ); // *!*

	// Clear all associations between ObjectBase and wxObjects
	m_wxobjects.clear();
	m_baseobjects.clear();

	m_form = AppData()->GetSelectedForm();
	if ( m_form )
	{
		m_back->Show(true);

		// --- [1] Configure the size of the form ---------------------------

		// Get size properties
		wxSize minSize( m_form->GetPropertyAsSize( wxT("minimum_size") ) );
		m_back->SetMinSize( minSize );

		wxSize maxSize( m_form->GetPropertyAsSize( wxT("maximum_size") ) );
		m_back->SetMaxSize( maxSize );

		wxSize size( m_form->GetPropertyAsSize( wxT("size") ) );

		// Determine necessary size for back panel
		wxSize backSize = size;
		if ( backSize.GetWidth() < minSize.GetWidth() && backSize.GetWidth() != wxDefaultCoord )
		{
			backSize.SetWidth( minSize.GetWidth() );
		}
		if ( backSize.GetHeight() < minSize.GetHeight() && backSize.GetHeight() != wxDefaultCoord )
		{
			backSize.SetHeight( minSize.GetHeight() );
		}
		if ( backSize.GetWidth() > maxSize.GetWidth() && maxSize.GetWidth() != wxDefaultCoord )
		{
			backSize.SetWidth( maxSize.GetWidth() );
		}
		if ( backSize.GetHeight() > maxSize.GetHeight() && maxSize.GetHeight() != wxDefaultCoord )
		{
			backSize.SetHeight( maxSize.GetHeight() );
		}

		// Modify size property to match
		if ( size != backSize )
		{
			PProperty psize = m_form->GetProperty( wxT("size") );
			if ( psize )
			{
				AppData()->ModifyProperty( psize, TypeConv::SizeToString( backSize ) );
			}
		}

		// --- [2] Set the color of the form -------------------------------
		PProperty background( m_form->GetProperty( wxT("bg") ) );
		if ( background && !background->GetValue().empty() )
		{
			m_back->GetFrameContentPanel()->SetBackgroundColour( TypeConv::StringToColour( background->GetValue() ) );
		}
		else
		{
			if ( m_form->GetClassName() == wxT("Frame") )
			{
				m_back->GetFrameContentPanel()->SetOwnBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_APPWORKSPACE ) );
			}
			else
			{
				m_back->GetFrameContentPanel()->SetOwnBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_BTNFACE ) );
			}
		}


		// --- [3] Title bar Setup
		if (  m_form->GetClassName() == wxT("Frame") || m_form->GetClassName() == wxT("Dialog") )
		{
			m_back->SetTitle( m_form->GetPropertyAsString( wxT("title") ) );
			long style = m_form->GetPropertyAsInteger( wxT("style") );
			m_back->SetTitleStyle( style );
			m_back->ShowTitleBar( (style & wxCAPTION) != 0 );
		}
		else
		  m_back->ShowTitleBar(false);

		// --- [4] Create the components of the form -------------------------

		// Used to save frame objects for later display
		PObjectBase menubar;
		wxWindow* statusbar = NULL;
		wxWindow* toolbar = NULL;

		for ( unsigned int i = 0; i < m_form->GetChildCount(); i++ )
		{
			PObjectBase child = m_form->GetChild( i );

			if (child->GetObjectTypeName() == wxT("menubar") )
			{
				// Create the menubar later
				menubar = child;
			}
			else
			{
				// Recursively generate the ObjectTree
				try
				{
				  // we have to put the content frame panel as parentObject in order
				  // to SetSizeHints be called.
					Generate( child, m_back->GetFrameContentPanel(), m_back->GetFrameContentPanel() );
				}
				catch ( wxFBException& ex )
				{
					wxLogError ( ex.what() );
				}
			}

			// Attach the status bar (if any) to the frame
			if ( child->GetClassName() == wxT("wxStatusBar") )
			{
				ObjectBaseMap::iterator it = m_baseobjects.find( child.get() );
				statusbar = wxDynamicCast( it->second, wxStatusBar );
			}

			// Attach the toolbar (if any) to the frame
			if (child->GetClassName() == wxT("wxToolBar") )
			{
				ObjectBaseMap::iterator it = m_baseobjects.find( child.get() );
				toolbar = wxDynamicCast( it->second, wxToolBar );
			}
		}

		if ( menubar || statusbar || toolbar )
		{
			m_back->SetFrameWidgets( menubar, toolbar, statusbar );
		}

		m_back->Layout();

		if ( backSize.GetHeight() == wxDefaultCoord || backSize.GetWidth() == wxDefaultCoord )
		{
		    m_back->GetSizer()->Fit( m_back );
			m_back->SetSize( m_back->GetBestSize() );
		}

		// Set size after fitting so if only one dimesion is -1, it still fits that dimension
		m_back->SetSize( backSize );

		PProperty enabled( m_form->GetProperty( wxT("enabled") ) );
		if ( enabled )
		{
			m_back->Enable( TypeConv::StringToInt( enabled->GetValue() ) != 0 );
		}

		PProperty hidden( m_form->GetProperty( wxT("hidden") ) );
		if ( hidden )
		{
			m_back->Show( TypeConv::StringToInt( hidden->GetValue() ) == 0 );
		}
	}
	else
	{
		// There is no form to display
		m_back->Show(false);
	}

	if ( IsShown() )
	{
		Thaw();
	}

	UpdateVirtualSize();
}
Example #4
0
VisualEditor::~VisualEditor()
{
	AppData()->RemoveHandler( this->GetEventHandler() );
	DeleteAbstractObjects();
	ClearComponents( m_back->GetFrameContentPanel() );
}
Example #5
0
GameObject::~GameObject(void)
{
	ClearComponents();
}
Example #6
0
/**
* Crea la vista preliminar borrando la previa.
*/
void VisualEditor::Create()
{
#if wxVERSION_NUMBER < 2900 && !defined(__WXGTK__ )
    if ( IsShown() )
    {
        Freeze();   // Prevent flickering on wx 2.8,
        // Causes problems on wx 2.9 in wxGTK (e.g. wxNoteBook objects)
    }
#endif
    // Delete objects which had no parent
    DeleteAbstractObjects();

    // Clear selections, delete objects
    m_back->SetSelectedItem(NULL);
    m_back->SetSelectedSizer(NULL);
    m_back->SetSelectedObject(PObjectBase());

    ClearAui();
    ClearWizard();
    ClearComponents( m_back->GetFrameContentPanel() );

    m_back->GetFrameContentPanel()->DestroyChildren();
    m_back->GetFrameContentPanel()->SetSizer( NULL ); // *!*

    // Clear all associations between ObjectBase and wxObjects
    m_wxobjects.clear();
    m_baseobjects.clear();

    if( IsShown() )
    {
        m_form = AppData()->GetSelectedForm();
        if ( m_form )
        {
            m_back->Show(true);

            // --- [1] Configure the size of the form ---------------------------

            // Get size properties
            wxSize minSize( m_form->GetPropertyAsSize( wxT("minimum_size") ) );
            m_back->SetMinSize( minSize );

            wxSize maxSize( m_form->GetPropertyAsSize( wxT("maximum_size") ) );
            m_back->SetMaxSize( maxSize );

            wxSize size( m_form->GetPropertyAsSize( wxT("size") ) );

            // Determine necessary size for back panel
            wxSize backSize = size;
            if ( backSize.GetWidth() < minSize.GetWidth() && backSize.GetWidth() != wxDefaultCoord )
            {
                backSize.SetWidth( minSize.GetWidth() );
            }
            if ( backSize.GetHeight() < minSize.GetHeight() && backSize.GetHeight() != wxDefaultCoord )
            {
                backSize.SetHeight( minSize.GetHeight() );
            }
            if ( backSize.GetWidth() > maxSize.GetWidth() && maxSize.GetWidth() != wxDefaultCoord )
            {
                backSize.SetWidth( maxSize.GetWidth() );
            }
            if ( backSize.GetHeight() > maxSize.GetHeight() && maxSize.GetHeight() != wxDefaultCoord )
            {
                backSize.SetHeight( maxSize.GetHeight() );
            }

            // Modify size property to match
            if ( size != backSize )
            {
                PProperty psize = m_form->GetProperty( wxT("size") );
                if ( psize )
                {
                    AppData()->ModifyProperty( psize, TypeConv::SizeToString( backSize ) );
                }
            }

            // --- [2] Set the color of the form -------------------------------
            PProperty background( m_form->GetProperty( wxT("bg") ) );
            if ( background && !background->GetValue().empty() )
            {
                m_back->GetFrameContentPanel()->SetBackgroundColour( TypeConv::StringToColour( background->GetValue() ) );
            }
            else
            {
                if ( m_form->GetClassName() == wxT("Frame") )
                {
                    m_back->GetFrameContentPanel()->SetOwnBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_APPWORKSPACE ) );
                }
                else
                {
#ifdef __WXGTK__
                    wxVisualAttributes attribs = wxToolBar::GetClassDefaultAttributes();
                    m_back->GetFrameContentPanel()->SetOwnBackgroundColour( attribs.colBg );
#else
                    m_back->GetFrameContentPanel()->SetOwnBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_BTNFACE ) );
#endif
                }
            }

            // --- [3] Title bar Setup
            if (  m_form->GetClassName() == wxT("Frame")  ||
                    m_form->GetClassName() == wxT("Dialog") ||
                    m_form->GetClassName() == wxT("Wizard") )
            {
                m_back->SetTitle( m_form->GetPropertyAsString( wxT("title") ) );
                long style = m_form->GetPropertyAsInteger( wxT("style") );
                m_back->SetTitleStyle( style );
                m_back->ShowTitleBar( (style & wxCAPTION) != 0 );
            }
            else
                m_back->ShowTitleBar(false);

            // --- AUI
            if(  m_form->GetObjectTypeName() == wxT("form") )
            {
                if(  m_form->GetPropertyAsInteger( wxT("aui_managed") ) == 1)
                {
                    m_auipanel = new wxPanel( m_back->GetFrameContentPanel() );
                    m_auimgr = new wxAuiManager( m_auipanel, m_form->GetPropertyAsInteger( wxT("aui_manager_style") ) );
                }
            }

            // --- Wizard
            if ( m_form->GetClassName() == wxT("Wizard") )
            {
                m_wizard = new Wizard( m_back->GetFrameContentPanel() );

                bool showbutton = false;
                PProperty pextra_style = m_form->GetProperty( wxT("extra_style") );
                if ( pextra_style )
                {
                    showbutton = pextra_style->GetValue().Contains( wxT("wxWIZARD_EX_HELPBUTTON") );
                }

                m_wizard->ShowHelpButton( showbutton );

                if ( !m_form->GetProperty( wxT("bitmap") )->IsNull() )
                {
                    wxBitmap bmp = m_form->GetPropertyAsBitmap( wxT("bitmap") );
                    if ( bmp.IsOk() )
                    {
                        m_wizard->SetBitmap( bmp );
                    }
                }
            }

            // --- [4] Create the components of the form -------------------------

            // Used to save frame objects for later display
            PObjectBase menubar;
            wxWindow* statusbar = NULL;
            wxWindow* toolbar = NULL;

            for ( unsigned int i = 0; i < m_form->GetChildCount(); i++ )
            {
                PObjectBase child = m_form->GetChild( i );

                if( !menubar && (m_form->GetObjectTypeName() == wxT("menubar_form")) )
                {
                    // main form acts as a menubar
                    menubar = m_form;
                }
                else if (child->GetObjectTypeName() == wxT("menubar") )
                {
                    // Create the menubar later
                    menubar = child;
                }
                else if( !toolbar && (m_form->GetObjectTypeName() == wxT("toolbar_form")) )
                {
                    Generate( m_form, m_back->GetFrameContentPanel(), m_back->GetFrameContentPanel() );

                    ObjectBaseMap::iterator it = m_baseobjects.find( m_form.get() );
                    toolbar = wxDynamicCast( it->second, wxToolBar );

                    break;
                }
                else
                {
                    // Recursively generate the ObjectTree
                    try
                    {
                        // we have to put the content frame panel as parentObject in order
                        // to SetSizeHints be called.
                        if( m_auipanel )
                        {
                            Generate( child, m_auipanel, m_auipanel );
                        }
                        else if( m_wizard )
                        {
                            Generate( child, m_wizard, m_wizard );
                        }
                        else
                            Generate( child, m_back->GetFrameContentPanel(), m_back->GetFrameContentPanel() );

                    }
                    catch ( wxFBException& ex )
                    {
                        wxLogError ( ex.what() );
                    }
                }

                // Attach the toolbar (if any) to the frame
                if (child->GetClassName() == wxT("wxToolBar") )
                {
                    ObjectBaseMap::iterator it = m_baseobjects.find( child.get() );
                    toolbar = wxDynamicCast( it->second, wxToolBar );
                }
                else if (child->GetClassName() == wxT("wxAuiToolBar") )
                {
                    ObjectBaseMap::iterator it = m_baseobjects.find( child.get() );
                    toolbar = wxDynamicCast( it->second, wxAuiToolBar );
                }

                // Attach the status bar (if any) to the frame
                if ( child->GetClassName() == wxT("wxStatusBar") )
                {
                    ObjectBaseMap::iterator it = m_baseobjects.find( child.get() );
                    statusbar = wxDynamicCast( it->second, wxStatusBar );
                }

                // Add toolbar(s) to AuiManager and update content
                if( m_auimgr && toolbar )
                {
                    SetupAui( GetObjectBase( toolbar ), toolbar );
                    toolbar = NULL;
                }
            }

            if ( menubar || statusbar || toolbar || m_auipanel || m_wizard )
            {
                if( m_auimgr )
                {
                    m_back->SetFrameWidgets( menubar, NULL, statusbar, m_auipanel );
                }
                else if( m_wizard )
                {
                    m_back->SetFrameWidgets( menubar, NULL, NULL, m_wizard );
                }
                else
                    m_back->SetFrameWidgets( menubar, toolbar, statusbar, m_auipanel );
            }

            m_back->Layout();

            if ( backSize.GetHeight() == wxDefaultCoord || backSize.GetWidth() == wxDefaultCoord )
            {
                m_back->GetSizer()->Fit( m_back );
                m_back->SetSize( m_back->GetBestSize() );
            }

            // Set size after fitting so if only one dimesion is -1, it still fits that dimension
            m_back->SetSize( backSize );

            if( m_auimgr ) m_auimgr->Update();
            else
                m_back->Refresh();

            PProperty enabled( m_form->GetProperty( wxT("enabled") ) );
            if ( enabled )
            {
                m_back->Enable( TypeConv::StringToInt( enabled->GetValue() ) != 0 );
            }

            PProperty hidden( m_form->GetProperty( wxT("hidden") ) );
            if ( hidden )
            {
                m_back->Show( TypeConv::StringToInt( hidden->GetValue() ) == 0 );
            }
        }
        else
        {
            // There is no form to display
            m_back->Show(false);
            Refresh();
        }
#if wxVERSION_NUMBER < 2900 && !defined(__WXGTK__)
        Thaw();
#endif
    }

    UpdateVirtualSize();
}
Example #7
0
			void GuiInstanceRootObject::FinalizeInstance()
			{
				ClearSubscriptions();
				ClearComponents();
			}