Example #1
0
void wxDialogBase::OnCloseWindow(wxCloseEvent& WXUNUSED(event))
{
    // We'll send a Cancel message by default, which may close the dialog.
    // Check for looping if the Cancel event handler calls Close().

    // Note that if a cancel button and handler aren't present in the dialog,
    // nothing will happen when you close the dialog via the window manager, or
    // via Close(). We wouldn't want to destroy the dialog by default, since
    // the dialog may have been created on the stack. However, this does mean
    // that calling dialog->Close() won't delete the dialog unless the handler
    // for wxID_CANCEL does so. So use Destroy() if you want to be sure to
    // destroy the dialog. The default OnCancel (above) simply ends a modal
    // dialog, and hides a modeless dialog.

    int idCancel = GetEscapeId();
    if ( idCancel == wxID_NONE )
        return;
    if ( idCancel == wxID_ANY )
        idCancel = wxID_CANCEL;

    // VZ: this is horrible and MT-unsafe. Can't we reuse some of these global
    //     lists here? don't dare to change it now, but should be done later!
    static wxList closing;

    if ( closing.Member(this) )
        return;

    closing.Append(this);

    wxCommandEvent cancelEvent(wxEVT_COMMAND_BUTTON_CLICKED, idCancel);
    cancelEvent.SetEventObject( this );
    GetEventHandler()->ProcessEvent(cancelEvent); // This may close the dialog

    closing.DeleteObject(this);
}
Example #2
0
void wxDialogBase::OnCloseWindow(wxCloseEvent& WXUNUSED(event))
{
    // We'll send a Cancel message by default, which may close the dialog.

    // Check for looping if the Cancel event handler calls Close().
    //
    // VZ: this is horrible and MT-unsafe. Can't we reuse some of these global
    //     lists here? don't dare to change it now, but should be done later!
    static wxList closing;

    if ( closing.Member(this) )
        return;

    closing.Append(this);

    if ( !SendCloseButtonClickEvent() )
    {
        // If the handler didn't close the dialog (e.g. because there is no
        // button with matching id) we still want to close it when the user
        // clicks the "x" button in the title bar, otherwise we shouldn't even
        // have put it there.
        //
        // Notice that using wxID_CLOSE might have been a better choice but we
        // use wxID_CANCEL for compatibility reasons.
        EndDialog(wxID_CANCEL);
    }

    closing.DeleteObject(this);
}
Example #3
0
void wxDialog::SetModal(bool flag)
{
   if ( flag )
       wxModelessWindows.DeleteObject(this);
   else
       wxModelessWindows.Append(this);
}
Example #4
0
void wxDialogBase::OnCloseWindow(wxCloseEvent& WXUNUSED(event))
{
    // We'll send a Cancel message by default, which may close the dialog.

    // Check for looping if the Cancel event handler calls Close().
    //
    // VZ: this is horrible and MT-unsafe. Can't we reuse some of these global
    //     lists here? don't dare to change it now, but should be done later!
    static wxList closing;

    if ( closing.Member(this) )
        return;

    closing.Append(this);

    // When a previously hidden (necessarily modeless) dialog is being closed,
    // we must not perform the usual validation and data transfer steps as they
    // had been already done when it was hidden and doing it again now would be
    // unexpected and could result in e.g. the dialog asking for confirmation
    // before discarding the changes being shown again, which doesn't make
    // sense as the dialog is not being closed in response to any user action.
    if ( !IsShown() || !SendCloseButtonClickEvent() )
    {
        // If the handler didn't close the dialog (e.g. because there is no
        // button with matching id) we still want to close it when the user
        // clicks the "x" button in the title bar, otherwise we shouldn't even
        // have put it there.
        //
        // Notice that using wxID_CLOSE might have been a better choice but we
        // use wxID_CANCEL for compatibility reasons.
        EndDialog(wxID_CANCEL);
    }

    closing.DeleteObject(this);
}
Example #5
0
void wxDialog::OnCloseWindow(wxCloseEvent& WXUNUSED(event))
{
    // We'll send a Cancel message by default,
    // which may close the dialog.
    // Check for looping if the Cancel event handler calls Close().

    // Note that if a cancel button and handler aren't present in the dialog,
    // nothing will happen when you close the dialog via the window manager, or
    // via Close().
    // We wouldn't want to destroy the dialog by default, since the dialog may have been
    // created on the stack.
    // However, this does mean that calling dialog->Close() won't delete the dialog
    // unless the handler for wxID_CANCEL does so. So use Destroy() if you want to be
    // sure to destroy the dialog.
    // The default OnCancel (above) simply ends a modal dialog, and hides a modeless dialog.

    static wxList closing;

    if ( closing.Member(this) )
        return;

    closing.Append(this);

    wxCommandEvent cancelEvent(wxEVT_COMMAND_BUTTON_CLICKED, wxID_CANCEL);
    cancelEvent.SetEventObject( this );
    GetEventHandler()->ProcessEvent(cancelEvent); // This may close the dialog

    closing.DeleteObject(this);
}
Example #6
0
void MyFrame::OnClose(wxCloseEvent& event)
{
    if ( !event.CanVeto() )
    {
        event.Skip();
        return ;
    }
    if ( m_children.GetCount () < 1 )
    {
        event.Skip();
        return ;
    }
    // now try the children
    wxObjectList::compatibility_iterator pNode = m_children.GetFirst ();
    wxObjectList::compatibility_iterator pNext ;
    MyChild * pChild ;
    while ( pNode )
    {
        pNext = pNode -> GetNext ();
        pChild = (MyChild*) pNode -> GetData ();
        if (pChild -> Close ())
        {
            m_children.Erase(pNode) ;
        }
        else
        {
            event.Veto();
            return;
        }
        pNode = pNext ;
    }
    event.Skip();
}
Example #7
0
File: view.cpp Project: EdgarTx/wx
void csDiagramView::DoCut(wxList& shapes)
{
    csDiagramDocument *doc = (csDiagramDocument *)GetDocument();

    if (shapes.GetCount() > 0)
    {
        csDiagramCommand* cmd = new csDiagramCommand(_T("Cut"), doc);

        wxObjectList::compatibility_iterator node = shapes.GetFirst();
        while (node)
        {
            wxShape *theShape = (wxShape*) node->GetData();
            csCommandState* state = new csCommandState(ID_CS_CUT, NULL, theShape);

            // Insert lines at the front, so they are cut first.
            // Otherwise we may try to remove a shape with a line still
            // attached.
            if (theShape->IsKindOf(CLASSINFO(wxLineShape)))
                cmd->InsertState(state);
            else
                cmd->AddState(state);

            node = node->GetNext();
        }
        cmd->RemoveLines(); // Schedule any connected lines, not already mentioned,
                            // to be removed first

        doc->GetCommandProcessor()->Submit(cmd);
    }
}
Example #8
0
static void ClearSplineList()
{
      wxList::compatibility_iterator node = ocpn_wx_spline_point_list.GetFirst();
      while (node)
      {
            wxPoint *point = (wxPoint *)node->GetData();
            delete point;
            ocpn_wx_spline_point_list.Erase(node);
            node = ocpn_wx_spline_point_list.GetFirst();
      }
}
Example #9
0
static void wx_spline_draw_point_array(wxDCBase *dc)
{
  dc->DrawLines(&wx_spline_point_list, 0, 0 );
  wxList::compatibility_iterator node = wx_spline_point_list.GetFirst();
  while (node)
  {
    wxPoint *point = (wxPoint *)node->GetData();
    delete point;
    wx_spline_point_list.Erase(node);
    node = wx_spline_point_list.GetFirst();
  }
}
Example #10
0
void GarbageCollector::DestroyItemList( wxList& lst )
{
    wxNode* pNode = lst.GetFirst();

    while( pNode )
    {
        delete &node_to_item( pNode );

        pNode = pNode->GetNext();
    }

    lst.Clear();
}
Example #11
0
void wxFontRefData::ClearX11Fonts()
{
#if wxUSE_UNICODE
#else
    wxList::compatibility_iterator node = m_fonts.GetFirst();
    while (node)
    {
        wxXFont* f = (wxXFont*) node->GetData();
        delete f;
        node = node->GetNext();
    }
    m_fonts.Clear();
#endif
}
Example #12
0
/// Remove a style
bool wxRichTextStyleSheet::RemoveStyle(wxList& list, wxRichTextStyleDefinition* def, bool deleteStyle)
{
    wxList::compatibility_iterator node = list.Find(def);
    if (node)
    {
        wxRichTextStyleDefinition* def = (wxRichTextStyleDefinition*) node->GetData();
        list.Erase(node);
        if (deleteStyle)
            delete def;
        return true;
    }
    else
        return false;
}
Example #13
0
void wxTopLevelWindowMotif::PreDestroy()
{
#ifdef __VMS
#pragma message disable codcauunr
#endif
   if ( (GetWindowStyleFlag() & wxDIALOG_MODAL) != wxDIALOG_MODAL )
        wxModelessWindows.DeleteObject(this);
#ifdef __VMS
#pragma message enable codcauunr
#endif

    m_icons.m_icons.Empty();

    DestroyChildren();

    // MessageDialog and FileDialog do not have a client widget
    if( GetClientWidget() )
    {
        XtRemoveEventHandler( (Widget)GetClientWidget(),
                              ButtonPressMask | ButtonReleaseMask |
                              PointerMotionMask | KeyPressMask,
                              False,
                              wxTLWEventHandler,
                              (XtPointer)this );
    }
}
Example #14
0
void wxDialog::DoShowModal()
{
    wxCHECK_RET( !IsModalShowing(), _T("DoShowModal() called twice") );

    wxModalDialogs.Append(this);

    SetFocus() ;
    
#if TARGET_CARBON
    BeginAppModalStateForWindow(  (WindowRef) MacGetWindowRef()) ;
#else
    // TODO : test whether parent gets disabled
    bool formerModal = s_macIsInModalLoop ;
    s_macIsInModalLoop = true ;
#endif
    while ( IsModalShowing() )
    {
        wxTheApp->MacDoOneEvent() ;
        // calls process idle itself
    }

#if TARGET_CARBON
    EndAppModalStateForWindow( (WindowRef) MacGetWindowRef() ) ;
#else
    // TODO probably reenable the parent window if any
    s_macIsInModalLoop = formerModal ;
#endif
}
Example #15
0
bool wxDialog::Show(bool show)
{
    if ( !wxDialogBase::Show(show) )
    {
        // nothing to do
        return FALSE;
    }

    if ( show )
    {
        // usually will result in TransferDataToWindow() being called
        InitDialog();
    }

    if ( IsModal() )
    {
        if ( show )
        {
            DoShowModal();
        }
        else // end of modal dialog
        {
            // this will cause IsModalShowing() return FALSE and our local
            // message loop will terminate
            wxModalDialogs.DeleteObject(this);
        }
    }

    return TRUE;
}
Example #16
0
MyChild::MyChild(wxMDIParentFrame *parent, const wxString& title, const wxPoint& pos, const wxSize& size,
const long style):
  wxMDIChildFrame(parent, wxID_ANY, title, pos, size, style)
{
  canvas = NULL;
  my_children.Append(this);
}
Example #17
0
static bool ocpn_wx_spline_add_point(double x, double y)
{
      wxPoint *point = new wxPoint ;
      point->x = (int) x;
      point->y = (int) y;
      ocpn_wx_spline_point_list.Append((wxObject*)point);
      return true;
}
Example #18
0
void wxDialog::SetModal(bool flag)
{
#ifdef __VMS
#pragma message disable codcauunr
#endif
   if ( flag )
        m_windowStyle |= wxDIALOG_MODAL ;
    else
        if ( m_windowStyle & wxDIALOG_MODAL )
            m_windowStyle -= wxDIALOG_MODAL ;

        wxModelessWindows.DeleteObject(this);
        if (!flag)
            wxModelessWindows.Append(this);
#ifdef __VMS
#pragma message enable codcauunr
#endif
}
Example #19
0
void wxTreeLayoutStored::GetChildren(long id, wxList& list)
{
    long currentId = GetTopNode();
    while (currentId != wxID_ANY)
    {
        if (id == GetNodeParent(currentId))
            list.Append((wxObject *)currentId);
        currentId = GetNextNode(currentId);
    }
}
Example #20
0
void MyFrame::OnNewWindow(wxCommandEvent& WXUNUSED(event) )
{
    // Make another frame, containing a canvas
    MyChild *subframe ;

    m_children.Append (new MyChild(frame, wxT("SVG Frame"),
        wxPoint(-1, -1), wxSize(-1, -1),
        wxDEFAULT_FRAME_STYLE )   ) ;

    subframe = (MyChild *) m_children.GetLast() -> GetData ();
    wxString title;
    title.Printf(wxT("SVG Test Window %d"), nWinCreated );
    // counts number of children previously, even if now closed
    nWinCreated ++ ;

    // Give it a title and icon
    subframe->SetTitle(title);
    subframe->SetIcon(wxICON(mondrian));

    // Make a menubar
    wxMenu *file_menu = new wxMenu;

    file_menu->Append(MDI_NEW_WINDOW, wxT("&Another test\tCtrl+N"));
    file_menu->Append(MDI_SAVE, wxT("&Save\tCtrl+S"), wxT("Save in SVG format"));
    file_menu->Append(MDI_CHILD_QUIT, wxT("&Close child\tCtrl+F4"));
    file_menu->Append(MDI_QUIT, wxT("&Exit\tAlt+X"));

    wxMenu *help_menu = new wxMenu;
    help_menu->Append(MDI_ABOUT, wxT("&About"));

    wxMenuBar *menu_bar = new wxMenuBar;

    menu_bar->Append(file_menu, wxT("&File"));
    menu_bar->Append(help_menu, wxT("&Help"));

    // Associate the menu bar with the frame
    subframe->SetMenuBar(menu_bar);

    subframe->Show(true);
}
Example #21
0
void wxFontRefData::ClearX11Fonts()
{
#if wxUSE_UNICODE
#else
    wxList::compatibility_iterator node = m_fonts.GetFirst();
#if defined(__INTEL_COMPILER) && 1 /* VDM auto patch */
#   pragma ivdep
#   pragma swp
#   pragma unroll
#   pragma prefetch
#   if 0
#       pragma simd noassert
#   endif
#endif /* VDM auto patch */
    while (node)
    {
        wxXFont* f = (wxXFont*) node->GetData();
        delete f;
        node = node->GetNext();
    }
    m_fonts.Clear();
#endif
}
Example #22
0
File: view.cpp Project: EdgarTx/wx
void csDiagramView::FindSelectedShapes(wxList& selections, wxClassInfo* toFind)
{
  csDiagramDocument *doc = (csDiagramDocument *)GetDocument();
  wxObjectList::compatibility_iterator node = doc->GetDiagram()->GetShapeList()->GetFirst();
  while (node)
  {
    wxShape *eachShape = (wxShape *)node->GetData();
    if ((eachShape->GetParent() == NULL) && !eachShape->IsKindOf(CLASSINFO(wxLabelShape)) && eachShape->Selected() && ((toFind == NULL) || (eachShape->IsKindOf(toFind))))
    {
      selections.Append(eachShape);
    }
    node = node->GetNext();
  }
}
Example #23
0
File: view.cpp Project: EdgarTx/wx
// Generalised command
void csDiagramView::DoCmd(wxList& shapes, wxList& oldShapes, int cmd, const wxString& op)
{
    csDiagramDocument *doc = (csDiagramDocument *)GetDocument();

    if (shapes.GetCount() > 0)
    {
        csDiagramCommand* command = new csDiagramCommand(op, doc);

        wxObjectList::compatibility_iterator node = shapes.GetFirst();
        wxObjectList::compatibility_iterator node1 = oldShapes.GetFirst();
        while (node && node1)
        {
            wxShape *theShape = (wxShape*) node->GetData();
            wxShape *oldShape = (wxShape*) node1->GetData();
            csCommandState* state = new csCommandState(cmd, theShape, oldShape);
            command->AddState(state);

            node = node->GetNext();
            node1 = node1->GetNext();
        }
        doc->GetCommandProcessor()->Submit(command);
    }
}
Example #24
0
void cbGCUpdatesMgr::AddItem( wxList&     itemList,
                              cbBarInfo*  pBar, 
                              cbDockPane* pPane,
                              wxRect&     curBounds,
                              wxRect&     prevBounds )
{
    cbRectInfo* pInfo = new cbRectInfo();

    pInfo->mpBar     = pBar;
    pInfo->mpPane       = pPane;
    pInfo->mpCurBounds  = &curBounds;
    pInfo->mpPrevBounds = &prevBounds;

    itemList.Append( (wxObject*) pInfo );
}
Example #25
0
void wxTopLevelWindowMotif::PreDestroy()
{
    wxModelessWindows.DeleteObject(this);

    DestroyChildren();

    // MessageDialog and FileDialog do not have a client widget
    if( GetClientWidget() )
    {
        XtRemoveEventHandler( (Widget)GetClientWidget(),
                              ButtonPressMask | ButtonReleaseMask |
                              PointerMotionMask | KeyPressMask,
                              False,
                              wxTLWEventHandler,
                              (XtPointer)this );
    }
}
Example #26
0
wxOGLConstraint::wxOGLConstraint(int type, wxShape *constraining, wxList &constrained)
{
	m_xSpacing = 0.0;
	m_ySpacing = 0.0;

	m_constraintType = type;
	m_constrainingObject = constraining;

	m_constraintId = 0;
	m_constraintName = wxT("noname");

	wxNode *node = constrained.GetFirst();
	while (node)
	{
		m_constrainedObjects.Append(node->GetData());
		node = node->GetNext();
	}
}
Example #27
0
// Helper for wxCreateAcceleratorTableForMenuBar
static void wxAddAccelerators(wxList& accelEntries, wxMenu* menu)
{
    size_t i;
    for (i = 0; i < menu->GetMenuItems().GetCount(); i++)
    {
        wxMenuItem* item = (wxMenuItem*) menu->GetMenuItems().Item(i)->GetData();
        if (item->GetSubMenu())
        {
            wxAddAccelerators(accelEntries, item->GetSubMenu());
        }
        else if (!item->GetItemLabel().IsEmpty())
        {
            wxAcceleratorEntry* entry = wxAcceleratorEntry::Create(item->GetItemLabel());
            if (entry)
            {
                entry->Set(entry->GetFlags(), entry->GetKeyCode(), item->GetId());
                accelEntries.Append((wxObject*) entry);
            }
        }
    }
}