Beispiel #1
0
wxWindow *wxIFMComponent::GetParentWindow()
{
#if IFM_CANFLOAT
    wxIFMFloatingData *data = IFM_GET_EXTENSION_DATA(this, wxIFMFloatingData);
    if( data->m_floating )
        return data->m_window->GetWindow();
    else
#endif
        return GetManager()->GetParent();
}
Beispiel #2
0
void wxIFMDefaultPlugin::OnUndock(wxIFMUndockEvent &event)
{
    wxIFMComponent *component = event.GetComponent();
    wxIFMComponent *parent = component->m_parent;
    wxASSERT_MSG(parent, wxT("Undocking a component with a null parent?"));

    // find the child within its parent's children list and remove it
    wxIFMComponentArray &children = parent->m_children;
    //for( int i = 0, count = parent->m_children.GetCount(); i < count; ++i )
    for( wxIFMComponentArray::iterator i = children.begin(), end = children.end(); i != end; ++i )
    {
        //if( children[i] == component )
        if( *i == component )
        {
            //children.RemoveAt(i);
            children.erase(i);
            break;
        }
    }

    // delete the parent if necessary
    if( event.GetDelete() && parent->m_children.GetCount() == 0 )
    {
#if IFM_CANFLOAT
        wxIFMFloatingData *floating_data = IFM_GET_EXTENSION_DATA(parent, wxIFMFloatingData);
#endif
        // undock the parent from its parent first
        if( parent->m_docked )
        {
            wxIFMUndockEvent evt(parent);
            GetIP()->ProcessPluginEvent(evt);
        }
#if IFM_CANFLOAT
        else if( floating_data->m_floating )
        {
            // if a component is not docked but is floating, that means its the root level component
            // of a floating window. It has no children left, so destroy the floating window.
            wxIFMDestroyFloatingWindowEvent evt(floating_data->m_window, true);
            GetIP()->AddPendingEvent(evt);
        }

        if( !floating_data->m_floating )
#endif
        {
            wxIFMDeleteComponentEvent delevt(parent);
            GetIP()->ProcessPluginEvent(delevt);
        }
    }

    component->m_docked = false;
    component->m_parent = NULL;
}
Beispiel #3
0
void wxIFMDefaultPlugin::UpdateFloatingPos(wxIFMComponent *component)
{
    wxPoint pos = component->m_rect.GetPosition();

    wxIFMFloatingData *data = IFM_GET_EXTENSION_DATA(component, wxIFMFloatingData);

    // client to screen
    data->m_rect.SetPosition(data->m_window->GetWindow()->ClientToScreen(pos));

    // child windows too
    const wxIFMComponentArray &children = component->m_children;
    for( size_t i = 0; i < children.GetCount(); i++ )
        //for( wxIFMComponentArray ::const_iterator i = children.begin(), end = children.end(); i != end; ++i )
        UpdateFloatingPos(children[i]);
}
Beispiel #4
0
void wxIFMDefaultPlugin::OnSetDesiredSize(wxIFMRectEvent &event)
{
    wxIFMComponent *component = event.GetComponent();

    wxASSERT_MSG(component, wxT("NULL component?"));
    if( !component )
        return;

    wxSize size = event.GetSize();

    // handle existing values
    if( size.GetWidth() == IFM_USE_CURRENT_VALUE )
        size.SetWidth(component->m_desiredSize.GetWidth());
    if( size.GetHeight() == IFM_USE_CURRENT_VALUE )
        size.SetHeight(component->m_desiredSize.GetHeight());

    // dont size below minimum or bigger than maximum sizes
    wxIFMRectEvent minevt(wxEVT_IFM_GETMINSIZE, component);
    GetIP()->ProcessPluginEvent(minevt);
    const wxSize &minsize = minevt.GetSize();

    if( size.x < minsize.x )
        size.x = minsize.x;
    if( size.y < minsize.y )
        size.y = minsize.y;

    wxIFMRectEvent maxevt(wxEVT_IFM_GETMAXSIZE, component);
    GetIP()->ProcessPluginEvent(maxevt);
    const wxSize &maxsize = maxevt.GetSize();

    if( size.x > maxsize.x && maxsize.x != IFM_NO_MAXIMUM )
        size.x = maxsize.x;
    if( size.y > maxsize.y && maxsize.y != IFM_NO_MAXIMUM )
        size.y = maxsize.y;

    // desired sizes are set in absolute coords but stored in client coords
    wxIFMConvertRectEvent cvtevt(component, IFM_COORDS_ABSOLUTE, IFM_COORDS_CLIENT, wxPoint(0,0), size);
    GetIP()->ProcessPluginEvent(cvtevt);
    size = cvtevt.GetSize();

    component->m_desiredSize = size;

    // set desired floating size if possible
#if IFM_CANFLOAT
    wxIFMFloatingData *data = IFM_GET_EXTENSION_DATA(component, wxIFMFloatingData);
    data->m_rect.SetSize(size);
#endif
}
Beispiel #5
0
void wxIFMDefaultPlugin::OnUpdate(wxIFMUpdateComponentEvent &event)
{
    wxIFMComponent *component = event.GetComponent();

    wxASSERT_MSG(component, wxT("NULL component?"));
    if( !component )
        return;

    // invalidate the current (old)position
    component->GetParentWindow()->RefreshRect(component->m_rect);

    // size and position the component
    wxIFMRectEvent rectevt(wxEVT_IFM_SETRECT, component, event.GetRect());
    GetIP()->ProcessPluginEvent(rectevt);

    // invalidate the current (new) position
    component->GetParentWindow()->RefreshRect(component->m_rect);

    // if this component is the root component of a floating window, set the floating windows size hints here
#if IFM_CANFLOAT
    wxIFMFloatingData *data = IFM_GET_EXTENSION_DATA(component, wxIFMFloatingData);
    if( data && data->m_floating && !component->m_docked )
    {
        wxSize min = component->GetMinSize();

        // absolute to floating window coords
        wxIFMConvertRectEvent cvtevt(component, IFM_COORDS_ABSOLUTE, IFM_COORDS_FLOATINGWINDOW, wxPoint(0,0), min);
        GetIP()->ProcessEvent(cvtevt);
        const wxRect &rect = cvtevt.GetRect();
        const wxSize min2(rect.width - rect.x, rect.height - rect.y);

        data->m_window->GetWindow()->SetSizeHints(min2.x, min2.y);

        // if the window is currently too small for the minimum size, make it bigger
        wxSize size = data->m_window->GetWindow()->GetClientSize();
        if( size.x < min.x || size.y < min.y )
        {
            if( size.x < min.x )
                size.x = min.x;
            if( size.y < min.y )
                size.y = min.y;

            data->m_window->GetWindow()->SetClientSize(size);
        }
    }
#endif
}
Beispiel #6
0
void wxIFMDefaultPlugin::OnFloatNotify(wxIFMFloatNotifyEvent &event)
{
    wxIFMComponent *component = event.GetComponent();
    wxIFMFloatingData *data = IFM_GET_EXTENSION_DATA(component, wxIFMFloatingData);

    data->m_floating = event.GetFloating();
    data->m_window = event.GetWindow();

    // notify our children they are now floating
    wxIFMComponentArray &children = component->m_children;
    for( int i = 0, count = children.GetCount(); i < count; ++i )
        //for( wxIFMComponentArray::iterator i = children.begin(), end = children.end(); i != end; ++i )
    {
        wxIFMFloatNotifyEvent evt(children[i], event.GetFloating(), event.GetWindow());
        GetIP()->ProcessPluginEvent(evt);
    }
}
Beispiel #7
0
void wxInterfaceManager::CaptureInput(wxIFMComponent *component)
{
    wxASSERT_MSG(component, wxT("Invalid component attempting to capture input"));
    wxASSERT_MSG(!m_capturedComponent, wxT("A component already has captured input!"));

#if IFM_CANFLOAT
    wxIFMFloatingData *data = IFM_GET_EXTENSION_DATA(component, wxIFMFloatingData);
    if( data->m_floating )
    {
        m_floatingCapture = data->m_window;
        m_floatingCapture->GetWindow()->CaptureMouse();
    }
    else
#endif
        m_parent->CaptureMouse();

    m_capturedComponent = component;
    m_capturedType = component->GetType();
}
Beispiel #8
0
void wxIFMDefaultPlugin::OnSetChildSize(wxIFMSetChildSizeEvent &event)
{
    wxIFMComponent *component = event.GetComponent();

    wxCHECK_RET(component, wxT("Setting the size of a child not managed by this interface"));

    wxSize size;

    // min size
    size = event.GetMinSize();
    if( size.GetWidth() == IFM_USE_CURRENT_VALUE )
        size.SetWidth(component->m_minSize.GetWidth());
    if( size.GetHeight() == IFM_USE_CURRENT_VALUE )
        size.SetHeight(component->m_minSize.GetHeight());
    component->m_minSize = size;

    // max size
    size = event.GetMinSize();
    if( size.GetWidth() == IFM_USE_CURRENT_VALUE )
        size.SetWidth(component->m_maxSize.GetWidth());
    if( size.GetHeight() == IFM_USE_CURRENT_VALUE )
        size.SetHeight(component->m_maxSize.GetHeight());
    component->m_maxSize = size;

    // desired size
    size = event.GetMinSize();
    if( size.GetWidth() == IFM_USE_CURRENT_VALUE )
        size.SetWidth(component->m_desiredSize.GetWidth());
    if( size.GetHeight() == IFM_USE_CURRENT_VALUE )
        size.SetHeight(component->m_desiredSize.GetHeight());
    component->m_desiredSize = size;

    if( event.GetUpdate() )
    {
#if IFM_CANFLOAT
        wxIFMFloatingData *data = IFM_GET_EXTENSION_DATA(component, wxIFMFloatingData);
        if( data->m_floating )
            data->m_window->Update();
        else
#endif
            GetManager()->Update();
    }
}
Beispiel #9
0
void wxIFMDefaultPlugin::OnDock(wxIFMDockEvent &event)
{
    wxIFMComponent *component = event.GetComponent();
    wxASSERT_MSG(!component->m_docked, wxT("Component already docked!"));

    wxIFMComponent *destination = event.GetDestination();

    wxASSERT_MSG(component != destination, wxT("Docking a component into itself?"));
    if( component == destination )
        return;

    component->m_docked = true;
    component->m_parent = destination;

#if IFM_CANFLOAT
    wxIFMFloatingData *floating_data = IFM_GET_EXTENSION_DATA(destination, wxIFMFloatingData);

    // let the component know if it is floating now
    wxIFMFloatNotifyEvent notifyevt(component, floating_data->m_floating, floating_data->m_window);
    GetIP()->ProcessPluginEvent(notifyevt);
#endif

    int index = event.GetIndex(), count = destination->m_children.size() - 1;

    wxASSERT_MSG(component, wxT("Docking a null component?"));
    wxASSERT_MSG(destination, wxT("Null destination component?"));

    if( index == IFM_DEFAULT_INDEX || index > count )
    {
        // add it after existing components
        destination->m_children.push_back(component);
    }
    else //if( index >= 0 )
    {
        // add it where it wants to be
        destination->m_children.insert(destination->m_children.begin() + index, component);
    }
}