Exemple #1
0
void wxControlRenderer::DoDrawItems(const wxListBox *lbox,
                                    size_t itemFirst, size_t itemLast,
#if wxUSE_CHECKLISTBOX
                                    bool isCheckLbox
#else
                                    bool WXUNUSED(isCheckLbox)
#endif
                                    )
{
    // prepare for the drawing: calc the initial position
    wxCoord lineHeight = lbox->GetLineHeight();

    // note that SetClippingRegion() needs the physical (unscrolled)
    // coordinates while we use the logical (scrolled) ones for the drawing
    // itself
    wxRect rect;
    wxSize size = lbox->GetClientSize();
    rect.width = size.x;
    rect.height = size.y;

    // keep the text inside the client rect or we will overwrite the vertical
    // scrollbar for the long strings
    m_dc.SetClippingRegion(rect.x, rect.y, rect.width + 1, rect.height + 1);

    // adjust the rect position now
    lbox->CalcScrolledPosition(rect.x, rect.y, &rect.x, &rect.y);
    rect.y += itemFirst*lineHeight;
    rect.height = lineHeight;

    // the rect should go to the right visible border so adjust the width if x
    // is shifted (rightmost point should stay the same)
    rect.width -= rect.x;

    // we'll keep the text colour unchanged
    m_dc.SetTextForeground(lbox->GetForegroundColour());

    // an item should have the focused rect only when the lbox has focus, so
    // make sure that we never set wxCONTROL_FOCUSED flag if it doesn't
    int itemCurrent = wxWindow::FindFocus() == (wxWindow *)lbox // cast needed
                        ? lbox->GetCurrentItem()
                        : -1;
    for ( size_t n = itemFirst; n < itemLast; n++ )
    {
        int flags = 0;
        if ( (int)n == itemCurrent )
            flags |= wxCONTROL_FOCUSED;
        if ( lbox->IsSelected(n) )
            flags |= wxCONTROL_SELECTED;

#if wxUSE_CHECKLISTBOX
        if ( isCheckLbox )
        {
            wxCheckListBox *checklstbox = wxStaticCast(lbox, wxCheckListBox);
            if ( checklstbox->IsChecked(n) )
                flags |= wxCONTROL_CHECKED;

            m_renderer->DrawCheckItem(m_dc, lbox->GetString(n),
                                      wxNullBitmap,
                                      rect,
                                      flags);
        }
        else
#endif // wxUSE_CHECKLISTBOX
        {
            m_renderer->DrawItem(m_dc, lbox->GetString(n), rect, flags);
        }

        rect.y += lineHeight;
    }
}
Exemple #2
0
void wxGISApplication::OnAppOptions(void)
{
    //read the config node for property pages and its names
	wxGISAppConfig oConfig = GetConfig();
	if(!oConfig.IsOk())
    {
        wxMessageBox(_("Get config failed!"), _("Error"), wxICON_ERROR | wxOK );
        return;
    }

    wxXmlNode *pPPXmlNode = oConfig.GetConfigNode(enumGISHKCU, GetAppName() + wxString(wxT("/propertypages")));
    if(!pPPXmlNode)
    {
        wxMessageBox(_("No Property Pages"), _("Error"), wxICON_ERROR | wxOK );
        return;
    }
    //load pages to the dialog and show
    wxPropertySheetDialog PropertySheetDialog;
    //(this, wxID_ANY, _("Options"), wxDefaultPosition, wxSize( 480,600 ), wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER);
    if (!PropertySheetDialog.Create(this, wxID_ANY, _("Options"), wxDefaultPosition, wxSize( 480,600 ), wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER))
        return;
    //PropertySheetDialog.SetMinSize( wxSize( 480,600 ));
    //PropertySheetDialog.SetSizeHints( wxSize( 480,600 ), wxDefaultSize );
    //PropertySheetDialog. SetClientSize( wxSize( 480,600 ));

    PropertySheetDialog.SetIcon(options_xpm);

    PropertySheetDialog.CreateButtons(wxOK|wxCANCEL);

    wxWindow* pParentWnd = static_cast<wxWindow*>(PropertySheetDialog.GetBookCtrl());
    // Add page
    wxXmlNode *pPropPageNode = pPPXmlNode->GetChildren();
    while(pPropPageNode)
    {
 		wxString sClass = pPropPageNode->GetAttribute(wxT("class"), ERR);
	    wxObject *obj = wxCreateDynamicObject(sClass);
		IPropertyPage *pPage = wxStaticCast(obj, IPropertyPage);//static_cast<IPropertyPage*>(obj);
		if(pPage != NULL)
		{
            if(pPage->Create(this, PropertySheetDialog.GetBookCtrl(), wxID_ANY))
            {
                wxPanel* panel = static_cast<wxPanel*>(pPage);
                if(panel)
                    PropertySheetDialog.GetBookCtrl()->AddPage(panel, pPage->GetPageName());
            }
        }
        pPropPageNode = pPropPageNode->GetNext();
    }

    //PropertySheetDialog.LayoutDialog();

    if(PropertySheetDialog.ShowModal() == wxID_OK)
    {
        //apply changes and exit
        for(size_t i = 0; i < PropertySheetDialog.GetBookCtrl()->GetPageCount(); ++i)
        {
            IPropertyPage *pPage = dynamic_cast<IPropertyPage*>(PropertySheetDialog.GetBookCtrl()->GetPage(i));// wxDynamicCast(PropertySheetDialog.GetBookCtrl()->GetPage(i), IPropertyPage);//
            if(pPage)
                pPage->Apply();
        }
    }
}
Exemple #3
0
void wxWindowDFB::HandleKeyEvent(const wxDFBWindowEvent& event_)
{
    if ( !IsEnabled() )
        return;

    const DFBWindowEvent& e = event_;

    wxLogTrace(TRACE_EVENTS,
               "handling key %s event for window %p ('%s')",
               e.type == DWET_KEYUP ? "up" : "down",
               this, GetName().c_str());

    // fill in wxKeyEvent fields:
    wxKeyEvent event;
    event.SetEventObject(this);
    event.SetTimestamp(wxDFB_EVENT_TIMESTAMP(e));
    event.m_rawCode = e.key_code;
    event.m_keyCode = GetTranslatedKeyCode(e.key_id);
#if wxUSE_UNICODE
    event.m_uniChar = e.key_symbol;
#endif
    event.m_shiftDown = ( e.modifiers & DIMM_SHIFT ) != 0;
    event.m_controlDown = ( e.modifiers & DIMM_CONTROL ) != 0;
    event.m_altDown = ( e.modifiers & DIMM_ALT ) != 0;
    event.m_metaDown = ( e.modifiers & DIMM_META ) != 0;

    // translate coordinates from TLW-relative to this window-relative:
    event.m_x = e.x;
    event.m_y = e.y;
    GetTLW()->ClientToScreen(&event.m_x, &event.m_y);
    this->ScreenToClient(&event.m_x, &event.m_y);

    if ( e.type == DWET_KEYUP )
    {
        event.SetEventType(wxEVT_KEY_UP);
        HandleWindowEvent(event);
    }
    else
    {
        bool isTab = (event.m_keyCode == WXK_TAB);

        event.SetEventType(wxEVT_KEY_DOWN);

        if ( HandleWindowEvent(event) )
            return;

        // only send wxEVT_CHAR event if not processed yet:
        event.m_keyCode = GetUntraslatedKeyCode(e.key_id, e.key_symbol);
        if ( event.m_keyCode != 0 )
        {
            event.SetEventType(wxEVT_CHAR);
            if ( HandleWindowEvent(event) )
                return;
        }

        // Synthetize navigation key event, but do it only if the TAB key
        // wasn't handled yet:
        if ( isTab && GetParent() && GetParent()->HasFlag(wxTAB_TRAVERSAL) )
        {
            wxNavigationKeyEvent navEvent;
            navEvent.SetEventObject(GetParent());
            // Shift-TAB goes in reverse direction:
            navEvent.SetDirection(!event.m_shiftDown);
            // Ctrl-TAB changes the (parent) window, i.e. switch notebook page:
            navEvent.SetWindowChange(event.m_controlDown);
            navEvent.SetCurrentFocus(wxStaticCast(this, wxWindow));
            GetParent()->HandleWindowEvent(navEvent);
        }
    }
}
Exemple #4
0
wxGxObject* wxGxWebConnectionFactory::GetGxObject(wxGxObject* pParent, const wxString &soName, const CPLString &szPath)
{
	wxGxTMSWebService* pDataset = new wxGxTMSWebService(pParent, soName, szPath);
	return wxStaticCast(pDataset, wxGxObject);
}
Exemple #5
0
wxTextCtrl* TextEditDocument::GetTextCtrl() const
{
    wxView* view = GetFirstView();
    return view ? wxStaticCast(view, TextEditView)->GetText() : NULL;
}
Exemple #6
0
wxObject *wxMenuXmlHandler::DoCreateResource()
{
    if (m_class == wxT("wxMenu"))
    {
        wxMenu *menu = m_instance ? wxStaticCast(m_instance, wxMenu)
                                  : new wxMenu(GetStyle());

        wxString title = GetText(wxT("label"));
        wxString help = GetText(wxT("help"));

        bool oldins = m_insideMenu;
        m_insideMenu = true;
        CreateChildren(menu, true/*only this handler*/);
        m_insideMenu = oldins;

        wxMenuBar *p_bar = wxDynamicCast(m_parent, wxMenuBar);
        if (p_bar)
        {
            p_bar->Append(menu, title);
        }
        else
        {
            wxMenu *p_menu = wxDynamicCast(m_parent, wxMenu);
            if (p_menu)
            {
                p_menu->Append(GetID(), title, menu, help);
                if (HasParam(wxT("enabled")))
                    p_menu->Enable(GetID(), GetBool(wxT("enabled")));
            }
        }

        return menu;
    }

    else
    {
        wxMenu *p_menu = wxDynamicCast(m_parent, wxMenu);

        if (m_class == wxT("separator"))
            p_menu->AppendSeparator();
        else if (m_class == wxT("break"))
            p_menu->Break();
        else /*wxMenuItem*/
        {
            int id = GetID();
            wxString label = GetText(wxT("label"));
            wxString accel = GetText(wxT("accel"), false);
            wxString fullLabel = label;
            if (!accel.empty())
                fullLabel << wxT("\t") << accel;

            wxItemKind kind = wxITEM_NORMAL;
            if (GetBool(wxT("radio")))
                kind = wxITEM_RADIO;
            if (GetBool(wxT("checkable")))
            {
                if ( kind != wxITEM_NORMAL )
                {
                    ReportParamError
                    (
                        "checkable",
                        "menu item can't have both <radio> and <checkable> properties"
                    );
                }

                kind = wxITEM_CHECK;
            }

            wxMenuItem *mitem = new wxMenuItem(p_menu, id, fullLabel,
                                               GetText(wxT("help")), kind);

#if (!defined(__WXMSW__) && !defined(__WXPM__)) || wxUSE_OWNER_DRAWN
            if (HasParam(wxT("bitmap")))
            {
                // currently only wxMSW has support for using different checked
                // and unchecked bitmaps for menu items
#ifdef __WXMSW__
                if (HasParam(wxT("bitmap2")))
                    mitem->SetBitmaps(GetBitmap(wxT("bitmap2"), wxART_MENU),
                                      GetBitmap(wxT("bitmap"), wxART_MENU));
                else
#endif // __WXMSW__
                    mitem->SetBitmap(GetBitmap(wxT("bitmap"), wxART_MENU));
            }
#endif
            p_menu->Append(mitem);
            mitem->Enable(GetBool(wxT("enabled"), true));
            if (kind == wxITEM_CHECK)
                mitem->Check(GetBool(wxT("checked")));
        }
        return NULL;
    }
}
Exemple #7
0
void ListBaseTestCase::ItemClick()
{
    // FIXME: This test fail under wxGTK because we get 3 FOCUSED events and
    //        2 SELECTED ones instead of the one of each we expect for some
    //        reason, this needs to be debugged as it may indicate a bug in the
    //        generic wxListCtrl implementation.
#if wxUSE_UIACTIONSIMULATOR && !defined(__WXGTK__)

    // FIXME: This test fails on MSW buildbot slaves although works fine on
    //        development machine, no idea why. It seems to be a problem with
    //        wxUIActionSimulator rather the wxListCtrl control itself however.
    if ( wxGetUserId().Lower().Matches("buildslave*") )
        return;

    wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(),
                                          wxTestableFrame);

    wxListCtrl* const list = GetList();

    list->InsertColumn(0, "Column 0", wxLIST_FORMAT_LEFT, 60);
    list->InsertColumn(1, "Column 1", wxLIST_FORMAT_LEFT, 50);
    list->InsertColumn(2, "Column 2", wxLIST_FORMAT_LEFT, 40);

    list->InsertItem(0, "Item 0");
    list->SetItem(0, 1, "first column");
    list->SetItem(0, 2, "second column");

    EventCounter count(list, wxEVT_COMMAND_LIST_ITEM_SELECTED);
    EventCounter count1(list, wxEVT_COMMAND_LIST_ITEM_FOCUSED);
    EventCounter count2(list, wxEVT_COMMAND_LIST_ITEM_ACTIVATED);
    EventCounter count3(list, wxEVT_COMMAND_LIST_ITEM_RIGHT_CLICK);

    wxUIActionSimulator sim;

    wxRect pos;
    list->GetItemRect(0, pos);

    //We move in slightly so we are not on the edge
    wxPoint point = list->ClientToScreen(pos.GetPosition()) + wxPoint(2, 2);

    sim.MouseMove(point);
    wxYield();

    sim.MouseClick();
    wxYield();

    sim.MouseDblClick();
    wxYield();

    sim.MouseClick(wxMOUSE_BTN_RIGHT);
    wxYield();

    // when the first item was selected the focus changes to it, but not
    // on subsequent clicks
    CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(wxEVT_COMMAND_LIST_ITEM_FOCUSED));
    CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(wxEVT_COMMAND_LIST_ITEM_SELECTED));
    CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(wxEVT_COMMAND_LIST_ITEM_ACTIVATED));
    CPPUNIT_ASSERT_EQUAL(1, frame->GetEventCount(wxEVT_COMMAND_LIST_ITEM_RIGHT_CLICK));

    //tidy up when we are finished
    list->ClearAll();
#endif // wxUSE_UIACTIONSIMULATOR
}
Exemple #8
0
wxObject* wxRibbonXmlHandler::Handle_button()
{
    wxRibbonButtonBar *buttonBar = wxStaticCast(m_parent, wxRibbonButtonBar);

    wxRibbonButtonKind  kind = wxRIBBON_BUTTON_NORMAL;

    if (GetBool(wxT("hybrid")))
        kind = wxRIBBON_BUTTON_HYBRID;

    // FIXME: The code below uses wxXmlNode directly but this can't be done
    //        in the ribbon library code as it would force it to always link
    //        with the xml library. Disable it for now but the real solution
    //        would be to virtualize GetChildren() and GetNext() methods via
    //        wxXmlResourceHandler, just as we already do for many others.
    //
    // FIXME: If re-enabling, don't forget to update the docs and RELAG NG schema!
#if 0 // wxUSE_MENUS
    // check whether we have dropdown tag inside
    wxMenu *menu = NULL; // menu for drop down items
    wxXmlNode * const nodeDropdown = GetParamNode("dropdown");
    if ( nodeDropdown )
    {
        if (kind == wxRIBBON_BUTTON_NORMAL)
            kind = wxRIBBON_BUTTON_DROPDOWN;

        // also check for the menu specified inside dropdown (it is
        // optional and may be absent for e.g. dynamically-created
        // menus)
        wxXmlNode * const nodeMenu = nodeDropdown->GetChildren();
        if ( nodeMenu )
        {
            wxObject *res = CreateResFromNode(nodeMenu, NULL);
            menu = wxDynamicCast(res, wxMenu);
            if ( !menu )
            {
                ReportError
                (
                    nodeMenu,
                    "drop-down tool contents can only be a wxMenu"
                );
            }

            if ( nodeMenu->GetNext() )
            {
                ReportError
                (
                    nodeMenu->GetNext(),
                    "unexpected extra contents under drop-down tool"
                );
            }
        }
    }
#endif // wxUSE_MENUS

    if (!buttonBar->AddButton(GetID(),
                              GetText("label"),
                              GetBitmap ("bitmap"),
                              GetBitmap ("small-bitmap"),
                              GetBitmap ("disabled-bitmap"),
                              GetBitmap ("small-disabled-bitmap"),
                              kind,
                              GetText("help")))
    {
        ReportError ("could not create button");
    }

    if ( GetBool(wxT("disabled")) )
            buttonBar->EnableButton(GetID(), false);

    return NULL; // nothing to return
}
Exemple #9
0
void wxRibbonPanel::HideIfExpanded()
{
    wxStaticCast(m_parent, wxRibbonPage)->HideIfExpanded();
}
SimulationWindow::SimulationWindow(wxWindow *parent) :
	m_threadCondition(m_threadMutex),
	m_controlInterface(this),
	m_started(false),
	m_simulationTimer(this, 1),
	m_drawTimer(this, 2)
{
	srand(time(nullptr));

	// initialize XRC elements..
	wxXmlResource::Get()->LoadFrame(this, parent, wxT("SimulationWindow"));

	wxPanel * p = XRCCTRL(*this, "m_topPanel", wxPanel);

	XRC_INIT(m_joy1_enable, wxCheckBox);

	INIT_JOY(1_x)
	INIT_JOY(1_y)
	INIT_JOY(1_z)
	INIT_JOY(1_t)
	
	m_joy1_x->SetReadOnly(true);
	m_joy1_y->SetReadOnly(true);
	m_joy1_z->SetReadOnly(true);
	m_joy1_t->SetReadOnly(true);

	XRC_INIT(m_joy1_1, wxCheckBox);
	XRC_INIT(m_joy1_2, wxCheckBox);
	XRC_INIT(m_joy1_3, wxCheckBox);
	XRC_INIT(m_joy1_4, wxCheckBox);

	INIT_JOY(2_x)
	INIT_JOY(2_y)
	INIT_JOY(2_z)
	INIT_JOY(2_t)

	XRC_INIT(m_joy2_1, wxCheckBox);
	XRC_INIT(m_joy2_2, wxCheckBox);
	XRC_INIT(m_joy2_3, wxCheckBox);
	XRC_INIT(m_joy2_4, wxCheckBox);

	XRC_INIT(m_ds_i_1, wxCheckBox);
	XRC_INIT(m_ds_i_2, wxCheckBox);
	XRC_INIT(m_ds_i_3, wxCheckBox);
	XRC_INIT(m_ds_i_4, wxCheckBox);
	XRC_INIT(m_ds_i_5, wxCheckBox);
	XRC_INIT(m_ds_i_6, wxCheckBox);
	XRC_INIT(m_ds_i_7, wxCheckBox);
	XRC_INIT(m_ds_i_8, wxCheckBox);

	INIT_DS_ANALOG(1)
	INIT_DS_ANALOG(2)
	INIT_DS_ANALOG(3)
	INIT_DS_ANALOG(4)

	XRC_INIT(m_stepText, wxTextCtrl);
	
	XRC_INIT(m_startButton, wxButton);
	XRC_INIT(m_statusBar, wxStatusBar);
	
	XRC_INIT(m_enabledBox, wxCheckBox);
	XRC_INIT(m_autonomousBox, wxCheckBox);

	XRC_INIT(m_lcdTop, wxTextCtrl);
	XRC_INIT(m_lcdBottom, wxTextCtrl);
	
	// setup validation
	m_stepText->SetValidator(wxTextValidator(wxFILTER_NUMERIC));
	
	// statusbar
	m_statusBar->SetFieldsCount(2);
	m_statusBar->SetStatusText(wxT("Stopped"), 0);
	m_statusBar->SetStatusText(wxT("0.0s"), 1);

	// initialize analog inputs
	wxXmlResource * xmlRes = wxXmlResource::Get();

	// slot 1
	for (int i = 0; i < ANALOG_IO_CHANNELS; i++)
	{
		m_slot1Analog[i] = new Slider(p, wxID_ANY, 0, 5, false);
		xmlRes->AttachUnknownControl(
			wxString::Format(wxT("m_analog_1_%d"), i+1), 
			m_slot1Analog[i], p);
	}

	// slot 2
	for (int i = 0; i < ANALOG_IO_CHANNELS; i++)
	{
		m_slot2Analog[i] = new Slider(p, wxID_ANY, 0, 5, false);
		xmlRes->AttachUnknownControl(
			wxString::Format(wxT("m_analog_2_%d"), i+1), 
			m_slot2Analog[i], p);
	}


	// initialize pwm outputs

	// slot 4
	for (int i = 0; i < DIGITAL_PWM_CHANNELS; i++)
	{
		m_slot1PWM[i] = new Slider(p, wxID_ANY, -1, 1, true);
		xmlRes->AttachUnknownControl(
			wxString::Format(wxT("m_pwm_1_%d"), i+1), 
			m_slot1PWM[i], p);
	}

	// slot 6
	// HAHAHAHAHAHAHAHAHAAHAHAHAAHAH
	// I'd been trying to fix this assert error for HOURS
	// and then I realized: size_t = long on Linux
	for (int i = 0; i < DIGITAL_PWM_CHANNELS; i++)
	{
		m_slot2PWM[i] = new Slider(p, wxID_ANY, -1, 1, true);
		xmlRes->AttachUnknownControl(
			wxString::Format(wxT("m_pwm_2_%d"), i+1), 
			m_slot2PWM[i], p);
	}
	
	// slot 8 (solenoids)
	for (int i = 0; i < SOLENOID_IO_CHANNELS; i++)
	{
		m_solenoids[i] = new TogglePanelButton(p, wxID_ANY);
		m_solenoids[i]->SetReadOnly(true);
		xmlRes->AttachUnknownControl(
			wxString::Format(wxT("m_sol_%d"), i+1), 
			m_solenoids[i], p);
	}
	

	// initialize digital channels

	// slot 4
	for (int i = 0; i < DIGITAL_IO_CHANNELS; i++)
	{
		m_slot1DIO[i] = new TogglePanelButton(p, wxID_ANY);
		xmlRes->AttachUnknownControl(
			wxString::Format(wxT("m_dio_1_%d"), i+1), 
			m_slot1DIO[i], p);

		m_slot1DIO_lbl[i] = wxStaticCast(FindWindow(xmlRes->GetXRCID(wxString::Format(wxT("m_diol_1_%d"), i+1))), 
			wxStaticText);
	}

	// slot 6
	for (int i = 0; i < DIGITAL_IO_CHANNELS; i++)
	{
		m_slot2DIO[i] = new TogglePanelButton(p, wxID_ANY);
		xmlRes->AttachUnknownControl(
			wxString::Format(wxT("m_dio_2_%d"), i+1), 
			m_slot2DIO[i], p);

		m_slot2DIO_lbl[i] = wxStaticCast(FindWindow(xmlRes->GetXRCID(wxString::Format(wxT("m_diol_2_%d"), i+1))), 
			wxStaticText);
	}


	p->Fit();
	p->Layout();

	Layout();

	// initialize the simulation thread
	BeginSimulation();
	
	// anything else that needs to be done

	m_joystick1.SetCapture(this);

	// try to update regularly
	m_drawTimer.Start(150);
}
bool wxGISDrawingLayer::AddShape(const wxGISGeometry &Geom, wxGISEnumShapeType eType)
{
    if (!Geom.IsOk())
        return false;

    wxGISSymbol* pSymbol = NULL;
    wxString sShapeName;
    switch (eType)
    {
    case enumGISShapeTypeRectangle:
        sShapeName = wxString::Format(_("Rectangle %ld"), m_aoShapes.size() + 1);
        pSymbol = wxStaticCast(m_pFillSymbol->Clone(), wxGISSymbol);
        break;
    case enumGISShapeTypePolygon:
        sShapeName = wxString::Format(_("Polygon %ld"), m_aoShapes.size() + 1);
        pSymbol = wxStaticCast(m_pFillSymbol->Clone(), wxGISSymbol);
        break;
    case enumGISShapeTypeCircle:
        sShapeName = wxString::Format(_("Circle %ld"), m_aoShapes.size() + 1);
        pSymbol = wxStaticCast(m_pCircleSymbol->Clone(), wxGISSymbol);
        break;
    case enumGISShapeTypeEllipse:
        sShapeName = wxString::Format(_("Ellipse %ld"), m_aoShapes.size() + 1);
        pSymbol = wxStaticCast(m_pEllipseSymbol->Clone(), wxGISSymbol);
        break;
    case enumGISShapeTypeLine:
        sShapeName = wxString::Format(_("Line %ld"), m_aoShapes.size() + 1);
        pSymbol = wxStaticCast(m_pLineSymbol->Clone(), wxGISSymbol);
        break;
#ifdef wxGIS_USE_SPLINE
    case enumGISShapeTypeCurve:
        sShapeName = wxString::Format(_("Curve %ld"), m_aoShapes.size() + 1);
        pSymbol = wxStaticCast(m_pLineSymbol->Clone(), wxGISSymbol);
        break;
#endif //wxGIS_USE_SPLINE
    case enumGISShapeTypeFreeHand:
        sShapeName = wxString::Format(_("FreeHand %ld"), m_aoShapes.size() + 1);
        pSymbol = wxStaticCast(m_pLineSymbol->Clone(), wxGISSymbol);
        break;
    case enumGISShapeTypeMarker:
        sShapeName = wxString::Format(_("Marker %ld"), m_aoShapes.size() + 1);
        pSymbol = wxStaticCast(m_pMarkerSymbol->Clone(), wxGISSymbol);
        break;
    default:
        sShapeName = wxString::Format(_("Shape %ld"), m_aoShapes.size() + 1);
        pSymbol = wxStaticCast(m_pFillSymbol->Clone(), wxGISSymbol);
        break;
    };

    wxGISShape * pNewShape = new wxGISShape(sShapeName, Geom, eType, pSymbol);
    m_aoShapes.push_back(pNewShape);

    if (m_oLayerExtent.IsInit())
    {
        m_oLayerExtent.Merge(pNewShape->GetBounds());
    }
    else
    {
        m_oLayerExtent = pNewShape->GetBounds();
    }


    pNewShape->Draw(m_pDisplay);

    wxMxMapViewEvent wxMxMapViewEvent_(wxMXMAP_LAYER_CHANGED, GetId());
    AddEvent(wxMxMapViewEvent_);

    return true;
}
wxThread::ExitCode wxGxMLDatasetUI::Entry()
{
    //ITrackCancel trackcancel;
    wxGISDataset* pDSet = GetDataset(false);
    wxGxCatalogUI* pCat = wxDynamicCast(GetGxCatalog(), wxGxCatalogUI);
    if(pDSet)
    {
        for(size_t i = 0; i < pDSet->GetSubsetsCount(); ++i)
        {
            wxGISDataset* pwxGISFeatureSuDataset = m_pwxGISDataset->GetSubset(i);
            wxString sSubsetName = pwxGISFeatureSuDataset->GetName();
            wxGxMLSubDatasetUI* pGxMLSubDatasetUI = new wxGxMLSubDatasetUI((wxGISEnumVectorDatasetType)GetSubType(), pwxGISFeatureSuDataset, wxStaticCast(this, wxGxObject), sSubsetName, wxGxObjectContainer::GetPath(), m_LargeSubIcon, m_SmallSubIcon);
            wxGIS_GXCATALOG_EVENT_ID(ObjectAdded, pGxMLSubDatasetUI->GetId());
        }

        wsDELETE(pDSet);
    }
    if(m_nPendUId != wxNOT_FOUND && pCat)
    {
        pCat->RemovePending(m_nPendUId);
        m_nPendUId = wxNOT_FOUND;
    }


    //wxGIS_GXCATALOG_EVENT(ObjectChanged);

    return (wxThread::ExitCode)wxTHREAD_NO_ERROR;
}
Exemple #13
0
wxGxObject* wxGxArchiveFolderUI::GetArchiveFolder(wxGxObject *oParent, const wxString &soName, const CPLString &soPath)
{
	wxGxArchiveFolderUI* pFolder = new wxGxArchiveFolderUI(oParent, soName, soPath, m_oLargeIcon, m_oSmallIcon);
	return wxStaticCast(pFolder, wxGxObject);
}
Exemple #14
0
wxFrame *MyApp::CreateChildFrame(wxView *view, bool isCanvas)
{
    // create a child frame of appropriate class for the current mode
    wxFrame *subframe;
    wxDocument *doc = view->GetDocument();
#if wxUSE_MDI_ARCHITECTURE
    if ( GetMode() == Mode_MDI )
    {
        subframe = new wxDocMDIChildFrame
                       (
                            doc,
                            view,
                            wxStaticCast(GetTopWindow(), wxDocMDIParentFrame),
                            wxID_ANY,
                            "Child Frame",
                            wxDefaultPosition,
                            wxSize(300, 300)
                       );
    }
    else
#endif // wxUSE_MDI_ARCHITECTURE
    {
        subframe = new wxDocChildFrame
                       (
                            doc,
                            view,
                            wxStaticCast(GetTopWindow(), wxDocParentFrame),
                            wxID_ANY,
                            "Child Frame",
                            wxDefaultPosition,
                            wxSize(300, 300)
                       );

        subframe->Centre();
    }

    wxMenu *menuFile = new wxMenu;

    menuFile->Append(wxID_NEW);
    menuFile->Append(wxID_OPEN);
    AppendDocumentFileCommands(menuFile, isCanvas);
    menuFile->AppendSeparator();
    menuFile->Append(wxID_EXIT);

    wxMenu *menuEdit;
    if ( isCanvas )
    {
        menuEdit = CreateDrawingEditMenu();

        doc->GetCommandProcessor()->SetEditMenu(menuEdit);
        doc->GetCommandProcessor()->Initialize();
    }
    else // text frame
    {
        menuEdit = new wxMenu;
        menuEdit->Append(wxID_COPY);
        menuEdit->Append(wxID_PASTE);
        menuEdit->Append(wxID_SELECTALL);
    }

    CreateMenuBarForFrame(subframe, menuFile, menuEdit);

    subframe->SetIcon(isCanvas ? wxICON(chrt) : wxICON(notepad));

    return subframe;
}
Exemple #15
0
static ibool MGLAPI wxWindowKeybHandler(window_t *wnd, event_t *e)
{
    wxWindowMGL *win = (wxWindowMGL*)MGL_wmGetWindowUserData(wnd);

    if ( !win->IsEnabled() ) return FALSE;

    wxPoint where;
    MGL_wmCoordGlobalToLocal(win->GetHandle(),
                             e->where_x, e->where_y, &where.x, &where.y);

    wxKeyEvent event;
    event.SetEventObject(win);
    event.SetTimestamp(e->when);
    event.m_keyCode = wxScanToKeyCode(e, true);
    event.m_x = where.x;
    event.m_y = where.y;
    event.m_shiftDown = ( e->modifiers & EVT_SHIFTKEY ) != 0;
    event.m_controlDown = ( e->modifiers & EVT_CTRLSTATE ) != 0;
    event.m_altDown = ( e->modifiers & EVT_LEFTALT ) != 0;
    event.m_metaDown = ( e->modifiers & EVT_RIGHTALT ) != 0;

    if ( e->what == EVT_KEYUP )
    {
        event.SetEventType(wxEVT_KEY_UP);
        return win->HandleWindowEvent(event);
    }
    else
    {
        bool ret;
        wxKeyEvent event2;

        event.SetEventType(wxEVT_KEY_DOWN);
        event2 = event;

        ret = win->HandleWindowEvent(event);

        // wxMSW doesn't send char events with Alt pressed
        // Only send wxEVT_CHAR event if not processed yet. Thus, ALT-x
        // will only be sent if it is not in an accelerator table:
        event2.m_keyCode = wxScanToKeyCode(e, false);
        if ( !ret && event2.m_keyCode != 0 )
        {
            event2.SetEventType(wxEVT_CHAR);
            ret = win->HandleWindowEvent(event2);
        }

        // Synthetize navigation key event, but do it only if the TAB key
        // wasn't handled yet:
        if ( !ret && event.m_keyCode == WXK_TAB &&
             win->GetParent() && win->GetParent()->HasFlag(wxTAB_TRAVERSAL) )
        {
            wxNavigationKeyEvent navEvent;
            navEvent.SetEventObject(win->GetParent());
            // Shift-TAB goes in reverse direction:
            navEvent.SetDirection(!event.m_shiftDown);
            // Ctrl-TAB changes the (parent) window, i.e. switch notebook page:
            navEvent.SetWindowChange(event.m_controlDown);
            navEvent.SetCurrentFocus(wxStaticCast(win, wxWindow));
            ret = win->HandleWindowEvent(navEvent);
        }

        // Finally, process special meaning keys that are usually
        // a responsibility of OS or window manager:
        if ( !ret )
            ret = wxHandleSpecialKeys(event);

        return ret;
    }
}
Exemple #16
0
bool wxStdScrollBarInputHandler::HandleMouse(wxInputConsumer *consumer,
                                             const wxMouseEvent& event)
{
    // is this a click event from an acceptable button?
    int btn = event.GetButton();
    if ( btn == wxMOUSE_BTN_LEFT )
    {
        // determine which part of the window mouse is in
        wxScrollBar *scrollbar = wxStaticCast(consumer->GetInputWindow(), wxScrollBar);
        wxHitTest ht = scrollbar->HitTestBar(event.GetPosition());

        // when the mouse is pressed on any scrollbar element, we capture it
        // and hold capture until the same mouse button is released
        if ( event.ButtonDown() || event.ButtonDClick() )
        {
            if ( !m_winCapture )
            {
                m_btnCapture = btn;
                m_winCapture = consumer->GetInputWindow();
                m_winCapture->CaptureMouse();

                // generate the command
                bool hasAction = true;
                wxControlAction action;
                switch ( ht )
                {
                    case wxHT_SCROLLBAR_ARROW_LINE_1:
                        action = wxACTION_SCROLL_LINE_UP;
                        break;

                    case wxHT_SCROLLBAR_ARROW_LINE_2:
                        action = wxACTION_SCROLL_LINE_DOWN;
                        break;

                    case wxHT_SCROLLBAR_BAR_1:
                        action = wxACTION_SCROLL_PAGE_UP;
                        m_ptStartScrolling = event.GetPosition();
                        break;

                    case wxHT_SCROLLBAR_BAR_2:
                        action = wxACTION_SCROLL_PAGE_DOWN;
                        m_ptStartScrolling = event.GetPosition();
                        break;

                    case wxHT_SCROLLBAR_THUMB:
                        consumer->PerformAction(wxACTION_SCROLL_THUMB_DRAG);
                        m_ofsMouse = GetMouseCoord(scrollbar, event) -
                                     scrollbar->ScrollbarToPixel();

                        // fall through: there is no immediate action

                    default:
                        hasAction = false;
                }

                // remove highlighting
                Highlight(scrollbar, false);
                m_htLast = ht;

                // and press the arrow or highlight thumb now instead
                if ( m_htLast == wxHT_SCROLLBAR_THUMB )
                    Highlight(scrollbar, true);
                else
                    Press(scrollbar, true);

                // start dragging
                if ( hasAction )
                {
                    m_timerScroll = new wxScrollBarTimer(this, action,
                                                         scrollbar);
                    m_timerScroll->StartAutoScroll();
                }
                //else: no (immediate) action

            }
            //else: mouse already captured, nothing to do
        }
        // release mouse if the *same* button went up
        else if ( btn == m_btnCapture )
        {
            if ( m_winCapture )
            {
                StopScrolling(scrollbar);

                // if we were dragging the thumb, send the last event
                if ( m_htLast == wxHT_SCROLLBAR_THUMB )
                {
                    scrollbar->PerformAction(wxACTION_SCROLL_THUMB_RELEASE);
                }

                m_htLast = ht;
                Highlight(scrollbar, true);
            }
            else
            {
                // this is not supposed to happen as the button can't go up
                // without going down previously and then we'd have
                // m_winCapture by now
                wxFAIL_MSG( wxT("logic error in mouse capturing code") );
            }
        }
    }

    return wxStdInputHandler::HandleMouse(consumer, event);
}
// Centre a list of strings in the given box. xOffset and yOffset are the
// the positions that these lines should be relative to, and this might be
// the same as m_xpos, m_ypos, but might be zero if formatting from left-justifying.
void oglCentreText(wxDC& dc, wxList *text_list,
                double m_xpos, double m_ypos, double width, double height,
                int formatMode)
{
  int n = text_list->GetCount();

  if (!text_list || (n == 0))
    return;

  // First, get maximum dimensions of box enclosing text

  wxCoord char_height = 0;
  wxCoord max_width = 0;
  wxCoord current_width = 0;

  // Store text extents for speed
  double *widths = new double[n];

  int i = 0;
  wxObjectList::compatibility_iterator current;
  for (current = text_list->GetFirst();
       current;
       current = current->GetNext(), i++)
  {
    wxShapeTextLine* line = wxStaticCast(current->GetData(), wxShapeTextLine);
    dc.GetTextExtent(line->GetText(), &current_width, &char_height);
    widths[i] = current_width;

    if (current_width > max_width)
      max_width = current_width;
  }

  double max_height = n*char_height;

  double xoffset, yoffset, xOffset, yOffset;

  if (formatMode & FORMAT_CENTRE_VERT)
  {
    if (max_height < height)
      yoffset = (double)(m_ypos - (height/2.0) + (height - max_height)/2.0);
    else
      yoffset = (double)(m_ypos - (height/2.0));
    yOffset = m_ypos;
  }
  else
  {
    yoffset = 0.0;
    yOffset = 0.0;
  }

  if (formatMode & FORMAT_CENTRE_HORIZ)
  {
    xoffset = (double)(m_xpos - width/2.0);
    xOffset = m_xpos;
  }
  else
  {
    xoffset = 0.0;
    xOffset = 0.0;
  }

  i = 0;

  for (current = text_list->GetFirst();
       current;
       current = current->GetNext(), i++)
  {
    wxShapeTextLine* line = wxStaticCast(current->GetData(), wxShapeTextLine);

    double x;
    if ((formatMode & FORMAT_CENTRE_HORIZ) && (widths[i] < width))
      x = (double)((width - widths[i])/2.0 + xoffset);
    else
      x = xoffset;
    double y = (double)(i*char_height + yoffset);

    line->SetX( x - xOffset ); line->SetY( y - yOffset );
  }
  delete[] widths;
}
wxString mmPanelBase::BuildPage() const
{
    mmReportsPanel* rp = wxStaticCast(this, mmReportsPanel);
    return rp ? rp->getPrintableBase()->getHTMLText() : "TBD";
}
Exemple #19
0
ImageDocument* ImageView::GetDocument()
{
    return wxStaticCast(wxView::GetDocument(), ImageDocument);
}
Exemple #20
0
wxGxObject* wxGxArchiveFolder::GetArchiveFolder(wxGxObject *oParent, const wxString &soName, const CPLString &soPath)
{
	wxGxArchiveFolder* pFolder = new wxGxArchiveFolder(oParent, soName, soPath);
	return wxStaticCast(pFolder, wxGxObject);
}
Exemple #21
0
DrawingDocument* DrawingView::GetDocument()
{
    return wxStaticCast(wxView::GetDocument(), DrawingDocument);
}
Exemple #22
0
bool DataModelListCtrl::IsOpen() const
{
    const wxDataModelBase* db = wxStaticCast(this, DataModelListCtrl)->GetModel(); // unconst

    return db && db->IsOpen();
}
wxGxObject* wxGxMapInfoFactoryUI::GetGxObject(wxGxObject* pParent, const wxString &soName, const CPLString &szPath, wxGISEnumVectorDatasetType type, bool bCheckNames)
{
    if(!m_bHasDriver)
        return NULL;

    if(bCheckNames && IsNameExist(pParent, soName))
    {
        return NULL;
    }

    switch(type)
    {
    case enumVecMapinfoTab:
        {
            CPLString sTestPath;
            wxGxObject *pCompoundObjectPart = NULL;
            wxGxObjectContainer* pParentCont = wxDynamicCast(pParent, wxGxObjectContainer);

            for (int j = 0; mi_filter_exts[j] != NULL; ++j)
            {
                sTestPath = (char*)CPLResetExtension(szPath, mi_filter_exts[j]);

                wxGxObjectList::const_iterator iter;
                for (iter = pParentCont->GetChildren().begin(); iter != pParentCont->GetChildren().end(); ++iter)
                {
                    wxGxObject *current = *iter;
                    if (wxGISEQUAL(current->GetPath(), sTestPath))
                    {
                        current->Destroy();
                        break;
                    }
                }
            }

            if(!m_SmallTabIcon.IsOk())
                m_SmallTabIcon = wxIcon(mi_dset_16_xpm);
            if(!m_LargeTabIcon.IsOk())
                m_LargeTabIcon = wxIcon(mi_dset_48_xpm);

            return wxStaticCast(new wxGxFeatureDatasetUI(type, pParent, soName, szPath, m_LargeTabIcon, m_SmallTabIcon), wxGxObject);
        }
    case enumVecMapinfoMif:
        if(!m_SmallMifIcon.IsOk())
            m_SmallMifIcon = wxIcon(md_dset_16_xpm);
        if(!m_LargeMifIcon.IsOk())
            m_LargeMifIcon = wxIcon(md_dset_48_xpm);
        return wxStaticCast(new wxGxFeatureDatasetUI(type, pParent, soName, szPath, m_LargeMifIcon, m_SmallMifIcon), wxGxObject);
    case enumVecMAX + 1:
        if(!m_SmallTabTIcon.IsOk())
            m_SmallTabTIcon = wxIcon(table_tab_16_xpm);
        if(!m_LargeTabTIcon.IsOk())
            m_LargeTabTIcon = wxIcon(table_tab_48_xpm);
        return wxStaticCast(new wxGxTableDatasetUI(enumTableMapinfoTab, pParent, soName, szPath, m_LargeTabTIcon, m_SmallTabTIcon), wxGxObject);
    case enumVecMAX + 2:
        if(!m_SmallTabTIcon.IsOk())
            m_SmallTabTIcon = wxIcon(table_tab_16_xpm);
        if(!m_LargeTabTIcon.IsOk())
            m_LargeTabTIcon = wxIcon(table_tab_48_xpm);
        return wxStaticCast(new wxGxTableDatasetUI(enumTableMapinfoMif, pParent, soName, szPath, m_LargeTabTIcon, m_SmallTabTIcon), wxGxObject);
    default:
        return NULL;
    }
}
Exemple #24
0
wxGxObject* wxGxPrjFactory::GetGxObject(wxGxObject* pParent, const wxString &soName, const CPLString &szPath, wxGISEnumPrjFileType nType)
{
    wxGxPrjFile* pFile = new wxGxPrjFile(nType, pParent, soName, szPath);
	return wxStaticCast(pFile, wxGxObject);
}
Exemple #25
0
Morphan* MorphanView::GetDocument()
{
    return wxStaticCast(wxView::GetDocument(), Morphan);
}