Exemple #1
0
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);
}
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();
}
Exemple #3
0
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);
    }
}
/**
 * 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;
}
    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();
    }