Example #1
0
wxStaticText *wxProgressDialog::CreateLabel(const wxString& text,
                                            wxSizer *sizer)
{
    wxBoxSizer *locsizer = new wxBoxSizer(wxLARGESMALL(wxHORIZONTAL,wxVERTICAL));

    wxStaticText *dummy = new wxStaticText(this, wxID_ANY, text);
    wxStaticText *label = new wxStaticText(this, wxID_ANY, _("unknown"));

    // select placement most native or nice on target GUI
#if defined(__SMARTPHONE__)
    // label and time to the left in two rows
    locsizer->Add(dummy, 1, wxALIGN_LEFT);
    locsizer->Add(label, 1, wxALIGN_LEFT);
    sizer->Add(locsizer, 0, wxALIGN_LEFT | wxTOP | wxLEFT, LAYOUT_MARGIN);
#elif defined(__WXMSW__) || defined(__WXPM__) || defined(__WXMAC__) || defined(__WXGTK20__)
    // label and time centered in one row
    locsizer->Add(dummy, 1, wxLARGESMALL(wxALIGN_RIGHT,wxALIGN_LEFT));
    locsizer->Add(label, 1, wxALIGN_LEFT | wxLEFT, LAYOUT_MARGIN);
    sizer->Add(locsizer, 0, wxALIGN_CENTER_HORIZONTAL | wxTOP, LAYOUT_MARGIN);
#else
    // label and time to the right in one row
    sizer->Add(locsizer, 0, wxALIGN_RIGHT | wxRIGHT | wxTOP, LAYOUT_MARGIN);
    locsizer->Add(dummy);
    locsizer->Add(label, 0, wxLEFT, LAYOUT_MARGIN);
#endif

    return label;
}
Example #2
0
wxStaticText *
wxGenericProgressDialog::CreateLabel(const wxString& text, wxSizer *sizer)
{
    wxStaticText *label = new wxStaticText(this, wxID_ANY, text);
    wxStaticText *value = new wxStaticText(this, wxID_ANY, _("unknown"));

    // select placement most native or nice on target GUI
#if defined(__SMARTPHONE__)
    // value and time to the left in two rows
    sizer->Add(label, 1, wxALIGN_LEFT);
    sizer->Add(value, 1, wxALIGN_LEFT);
#elif defined(__WXMSW__) || defined(__WXPM__) || defined(__WXMAC__) || defined(__WXGTK20__)
    // value and time centered in one row
    sizer->Add(label, 1, wxLARGESMALL(wxALIGN_RIGHT,wxALIGN_LEFT) | wxTOP | wxRIGHT, LAYOUT_MARGIN);
    sizer->Add(value, 1, wxALIGN_LEFT | wxTOP, LAYOUT_MARGIN);
#else
    // value and time to the right in one row
    sizer->Add(label);
    sizer->Add(value, 0, wxLEFT, LAYOUT_MARGIN);
#endif

    return value;
}
Example #3
0
wxGenericDirDialog::wxGenericDirDialog(wxWindow* parent, const wxString& title,
                                       const wxString& defaultPath, long style,
                                       const wxPoint& pos, const wxSize& sz,
                                       const wxString& name):
                wxDialog(parent, ID_DIRCTRL, title, pos, sz, style, name)
{
    wxBusyCursor cursor;

    m_path = defaultPath;
    if (m_path == wxT("~"))
        wxGetHomeDir(&m_path);
    if (m_path == wxT("."))
        m_path = wxGetCwd();

    wxBoxSizer *topsizer = new wxBoxSizer( wxVERTICAL );

    // smart phones does not support or do not waste space for wxButtons
#if defined(__SMARTPHONE__)

    wxMenu *dirMenu = new wxMenu;
    dirMenu->Append(ID_GO_HOME, _("Home"));

    if (style & wxDD_NEW_DIR_BUTTON)
    {
        dirMenu->Append(ID_NEW, _("New directory"));
    }

    dirMenu->AppendCheckItem(ID_SHOW_HIDDEN, _("Show hidden directories"));
    dirMenu->AppendSeparator();
    dirMenu->Append(wxID_CANCEL, _("Cancel"));

    SetRightMenu(wxID_ANY, _("Options"), dirMenu);

#else

    // 0) 'New' and 'Home' Buttons
    wxSizer* buttonsizer = new wxBoxSizer( wxHORIZONTAL );

    // VS: 'Home directory' concept is unknown to MS-DOS
#if !defined(__DOS__)
    wxBitmapButton* homeButton =
        new wxBitmapButton(this, ID_GO_HOME,
                           wxArtProvider::GetBitmap(wxART_GO_HOME, wxART_BUTTON));
    buttonsizer->Add( homeButton, 0, wxLEFT|wxRIGHT, 10 );
#endif

    // I'm not convinced we need a New button, and we tend to get annoying
    // accidental-editing with label editing enabled.
    if (style & wxDD_NEW_DIR_BUTTON)
    {
        wxBitmapButton* newButton =
            new wxBitmapButton(this, ID_NEW,
                            wxArtProvider::GetBitmap(wxART_NEW_DIR, wxART_BUTTON));
        buttonsizer->Add( newButton, 0, wxRIGHT, 10 );
#if wxUSE_TOOLTIPS
        newButton->SetToolTip(_("Create new directory"));
#endif
    }

#if wxUSE_TOOLTIPS
    homeButton->SetToolTip(_("Go to home directory"));
#endif

    topsizer->Add( buttonsizer, 0, wxTOP | wxALIGN_RIGHT, 10 );

#endif // __SMARTPHONE__/!__SMARTPHONE__

    // 1) dir ctrl
    m_dirCtrl = NULL; // this is necessary, event handler called from
                      // wxGenericDirCtrl would crash otherwise!
    long dirStyle = wxDIRCTRL_DIR_ONLY | wxDEFAULT_CONTROL_BORDER;

#ifdef __WXMSW__
    if (style & wxDD_NEW_DIR_BUTTON)
    {
        // Only under Windows do we need the wxTR_EDIT_LABEL tree control style
        // before we can call EditLabel (required for "New directory")
        dirStyle |= wxDIRCTRL_EDIT_LABELS;
    }
#endif

    m_dirCtrl = new wxGenericDirCtrl(this, ID_DIRCTRL,
                                     m_path, wxDefaultPosition,
                                     wxSize(300, 200),
                                     dirStyle);

    topsizer->Add( m_dirCtrl, 1, wxTOP|wxLEFT|wxRIGHT | wxEXPAND, wxLARGESMALL(10,0) );

#ifndef __SMARTPHONE__
    // Make the an option depending on a flag?
    wxCheckBox* check = new wxCheckBox( this, ID_SHOW_HIDDEN, _("Show hidden directories") );
    topsizer->Add( check, 0, wxLEFT|wxRIGHT|wxTOP | wxALIGN_RIGHT, 10 );
#endif // !__SMARTPHONE__

    // 2) text ctrl
    m_input = new wxTextCtrl( this, ID_TEXTCTRL, m_path, wxDefaultPosition );
    topsizer->Add( m_input, 0, wxTOP|wxLEFT|wxRIGHT | wxEXPAND, wxLARGESMALL(10,0) );

#ifndef __SMARTPHONE__

#if wxUSE_STATLINE
    // 3) Static line
    topsizer->Add( new wxStaticLine( this, wxID_ANY ), 0, wxEXPAND | wxLEFT|wxRIGHT|wxTOP, 10 );
#endif

    // 4) Buttons
    topsizer->Add( CreateButtonSizer( wxOK|wxCANCEL ), 0, wxEXPAND | wxALL, 10 );

#endif // !__SMARTPHONE__

    m_input->SetFocus();

    SetAutoLayout( true );
    SetSizer( topsizer );

#if !defined(__SMARTPHONE__) && !defined(__POCKETPC__)
    topsizer->SetSizeHints( this );
    topsizer->Fit( this );

    Centre( wxBOTH );
#endif
}
Example #4
0
bool wxAnyChoiceDialog::Create(wxWindow *parent,
                               const wxString& message,
                               const wxString& caption,
                               int n, const wxString *choices,
                               long styleDlg,
                               const wxPoint& pos,
                               long styleLbox)
{
#if defined(__SMARTPHONE__) || defined(__POCKETPC__)
    styleDlg &= ~wxBORDER_MASK;
    styleDlg &= ~wxRESIZE_BORDER;
    styleDlg &= ~wxCAPTION;
#endif

#ifdef __WXMAC__
    if ( !wxDialog::Create(parent, wxID_ANY, caption, pos, wxDefaultSize, styleDlg & (~wxCANCEL) ) )
        return false;
#else
    if ( !wxDialog::Create(parent, wxID_ANY, caption, pos, wxDefaultSize, styleDlg) )
        return false;
#endif

    wxBoxSizer *topsizer = new wxBoxSizer( wxVERTICAL );

    // 1) text message
#ifdef __WXMAC__
    // align text and list at least on mac
    topsizer->Add( CreateTextSizer( message ), 0, wxALL, wxLARGESMALL(15,0) );
#else
    topsizer->Add( CreateTextSizer( message ), 0, wxALL, wxLARGESMALL(10,0) );
#endif
    
    // 2) list box
    m_listbox = new wxListBox( this, wxID_LISTBOX,
                               wxDefaultPosition, wxDefaultSize,
                               n, choices,
                               styleLbox );
    if ( n > 0 )
        m_listbox->SetSelection(0);

    topsizer->Add( m_listbox, 1, wxEXPAND|wxLEFT|wxRIGHT, wxLARGESMALL(15,0) );

    // smart phones does not support or do not waste space for wxButtons
#ifdef __SMARTPHONE__

    SetRightMenu(wxID_CANCEL, _("Cancel"));

#else // __SMARTPHONE__/!__SMARTPHONE__

    // Mac Human Interface Guidelines recommend not to use static lines as grouping elements
#ifndef __WXMAC__
#if wxUSE_STATLINE
    // 3) static line
    topsizer->Add( new wxStaticLine( this, wxID_ANY ), 0, wxEXPAND | wxLEFT|wxRIGHT|wxTOP, 10 );
#endif
#endif

    // 4) buttons
    topsizer->Add( CreateButtonSizer( styleDlg & (wxOK|wxCANCEL) ), 0, wxEXPAND | wxALL, 10 );

#endif // !__SMARTPHONE__

    SetSizer( topsizer );

#if !defined(__SMARTPHONE__) && !defined(__POCKETPC__)
    topsizer->SetSizeHints( this );
    topsizer->Fit( this );

    if ( styleDlg & wxCENTRE )
        Centre(wxBOTH);
#endif

    m_listbox->SetFocus();

    return true;
}