コード例 #1
0
ファイル: wxmain.cpp プロジェクト: guy-middleton/EPH
void MyFrame::OnRun(wxCommandEvent &event) {
    ostringstream stream;

    text->Clear();

    unique_ptr<eph::nominate_abstract> nsl;

    switch (methods->GetCurrentSelection()) {
        case 0:
            nsl = make_unique<eph::nominate_pal>(stream, lines);
            break;
        case 1:
            nsl = make_unique<eph::nominate_sdv_lpe>(stream, lines);
            break;
        case 2:
            nsl = make_unique<eph::nominate_sdv_lpe>(stream, lines, eph::ENABLE_SL::YES);
            break;
    }

    auto result = nsl->nominate(finalists->GetCurrentSelection()+1, noms_per_ballot->GetCurrentSelection()+1);

    if (verbose->GetValue()) {
        text->AppendText(stream.str());
    }
    text->AppendText(result);
}
コード例 #2
0
void SjViewSettingsPage::GetFontFromDialog(wxString& fontFace, long& fontSize, long& columnWidth, long& coverHeight)
{
	long i = m_fontFaceChoice->GetSelection();
	if( i >= 0 )
	{
		fontFace = m_fontFaceChoice->GetString(i);
	}
	else
	{
		fontFace = g_mainFrame->GetBaseFontFace();
	}

	fontSize = m_fontPtSlider->GetValue();
	columnWidth = m_columnWidthSlider->GetValue() * COLUMNWIDTH_DIVISOR;
	coverHeight = m_coverHeightSlider->GetValue();
}
コード例 #3
0
void SjViewSettingsPage::OnFontDefault(wxCommandEvent&)
{
	// use default values
	long i = m_fontFaceChoice->FindString(SJ_DEF_FONT_FACE);
	if( i == -1 ) i = 0;
	m_fontFaceChoice->SetSelection(i);

	m_fontPtSlider->SetValue(SJ_DEF_FONT_SIZE);
	UpdateFontPtText();
	m_columnWidthSlider->SetValue(SJ_DEF_COLUMN_WIDTH / COLUMNWIDTH_DIVISOR);
	UpdateColumnWidthText();
	m_coverHeightSlider->SetValue(SJ_DEF_COVER_HEIGHT);
	UpdateCoverHeightText();

	m_useViewFontInDlgCheckBox->SetValue(false);

	g_mainFrame->SetFontNCoverBase(SJ_DEF_FONT_FACE, SJ_DEF_FONT_SIZE, SJ_DEF_COLUMN_WIDTH, SJ_DEF_COVER_HEIGHT);
}
コード例 #4
0
ファイル: dynsash_switch.cpp プロジェクト: hajuuk/R7000
void SwitchView::OnSplit(wxDynamicSashSplitEvent& WXUNUSED(event)) {
    SwitchView *view = new SwitchView(m_dyn_sash);
    view->m_choice->SetSelection(m_choice->GetSelection());

    wxScrollBar *hscroll = m_dyn_sash->GetHScrollBar(this);
    wxScrollBar *vscroll = m_dyn_sash->GetVScrollBar(this);

    hscroll->SetEventHandler(this);
    vscroll->SetEventHandler(this);
}
コード例 #5
0
void CDialogVolumeAddNew::OnOK(wxCommandEvent &e)
{
  wxString sCopyFrom = m_pChoiceKit->GetStringSelection();
  m_sName = m_pText->GetValue();
  bool bError = true;
  {
    wxBusyCursor xxx;
    if(m_pVolumes->Create(sCopyFrom,m_sName))
    {
      bError = false;
      e.Skip();
    }
  }

  if(bError) // we want wxBusyCursor out of scope here
  {
    m_sName.Empty();
    mainApp::ShowError(m_pVolumes->GetLastError(),this);
  }
}
コード例 #6
0
ファイル: dynsash_switch.cpp プロジェクト: hajuuk/R7000
void SwitchView::OnPaint(wxPaintEvent& WXUNUSED(event)) {
    wxPaintDC dc(m_view);

    wxScrollBar *hscroll = m_dyn_sash->GetHScrollBar(this);
    wxScrollBar *vscroll = m_dyn_sash->GetVScrollBar(this);

    dc.Clear();
    dc.SetDeviceOrigin(-hscroll->GetThumbPosition(), -vscroll->GetThumbPosition());

    if (m_choice->GetSelection()) {
        dc.DrawLine(20, 20, 280, 20);
        dc.DrawLine(280, 20, 280, 280);
        dc.DrawLine(280, 280, 20, 280);
        dc.DrawLine(20, 280, 20, 20);
    } else {
        dc.DrawLine(150, 20, 280, 280);
        dc.DrawLine(280, 280, 20, 280);
        dc.DrawLine(20, 280, 150, 20);
    }
}
コード例 #7
0
/**
 * Validates and saves (if valid) the type and offset of an array axis numbering
 *
 * @param offsetEntry the entry of the offset (text)
 * @param typeEntry the entry of the axis nmbering scheme (choice)
 * @param type the destination of the type if valid
 * @param offset the destination of the offset if valid
 * @param errors error string accumulator
 * @return if all valid
 */
static bool validateNumberingTypeAndOffset( const wxTextCtrl& offsetEntry,
                                            const wxChoice& typeEntry,
                                            DIALOG_CREATE_ARRAY::ARRAY_NUMBERING_TYPE_T& type,
                                            int& offset,
                                            wxArrayString& errors )
{
    const int typeVal = typeEntry.GetSelection();
    // mind undefined casts to enums (should not be able to happen)
    bool ok = typeVal <= DIALOG_CREATE_ARRAY::NUMBERING_TYPE_MAX;

    if( ok )
    {
        type = (DIALOG_CREATE_ARRAY::ARRAY_NUMBERING_TYPE_T) typeVal;
    }
    else
    {
        wxString err;
        err.Printf( _("Unrecognised numbering scheme: %d"), typeVal );
        errors.Add( err );
        // we can't proceed - we don't know the numbering type
        return false;
    }

    const wxString text = offsetEntry.GetValue();
    ok = getNumberingOffset( text, type, offset );

    if( !ok )
    {
        const wxString& alphabet = alphabetFromNumberingScheme( type );

        wxString err;
        err.Printf( _( "Could not determine numbering start from \"%s\": "
                       "expected value consistent with alphabet \"%s\"" ),
                    text, alphabet );
        errors.Add(err);
    }

    return ok;
}
コード例 #8
0
	NewMapDialog(wxWindow* parent, int game, int port, vector<Archive::mapdesc_t>& maps) : wxDialog(parent, -1, "New Map")
	{
		// Setup dialog
		wxBoxSizer* msizer = new wxBoxSizer(wxVERTICAL);
		SetSizer(msizer);
		wxGridBagSizer* sizer = new wxGridBagSizer(4, 4);
		msizer->Add(sizer, 1, wxEXPAND|wxALL, 10);

		// Open selected game configuration if no map names are currently loaded
		if (theGameConfiguration->nMapNames() == 0)
		{
			string gname = theGameConfiguration->gameConfig(game).name;
			string pname = theGameConfiguration->portConfig(port).name;
			theGameConfiguration->openConfig(gname, pname);
		}

		// Check if the game configuration allows any map name
		int flags = 0;
		if (!theGameConfiguration->anyMapName())
			flags = wxCB_READONLY;

		// Create map name combo box
		cbo_mapname = new wxComboBox(this, -1, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, NULL, flags);
		if (theGameConfiguration->anyMapName()) cbo_mapname->SetMaxLength(8);
		sizer->Add(new wxStaticText(this, -1, "Map Name:"), wxGBPosition(0, 0), wxDefaultSpan, wxALIGN_CENTER_VERTICAL);
		sizer->Add(cbo_mapname, wxGBPosition(0, 1), wxDefaultSpan, wxEXPAND);

		// Add possible map names to the combo box
		for (unsigned a = 0; a < theGameConfiguration->nMapNames(); a++)
		{
			// Check if map already exists
			string mapname = theGameConfiguration->mapName(a);
			bool exists = false;
			for (unsigned m = 0; m < maps.size(); m++)
			{
				if (S_CMPNOCASE(maps[m].name, mapname))
				{
					exists = true;
					break;
				}
			}

			if (!exists)
				cbo_mapname->Append(mapname);
		}

		// Set inital map name selection
		if (theGameConfiguration->nMapNames() > 0)
			cbo_mapname->SetSelection(0);

		// Create map format combo box
		choice_mapformat = new wxChoice(this, -1);
		sizer->Add(new wxStaticText(this, -1, "Map Format:"), wxGBPosition(1, 0), wxDefaultSpan, wxALIGN_CENTER_VERTICAL);
		sizer->Add(choice_mapformat, wxGBPosition(1, 1), wxDefaultSpan, wxEXPAND);

		// Add possible map formats to the combo box
		if (theGameConfiguration->mapFormatSupported(MAP_DOOM, game, port))
			choice_mapformat->Append("Doom");
		if (theGameConfiguration->mapFormatSupported(MAP_HEXEN, game, port))
			choice_mapformat->Append("Hexen");
		if (theGameConfiguration->mapFormatSupported(MAP_UDMF, game, port))
			choice_mapformat->Append("UDMF");
		if (theGameConfiguration->mapFormatSupported(MAP_DOOM64, game, port))
			choice_mapformat->Append("Doom64");
		choice_mapformat->SetSelection(0);

		// Add dialog buttons
		sizer->Add(CreateButtonSizer(wxOK|wxCANCEL), wxGBPosition(2, 0), wxGBSpan(1, 2), wxEXPAND);
		sizer->AddGrowableCol(1, 1);

		Layout();
		sizer->Fit(this);
		CenterOnParent();
	}
コード例 #9
0
	string getMapFormat()
	{
		return choice_mapformat->GetStringSelection();
	}
コード例 #10
0
    NewMapDialog(wxWindow* parent, int game, int port, vector<Archive::mapdesc_t>& maps, Archive* archive)
        : wxDialog(parent, -1, "New Map")
    {
        // Setup dialog
        wxBoxSizer* msizer = new wxBoxSizer(wxVERTICAL);
        SetSizer(msizer);
        wxGridBagSizer* sizer = new wxGridBagSizer(4, 4);
        msizer->Add(sizer, 1, wxEXPAND|wxALL, 10);

        // Open selected game configuration if no map names are currently loaded
        if (theGameConfiguration->nMapNames() == 0)
        {
            string gname = theGameConfiguration->gameConfig(game).name;
            string pname = theGameConfiguration->portConfig(port).name;
            theGameConfiguration->openConfig(gname, pname);
        }

        // Check if the game configuration allows any map name
        int flags = 0;
        if (!theGameConfiguration->anyMapName())
            flags = wxCB_READONLY;

        // Create map name combo box
        cbo_mapname = new wxComboBox(this, -1, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, NULL, flags);
        sizer->Add(new wxStaticText(this, -1, "Map Name:"), wxGBPosition(0, 0), wxDefaultSpan, wxALIGN_CENTER_VERTICAL);
        sizer->Add(cbo_mapname, wxGBPosition(0, 1), wxDefaultSpan, wxEXPAND);

        // Limit map name length if necessary
        if (theGameConfiguration->anyMapName() &&
                (!theGameConfiguration->allowLongNames() ||
                 (archive && archive->getType() != ARCHIVE_ZIP &&
                  archive->getType() != ARCHIVE_7Z &&
                  archive->getType() != ARCHIVE_FOLDER)))
            cbo_mapname->SetMaxLength(8);

        // Add possible map names to the combo box
        for (unsigned a = 0; a < theGameConfiguration->nMapNames(); a++)
        {
            // Check if map already exists
            string mapname = theGameConfiguration->mapName(a);
            bool exists = false;
            for (unsigned m = 0; m < maps.size(); m++)
            {
                if (S_CMPNOCASE(maps[m].name, mapname))
                {
                    exists = true;
                    break;
                }
            }

            if (!exists)
                cbo_mapname->Append(mapname);
        }

        // Set inital map name selection
        if (theGameConfiguration->nMapNames() > 0)
            cbo_mapname->SetSelection(0);

        // Create map format combo box
        choice_mapformat = new wxChoice(this, -1);
        sizer->Add(new wxStaticText(this, -1, "Map Format:"), wxGBPosition(1, 0), wxDefaultSpan, wxALIGN_CENTER_VERTICAL);
        sizer->Add(choice_mapformat, wxGBPosition(1, 1), wxDefaultSpan, wxEXPAND);

        // Add possible map formats to the combo box
        uint8_t default_format = MAP_UNKNOWN;
        if (! maps.empty())
            default_format = maps[0].format;
        for (uint8_t map_type = 0; map_type < MAP_UNKNOWN; map_type++)
        {
            if (theGameConfiguration->mapFormatSupported(map_type, game, port))
            {
                choice_mapformat->Append(MAP_TYPE_NAMES[map_type]);
                if (map_type == default_format)
                    choice_mapformat->SetSelection(choice_mapformat->GetCount() - 1);
            }
        }
        // Default to the "best" supported format, the last one in the list
        if (choice_mapformat->GetSelection() == wxNOT_FOUND)
            choice_mapformat->SetSelection(choice_mapformat->GetCount() - 1);

        // Add dialog buttons
        wxBoxSizer* hbox = new wxBoxSizer(wxHORIZONTAL);
        msizer->Add(hbox, 0, wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM, 10);
        hbox->AddStretchSpacer();
        btn_ok = new wxButton(this, -1, "OK");
        hbox->Add(btn_ok, 0, wxEXPAND | wxRIGHT, 4);
        btn_cancel = new wxButton(this, -1, "Cancel");
        hbox->Add(btn_cancel, 0, wxEXPAND);
        sizer->AddGrowableCol(1);

        // Bind events
        btn_ok->Bind(wxEVT_BUTTON, &NewMapDialog::onBtnOk, this);
        btn_cancel->Bind(wxEVT_BUTTON, &NewMapDialog::onBtnCancel, this);

        Layout();
        msizer->Fit(this);
        CenterOnParent();
    }
コード例 #11
0
wxPanel* SjViewSettingsPage::CreateFontPage(wxWindow* parent)
{
	// init dialog
	wxPanel* page = new wxPanel(parent, -1);
	wxSizer* sizer1 = new wxBoxSizer(wxVERTICAL);
	page->SetSizer(sizer1);

	sizer1->Add(SJ_DLG_SPACE, SJ_DLG_SPACE); // some space

	wxStaticText* staticText = new wxStaticText(page, -1,
	        _("You can set independent font and cover sizes to use in the main window. The sizes\nrefer to a zoom of 100%. If you zoom in or out (eg. by using the \"+\" or \"-\" keys), both\nsizes will grow or shrink proportionally."));
	sizer1->Add(staticText,
	            0, wxALL, SJ_DLG_SPACE);

	m_orgFace           = g_mainFrame->GetBaseFontFace();
	m_orgSize           = g_mainFrame->GetBaseFontSize();
	m_orgColumnWidth    = g_mainFrame->GetBaseColumnWidth();
	m_orgCoverHeight    = g_mainFrame->GetBaseCoverHeight();

	wxFlexGridSizer* sizer3 = new wxFlexGridSizer(2, SJ_DLG_SPACE/2, SJ_DLG_SPACE);
	sizer1->Add(sizer3, 0, wxGROW|wxALL, SJ_DLG_SPACE);

	#define SLIDER_W 240

	// font face
	sizer3->Add(new wxStaticText(page, -1, _("Font:")), 0, wxALIGN_CENTER_VERTICAL);

	m_fontFaceChoice = new wxChoice(page, IDC_FONTFACECHOICE/*, wxDefaultPosition, wxSize(FONTFACE_W, -1)*/);

	const wxArrayString& fontFaces = g_tools->GetFacenames();

	wxString currFace;
	int facesIndex, facesCount = fontFaces.GetCount();
	for( facesIndex = 0; facesIndex < facesCount; facesIndex++ )
	{
		currFace = fontFaces.Item(facesIndex);
		if( currFace[0] != '?' && currFace[0] != '#' ) // ignore funny font names as "?234" eg. on os x/wx2.6.3
		{
			m_fontFaceChoice->Append(currFace);
			if( currFace.CmpNoCase(m_orgFace)==0 )
			{
				m_fontFaceChoice->SetSelection(m_fontFaceChoice->GetCount()-1);
			}
		}
	}

	SjDialog::SetCbWidth(m_fontFaceChoice);
	sizer3->Add(m_fontFaceChoice, 0, wxALIGN_CENTER_VERTICAL);

	// font size
	sizer3->Add(new wxStaticText(page, -1, _("Font size:")), 0, wxALIGN_CENTER_VERTICAL);

	wxBoxSizer* sizer4 = new wxBoxSizer(wxHORIZONTAL);
	sizer3->Add(sizer4);

	m_fontPtSlider = new wxSlider(page, IDC_FONTPTSLIDER, m_orgSize, SJ_MIN_FONT_SIZE, SJ_MAX_FONT_SIZE, wxDefaultPosition, wxSize(SLIDER_W, -1), wxSL_HORIZONTAL);
	sizer4->Add(m_fontPtSlider, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, SJ_DLG_SPACE);

	m_fontPtText = new wxStaticText(page, -1, wxEmptyString);
	UpdateFontPtText(TRUE);
	sizer4->Add(m_fontPtText, 0, wxALIGN_CENTER_VERTICAL, 0);


	// use font in dialogs?
	sizer3->Add(SJ_DLG_SPACE, SJ_DLG_SPACE);

	m_useViewFontInDlgCheckBox = new wxCheckBox(page, -1, _("Use this font for dialogs, too"));
	m_useViewFontInDlgCheckBox->SetValue((g_accelModule->m_flags&SJ_ACCEL_USE_VIEW_FONT_IN_DLG)!=0);
	sizer3->Add(m_useViewFontInDlgCheckBox, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM, SJ_DLG_SPACE);

	// column width
	sizer3->Add(new wxStaticText(page, -1, _("Column width:")), 0, wxALIGN_CENTER_VERTICAL);

	sizer4 = new wxBoxSizer(wxHORIZONTAL);
	sizer3->Add(sizer4);

	m_columnWidthSlider = new wxSlider(page, IDC_COLUMNWIDTHSLIDER, m_orgColumnWidth/COLUMNWIDTH_DIVISOR, SJ_MIN_COLUMN_WIDTH/COLUMNWIDTH_DIVISOR, SJ_MAX_COLUMN_WIDTH/COLUMNWIDTH_DIVISOR, wxDefaultPosition, wxSize(SLIDER_W, -1), wxSL_HORIZONTAL);
	sizer4->Add(m_columnWidthSlider, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, SJ_DLG_SPACE);

	m_columnWidthText = new wxStaticText(page, -1, wxEmptyString);
	UpdateColumnWidthText();
	sizer4->Add(m_columnWidthText, 0, wxALIGN_CENTER_VERTICAL);


	// cover height (= width = size)
	sizer3->Add(new wxStaticText(page, -1, _("Cover size:")), 0, wxALIGN_CENTER_VERTICAL);

	sizer4 = new wxBoxSizer(wxHORIZONTAL);
	sizer3->Add(sizer4);

	m_coverHeightSlider = new wxSlider(page, IDC_COVERHEIGHTSLIDER, m_orgCoverHeight, 1, 100, wxDefaultPosition, wxSize(SLIDER_W, -1), wxSL_HORIZONTAL);
	sizer4->Add(m_coverHeightSlider, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, SJ_DLG_SPACE);

	m_coverHeightText = new wxStaticText(page, -1, wxEmptyString);
	UpdateCoverHeightText();
	sizer4->Add(m_coverHeightText, 0, wxALIGN_CENTER_VERTICAL);

	wxButton* button = new wxButton(page, IDC_FONTDEFAULT, _("Reset to default values"), wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT);
	sizer1->Add(button, 0, wxALL, SJ_DLG_SPACE);

	return page;
}