Exemple #1
0
wxExSTCEntryDialog::wxExSTCEntryDialog(wxWindow* parent,
  const wxString& caption,
  const wxString& text,
  const wxString& prompt,
  long button_style,
  bool use_shell,
  wxWindowID id,
  const wxPoint& pos,
  const wxSize& size, 
  long style,
  const wxString& name)
  : wxExDialog(parent, caption, button_style, id, pos, size, style, name)
  , m_Process(NULL)
{
  if (!prompt.empty())
  {
    AddUserSizer(CreateTextSizer(prompt), wxSizerFlags().Center());
  }

  wxPersistentRegisterAndRestore(this);

  m_STC =  (use_shell ?
    new wxExSTCShell(this, text, wxEmptyString, true, -1, wxEmptyString, wxExSTC::STC_MENU_DEFAULT):
    new wxExSTC(this, text));
  
  m_STC->SetEdgeMode(wxSTC_EDGE_NONE);
  m_STC->ResetMargins();
  m_STC->SetViewEOL(false);
  m_STC->SetViewWhiteSpace(wxSTC_WS_INVISIBLE);

  AddUserSizer(m_STC);

  LayoutSizers();
}
Exemple #2
0
wxExSTCEntryDialog::wxExSTCEntryDialog(wxWindow* parent,
  const wxString& caption,
  const wxString& text,
  const wxString& prompt,
  long button_style,
  bool use_shell,
  wxWindowID id,
  const wxPoint& pos,
  const wxSize& size, 
  long style,
  const wxString& name)
  : wxExDialog(parent, caption, button_style, id, pos, size, style, name)
  , m_Process(NULL)
{
#if wxUSE_STATTEXT
  if (!prompt.empty())
  {
    // See wxWidgets: src\generic\textdlgg.cpp, use similar bottom border flags.
    AddUserSizer(CreateTextSizer(prompt), 
      wxSizerFlags().DoubleBorder(wxBOTTOM));
  }
#endif

  wxPersistentRegisterAndRestore(this);

  m_STC = (use_shell ?
    new wxExSTCShell(this, text, wxEmptyString, true, -1, wxEmptyString,
      wxExSTC::STC_MENU_DEFAULT | wxExSTC::STC_MENU_OPEN_LINK):
    new wxExSTC(this, text));
  
  m_STC->SetEdgeMode(wxSTC_EDGE_NONE);
  m_STC->ResetMargins();
  m_STC->SetViewEOL(false);
  m_STC->SetViewWhiteSpace(wxSTC_WS_INVISIBLE);

  AddUserSizer(m_STC);

  LayoutSizers();
  
  Bind(wxEVT_CLOSE_WINDOW, [=](wxCloseEvent& event){
    if (m_Process != NULL)
    {
      if (m_Process->IsRunning())
      {
        m_Process->Kill();
      }
    }});

  Bind(wxEVT_BUTTON, [=](wxCommandEvent& event) {
      if (m_Process != NULL)
      {
        if (m_Process->IsRunning())
        {
          m_Process->Kill();
        }
      }
      event.Skip();}, wxID_OK);
  
  Bind(wxEVT_MENU, [=](wxCommandEvent& event) {
      wxPostEvent(wxTheApp->GetTopWindow(), event);}, wxID_FIND);
  Bind(wxEVT_MENU, [=](wxCommandEvent& event) {
      wxPostEvent(wxTheApp->GetTopWindow(), event);}, wxID_REPLACE);
}
Exemple #3
0
void wxExConfigDialog::Layout(int rows, int cols, int bookctrl_style)
{
  if (m_ConfigItems.empty())
  {
    AddUserSizer(CreateTextSizer(
      _("No further info available")),
      wxSizerFlags().Center());
    LayoutSizers();
    return;
  }
  
  bool first_time = true;
  wxFlexGridSizer* sizer = NULL;
  wxFlexGridSizer* previous_item_sizer = NULL;
  int previous_item_type = -1;
  
  wxBookCtrlBase* bookctrl = NULL;
  
  if (!m_ConfigItems.begin()->GetPage().empty())
  {
    switch (bookctrl_style)
    {
    case CONFIG_AUINOTEBOOK:
      bookctrl = new wxAuiNotebook(this);
      break;

    case CONFIG_CHOICEBOOK:
      bookctrl = new wxChoicebook(this, wxID_ANY);
      break;

    case CONFIG_LISTBOOK:
      bookctrl = new wxListbook(this, wxID_ANY);
      break;

    case CONFIG_NOTEBOOK:
      bookctrl = new wxNotebook(this, wxID_ANY);
      break;

    case CONFIG_TOOLBOOK:
      bookctrl = new wxToolbook(this, wxID_ANY);
      break;

    case CONFIG_TREEBOOK:
      bookctrl = new wxTreebook(this, wxID_ANY);
      break;

    default:
      wxFAIL;  
    }
  }
       
  wxString previous_page = "XXXXXX";

  for (
#ifdef wxExUSE_CPP0X	
    auto it = m_ConfigItems.begin();
#else
    std::vector<wxExConfigItem>::iterator it = m_ConfigItems.begin();
#endif	
    it != m_ConfigItems.end();
    ++it)
  {
    if (first_time ||
       (it->GetPage() != previous_page && !it->GetPage().empty()))
    {
      first_time = false;

      if (bookctrl != NULL)
      {
        // Finish the current page.
        if (bookctrl->GetCurrentPage() != NULL)
        {
          bookctrl->GetCurrentPage()->SetSizer(sizer);
        }

        // And make a new one.
        bookctrl->AddPage(
          new wxWindow(bookctrl, wxID_ANY), it->GetPage(), true); // select
      }

      previous_page = it->GetPage();

      const int use_cols = (it->GetColumns() != -1 ? it->GetColumns(): cols);

      sizer = (rows != 0 ? 
        new wxFlexGridSizer(rows, use_cols, 0, 0):
        new wxFlexGridSizer(use_cols));

      for (int i = 0; i < use_cols; i++)
      {
        sizer->AddGrowableCol(i);
      }
    }

    wxFlexGridSizer* use_item_sizer = (it->GetType() == previous_item_type ?
      previous_item_sizer: NULL);

    // Layout the config item.
    previous_item_sizer = it->Layout(
      (bookctrl != NULL ? bookctrl->GetCurrentPage(): this), 
      sizer, 
      GetButtonFlags() == wxCANCEL,
      use_item_sizer);

    previous_item_type = it->GetType();

    if (
      it->GetType() == CONFIG_BUTTON ||
      it->GetType() == CONFIG_COMBOBOXDIR)
    {
      Bind(
        wxEVT_COMMAND_BUTTON_CLICKED, 
        &wxExConfigDialog::OnCommand, 
        this, 
        it->GetWindow()->GetId());
    }

    if (sizer != NULL &&
        sizer->GetEffectiveRowsCount() >= 1 &&
       !sizer->IsRowGrowable(sizer->GetEffectiveRowsCount() - 1) &&
        it->IsRowGrowable())
    {
      sizer->AddGrowableRow(sizer->GetEffectiveRowsCount() - 1);
    }
  }

  if (bookctrl != NULL)
  {
    bookctrl->GetCurrentPage()->SetSizer(sizer);
    bookctrl->SetName("book" + GetName());

    if (!wxPersistenceManager::Get().RegisterAndRestore(bookctrl))
    {
      // nothing was restored, so choose the default page ourselves
      bookctrl->SetSelection(0);
    }

    AddUserSizer(bookctrl);
  }
  else
  {
    AddUserSizer(sizer);
  }

  LayoutSizers(bookctrl == NULL); // add separator line if no bookctrl
}