void WindowTestCase::Children()
{
    CPPUNIT_ASSERT_EQUAL(0, m_window->GetChildren().GetCount());

    wxWindow* child1 = new wxWindow(m_window, wxID_ANY);

    CPPUNIT_ASSERT_EQUAL(1, m_window->GetChildren().GetCount());

    m_window->RemoveChild(child1);

    CPPUNIT_ASSERT_EQUAL(0, m_window->GetChildren().GetCount());

    child1->SetId(wxID_HIGHEST + 1);
    child1->SetName("child1");

    m_window->AddChild(child1);

    CPPUNIT_ASSERT_EQUAL(1, m_window->GetChildren().GetCount());
    CPPUNIT_ASSERT_EQUAL(child1, m_window->FindWindow(wxID_HIGHEST + 1));
    CPPUNIT_ASSERT_EQUAL(child1, m_window->FindWindow("child1"));

    m_window->DestroyChildren();

    CPPUNIT_ASSERT_EQUAL(0, m_window->GetChildren().GetCount());
}
Beispiel #2
0
void
EnableLetter(wxWindow& window, bool letters)
{
	// on first time, we need to set up values
	window.FindWindow(ShowInfoReq_ID_POINTS_PER_LETTER)->Enable(letters);
	window.FindWindow(ShowInfoReq_ID_LABEL_LETTERS)->Enable(letters);
}
Beispiel #3
0
void
raiseMovementEvent(
  wxWindow &Control,
  std::shared_ptr<StateAccessToken> &Access,
  std::function<seec::cm::MovementResult (seec::cm::ProcessState &State)> Mover)
{
  auto const Handler = Control.GetEventHandler();
  if (!Handler) {
    wxLogDebug("raiseMovementEvent: wxWindow does not have an event handler.");
    return;
  }
  
  if (!Access) {
    wxLogDebug("raiseMovementEvent: no access provided.");
    return;
  }
  
  auto LockAccess = Access->getAccess();
  if (!LockAccess) { // Token is out of date.
    wxLogDebug("raiseMovementEvent: access token is outdated.");
    return;
  }
  
  ProcessMoveEvent Ev {
    SEEC_EV_PROCESS_MOVE,
    Control.GetId(),
    std::move(Mover)
  };
  
  Ev.SetEventObject(&Control);
  
  LockAccess.release();
  
  Handler->AddPendingEvent(Ev);
}
Beispiel #4
0
void SetSizeTestCase::SetSizeLessThanMinSize()
{
    m_win->SetMinSize(wxSize(100, 100));

    const wxSize size(200, 50);
    m_win->SetSize(size);
    CPPUNIT_ASSERT_EQUAL( size, m_win->GetSize() );
}
 ~WDO_ENABLE_DISABLE()
 {
     if( m_win )
     {
         m_win->Enable();
         m_win->SetFocus(); // let's focus back on the parent window
     }
 }
Beispiel #6
0
    void Restore()
    {
        int x, y;

        m_w->GetSize( &x, &y );
        if( x != m_x || y != m_y )
            m_w->SetSize( -1, -1, m_x, m_y );
    }
Beispiel #7
0
void wxDynamicSashWindowLeaf::OnReparent(wxEvent &WXUNUSED(event))
{
    if (m_child)
    {
        m_child->Reparent(m_viewport);
    }

    ResizeChild(m_viewport->GetSize());
}
void WindowTestCase::Help()
{
    wxHelpProvider::Set(new wxSimpleHelpProvider());

    CPPUNIT_ASSERT_EQUAL("", m_window->GetHelpText());

    m_window->SetHelpText("helptext");

    CPPUNIT_ASSERT_EQUAL("helptext", m_window->GetHelpText());
}
Beispiel #9
0
void SetSizeTestCase::BestSize()
{
    CPPUNIT_ASSERT_EQUAL( wxSize(50, 250), m_win->GetBestSize() );

    m_win->SetMinSize(wxSize(100, 100));
    CPPUNIT_ASSERT_EQUAL( wxSize(100, 250), m_win->GetBestSize() );

    m_win->SetMaxSize(wxSize(200, 200));
    CPPUNIT_ASSERT_EQUAL( wxSize(100, 200), m_win->GetBestSize() );
}
Beispiel #10
0
void wxDynamicSashWindowLeaf::OnScroll(wxScrollEvent &WXUNUSED(event))
{
    int nx = -m_hscroll->GetThumbPosition();
    int ny = -m_vscroll->GetThumbPosition();

    if (m_child)
    {
        wxPoint pos = m_child->GetPosition();

        m_viewport->ScrollWindow(nx - pos.x, ny - pos.y);
    }
}
Beispiel #11
0
void MyFrame::OnSplitVertical(wxCommandEvent& WXUNUSED(event) )
{
    if ( m_splitter->IsSplit() )
        m_splitter->Unsplit();
    m_left->Show(true);
    m_right->Show(true);
    m_splitter->SplitVertically( m_left, m_right );
    m_replacewindow = NULL;

#if wxUSE_STATUSBAR
    SetStatusText(wxT("Splitter split vertically"), 1);
#endif // wxUSE_STATUSBAR
}
void WindowTestCase::Siblings()
{
    CPPUNIT_ASSERT_EQUAL(static_cast<wxWindow*>(NULL), m_window->GetNextSibling());
    CPPUNIT_ASSERT_EQUAL(static_cast<wxWindow*>(NULL), m_window->GetPrevSibling());

    wxWindow* newwin = new wxWindow(wxTheApp->GetTopWindow(), wxID_ANY);

    CPPUNIT_ASSERT_EQUAL(newwin, m_window->GetNextSibling());
    CPPUNIT_ASSERT_EQUAL(static_cast<wxWindow*>(NULL), m_window->GetPrevSibling());

    CPPUNIT_ASSERT_EQUAL(static_cast<wxWindow*>(NULL), newwin->GetNextSibling());
    CPPUNIT_ASSERT_EQUAL(m_window, newwin->GetPrevSibling());

    wxDELETE(newwin);
}
Beispiel #13
0
void MyFrame::OnReplace(wxCommandEvent& WXUNUSED(event) )
{
    if (m_replacewindow == NULL) {
        m_replacewindow = m_splitter->GetWindow2();
        m_splitter->ReplaceWindow(m_replacewindow, new wxPanel(m_splitter, wxID_ANY));
        m_replacewindow->Hide();
    } else {
        wxWindow *empty = m_splitter->GetWindow2();
        wxASSERT(empty != m_replacewindow);
        m_splitter->ReplaceWindow(empty, m_replacewindow);
        m_replacewindow->Show();
        m_replacewindow = NULL;
        empty->Destroy();
    }
}
Beispiel #14
0
void wxDynamicSashWindowImpl::OnSize(wxSizeEvent &event)
{
    m_container->Layout();

    if (m_leaf)
        m_leaf->OnSize(event);
}
Beispiel #15
0
void MvcController::ConditionallyEnableControl
    (std::string const& name
    ,wxWindow&          control
    )
{
    control.Enable(ModelReference<datum_base>(name).is_enabled());
}
void WindowTestCase::FindWindowBy()
{
    m_window->SetId(wxID_HIGHEST + 1);
    m_window->SetName("name");
    m_window->SetLabel("label");

    CPPUNIT_ASSERT_EQUAL(m_window, wxWindow::FindWindowById(wxID_HIGHEST + 1));
    CPPUNIT_ASSERT_EQUAL(m_window, wxWindow::FindWindowByName("name"));
    CPPUNIT_ASSERT_EQUAL(m_window, wxWindow::FindWindowByLabel("label"));

    CPPUNIT_ASSERT_EQUAL(static_cast<wxWindow*>(NULL),
                         wxWindow::FindWindowById(wxID_HIGHEST + 3));
    CPPUNIT_ASSERT_EQUAL(static_cast<wxWindow*>(NULL),
                         wxWindow::FindWindowByName("noname"));
    CPPUNIT_ASSERT_EQUAL(static_cast<wxWindow*>(NULL),
                         wxWindow::FindWindowByLabel("nolabel"));
}
	virtual ~ScopedOkButtonDisabler() throw()
	{
		if (m_apply)	m_apply	->Enable();
		if (m_ok)		m_ok	->Enable();
		if (m_cancel)	m_cancel->Enable();

		m_parent->AllowApplyActivation( true );
	}
Beispiel #18
0
void wxDynamicSashWindowLeaf::OnFocus(wxFocusEvent &event)
{
    if ( event.GetEventObject() == m_hscroll ||
            event.GetEventObject() == m_vscroll )
    {
        m_child->SetFocus();
    }
}
Beispiel #19
0
// Returns FALSE if the window position is considered invalid, which means that it's title
// bar is most likely not easily grabble.  Such a window should be moved to a valid or
// default position.
bool pxIsValidWindowPosition( const wxWindow& window, const wxPoint& windowPos )
{
	// The height of the window is only revlevant to the height of a title bar, which is
	// all we need visible for the user to be able to drag the window into view.  But
	// there's no way to get that info from wx, so we'll just have to guesstimate...

	wxSize sizeMatters( window.GetSize().GetWidth(), 32 );		// if some gui has 32 pixels of undraggable title bar, the user deserves to suffer.
	return wxGetDisplayArea().Contains( wxRect( windowPos, sizeMatters ) );
}
void WindowTestCase::ShowHideEvent()
{
#if defined(__WXMSW__)
    EventCounter show(m_window, wxEVT_SHOW);

    CPPUNIT_ASSERT(m_window->IsShown());

    m_window->Show(false);

    CPPUNIT_ASSERT(!m_window->IsShown());

    m_window->Show();

    CPPUNIT_ASSERT(m_window->IsShown());

    CPPUNIT_ASSERT_EQUAL(2, show.GetCount());
#endif // __WXMSW__
}
Beispiel #21
0
void wxDynamicSashWindowLeaf::ResizeChild(const wxSize& size)
{
    if (m_child)
    {
        if (m_impl->m_window->HasFlag(wxDS_MANAGE_SCROLLBARS))
        {
            wxSize best_size = m_child->GetBestSize();
            if (best_size.GetWidth() < size.GetWidth())
                best_size.SetWidth(size.GetWidth());
            if (best_size.GetHeight() < size.GetHeight())
                best_size.SetHeight(size.GetHeight());
            m_child->SetSize(best_size);

            int hpos = m_hscroll->GetThumbPosition();
            int vpos = m_vscroll->GetThumbPosition();

            if (hpos < 0)
                hpos = 0;
            if (vpos < 0)
                vpos = 0;
            if (hpos > best_size.GetWidth() - size.GetWidth())
                hpos = best_size.GetWidth() - size.GetWidth();
            if (vpos > best_size.GetHeight() - size.GetHeight())
                vpos = best_size.GetHeight() - size.GetHeight();

            m_hscroll->SetScrollbar(hpos, size.GetWidth(),
                                    best_size.GetWidth(), size.GetWidth());
            m_vscroll->SetScrollbar(vpos, size.GetHeight(),
                                    best_size.GetHeight(), size.GetHeight());

            //  Umm, the scrollbars are doing something insane under GTK+ and subtracting
            //  one from the position I pass in.  This works around that.
            m_hscroll->SetThumbPosition(hpos + hpos - m_hscroll->GetThumbPosition());
            m_vscroll->SetThumbPosition(vpos + vpos - m_vscroll->GetThumbPosition());

            wxPoint pos = m_child->GetPosition();
            m_viewport->ScrollWindow(-hpos - pos.x, -vpos - pos.y);
        }
        else // !wxDS_MANAGE_SCROLLBARS
        {
            m_child->SetSize(size);
        }
    }
}
Beispiel #22
0
//----------------------------------------
void CXYPlotPanel::EvtSize(wxWindow& window, const wxSizeEventFunction& method, wxObject* userData, wxEvtHandler* eventSink)
{
  window.Connect(wxEVT_SIZE,
                 (wxObjectEventFunction)
                 (wxEventFunction)
                 method,
                 userData,
                 eventSink);

}
Beispiel #23
0
//----------------------------------------
void CXYPlotPanel::EvtCheckBox(wxWindow& window, const wxCommandEventFunction& method, wxObject* userData, wxEvtHandler* eventSink)
{
  window.Connect(wxEVT_COMMAND_CHECKBOX_CLICKED,
                 (wxObjectEventFunction)
                 (wxEventFunction)
                 method,
                 userData,
                 eventSink);

}
Beispiel #24
0
void wxDynamicSashWindowLeaf::AddChild(wxWindow *window)
{
    if (m_child)
        m_child->Destroy();

    m_child = window;

    wxDynamicSashReparentEvent event(this);
    AddPendingEvent(event);
}
Beispiel #25
0
void SwitchView::OnFocus(wxFocusEvent& event) {
    wxScrollBar *hscroll = m_dyn_sash->GetHScrollBar(this);
    wxScrollBar *vscroll = m_dyn_sash->GetVScrollBar(this);

    if (event.GetEventObject() == hscroll || event.GetEventObject() == vscroll) {
        m_view->SetFocus();
    } else {
        event.Skip();
    }
}
Beispiel #26
0
static bool pxTrySetFocus( wxWindow& parent, wxWindowID id )
{
	if( wxWindow* found = parent.FindWindowById( id ) )
	{
		found->SetFocus();
		return true;
	}

	return false;
}
Beispiel #27
0
//----------------------------------------
void CXYPlotPanel::EvtRadioButton(wxWindow& window, const wxCommandEventFunction& method, wxObject* userData, wxEvtHandler* eventSink)
{
  window.Connect(wxEVT_COMMAND_RADIOBUTTON_SELECTED,
                 (wxObjectEventFunction)
                 (wxEventFunction)
                 method,
                 userData,
                 eventSink);

}
void WindowTestCase::FocusEvent()
{
#ifndef __WXOSX__
    EventCounter setfocus(m_window, wxEVT_SET_FOCUS);
    EventCounter killfocus(m_window, wxEVT_KILL_FOCUS);

    m_window->SetFocus();

    CPPUNIT_ASSERT_EQUAL(1, setfocus.GetCount());
    CPPUNIT_ASSERT(m_window->HasFocus());

    wxButton* button = new wxButton(wxTheApp->GetTopWindow(), wxID_ANY);

    wxYield();
    button->SetFocus();

    CPPUNIT_ASSERT_EQUAL(1, killfocus.GetCount());
    CPPUNIT_ASSERT(!m_window->HasFocus());
#endif
}
Beispiel #29
0
void wxDynamicSashWindowImpl::OnPaint(wxPaintEvent &event)
{
    if (m_leaf)
        m_leaf->OnPaint(event);
    else
    {
        wxPaintDC dc(m_container);
        dc.SetBackground(wxBrush(m_container->GetBackgroundColour(), wxSOLID));
        dc.Clear();
    }
}
Beispiel #30
0
//----------------------------------------
void CZFXYPlotFrame::EvtUpdateMinSize(wxWindow& window, int32_t winId, const CZFXYUpdateMinSizeEventFunction& method,
                                wxObject* userData, wxEvtHandler* eventSink)
{
  window.Connect(winId,
                 wxEVT_ZFXY_UPDATE_MINSIZE,
                 (wxObjectEventFunction)
                 (wxEventFunction)
                 method,
                 userData,
                 eventSink);
}