示例#1
0
wxSize wxListbook::GetControllerSize() const
{
    const wxSize sizeClient = GetClientSize(),
                 sizeBorder = m_bookctrl->GetSize() - m_bookctrl->GetClientSize(),
                 sizeList = GetListView()->GetViewRect().GetSize() + sizeBorder;

    wxSize size;

    if ( IsVertical() )
    {
        size.x = sizeClient.x;
        size.y = sizeList.y;
    }
    else // left/right aligned
    {
        size.x = sizeList.x;
        size.y = sizeClient.y;
    }

    return size;
}
示例#2
0
int wxListbook::HitTest(const wxPoint& pt, long *flags) const
{
    int pagePos = wxNOT_FOUND;

    if ( flags )
        *flags = wxBK_HITTEST_NOWHERE;

    // convert from listbook control coordinates to list control coordinates
    const wxListView * const list = GetListView();
    const wxPoint listPt = list->ScreenToClient(ClientToScreen(pt));

    // is the point inside list control?
    if ( wxRect(list->GetSize()).Contains(listPt) )
    {
        int flagsList;
        pagePos = list->HitTest(listPt, flagsList);

        if ( flags )
        {
            if ( pagePos != wxNOT_FOUND )
                *flags = 0;

            if ( flagsList & (wxLIST_HITTEST_ONITEMICON |
                              wxLIST_HITTEST_ONITEMSTATEICON ) )
                *flags |= wxBK_HITTEST_ONICON;

            if ( flagsList & wxLIST_HITTEST_ONITEMLABEL )
                *flags |= wxBK_HITTEST_ONLABEL;
        }
    }
    else // not over list control at all
    {
        if ( flags && GetPageRect().Contains(pt) )
            *flags |= wxBK_HITTEST_ONPAGE;
    }

    return pagePos;
}
示例#3
0
void wxListbook::SetImageList(wxImageList *imageList)
{
#ifdef CAN_USE_REPORT_VIEW
    wxListView * const list = GetListView();

    // If imageList presence has changed, we update the list control view
    if ( (imageList != NULL) != (GetImageList() != NULL) )
    {
        // Preserve the selection which is lost when changing the mode
        const int oldSel = GetSelection();

        // Update the style to use icon view for images, report view otherwise
        long style = wxLC_SINGLE_SEL;
        if ( imageList )
        {
            style |= GetListCtrlIconViewFlags();
        }
        else // no image list
        {
            style |= GetListCtrlReportViewFlags();
        }

        list->SetWindowStyleFlag(style);
        if ( !imageList )
            list->InsertColumn(0, wxT("Pages"));

        // Restore selection
        if ( oldSel != wxNOT_FOUND )
           SetSelection(oldSel);
    }

    list->SetImageList(imageList, wxIMAGE_LIST_NORMAL);
#endif // CAN_USE_REPORT_VIEW

    wxBookCtrlBase::SetImageList(imageList);
}
示例#4
0
void wxListbook::UpdateSelectedPage(size_t newsel)
{
    m_selection = newsel;
    GetListView()->Select(newsel);
    GetListView()->Focus(newsel);
}
示例#5
0
bool wxListbook::SetPageImage(size_t n, int imageId)
{
    return GetListView()->SetItemImage(n, imageId);
}
示例#6
0
wxString wxListbook::GetPageText(size_t n) const
{
    return GetListView()->GetItemText(n);
}
示例#7
0
bool wxListbook::SetPageText(size_t n, const wxString& strText)
{
    GetListView()->SetItemText(n, strText);

    return true;
}
示例#8
0
void wxExSampleFrame::OnCommand(wxCommandEvent& event)
{
  m_Statistics.Inc(wxString::Format("%d", event.GetId()));

  auto* editor = GetSTC();
  auto* grid = GetGrid();
  auto* listview = GetListView();

  if (
    (event.GetId() == wxID_UNDO ||
     event.GetId() == wxID_REDO ||
     event.GetId() == wxID_DELETE ||
     event.GetId() == wxID_SELECTALL ||
     event.GetId() == wxID_JUMP_TO) ||
    (event.GetId() >= wxID_CUT && event.GetId() <= wxID_CLEAR))
  {
    if (editor != NULL)
    {
      wxPostEvent(editor, event);
    }
    else if (grid != NULL)
    {
      wxPostEvent(grid, event);
    }
    else if (listview != NULL)
    {
      wxPostEvent(listview, event);
    }
  }
  else
  {
    switch (event.GetId())
    {
    case wxID_ABOUT:
      {
      wxAboutDialogInfo info;
      info.SetIcon(GetIcon());
      info.SetVersion(wxExGetVersionInfo().GetVersionOnlyString());
      info.SetCopyright(wxExGetVersionInfo().GetCopyright());
      wxAboutBox(info);
      }
      break;
    case wxID_EXIT: Close(true); break;
    case wxID_OPEN:
      {
      wxExFileDialog dlg(this, &m_STC->GetFile());
      if (dlg.ShowModalIfChanged(true) == wxID_CANCEL) return;
  
      wxStopWatch sw;
      
      m_STC->Open(dlg.GetPath(), 0, wxEmptyString, m_FlagsSTC);
  
      const auto stop = sw.Time();
      wxLogStatus(wxString::Format(
        "wxExSTC::Open:%ld milliseconds, %d bytes", stop, m_STC->GetTextLength()));
      }
      break;
  
    case wxID_PREVIEW: m_ListView->PrintPreview(); break;
    case wxID_PRINT: m_ListView->Print(); break;
    case wxID_PRINT_SETUP: wxExPrinting::Get()->GetHtmlPrinter()->PageSetup(); break;
  
    case wxID_SAVE:
      m_STC->GetFile().FileSave();
  
      if (m_STC->GetFileName().GetFullPath() == 
          wxExLexers::Get()->GetFileName().GetFullPath())
      {
        wxExLexers::Get()->Read();
        wxLogMessage("File contains: %d lexers", wxExLexers::Get()->GetCount());
          // As the lexer might have changed, update status bar field as well.
  #if wxUSE_STATUSBAR
        UpdateStatusBar(m_STC, "PaneLexer");
  #endif
      }
      break;
  
    case ID_CONFIG_DLG: ShowConfigItems(); break;
    case ID_CONFIG_DLG_READONLY:
      {
      std::vector<wxExConfigItem> v;
  
      v.push_back(wxExConfigItem("File Picker", CONFIG_FILEPICKERCTRL));
  
      for (size_t j = 1; j <= 10; j++)
      {
        v.push_back(wxExConfigItem(wxString::Format("Integer%d", j), CONFIG_INT));
      }
  
      wxExConfigDialog* dlg = new wxExConfigDialog(
        this,
        v,
        "Config Dialog Readonly",
        0,
        1,
        wxCANCEL);
  
        dlg->Show();
      }
      break;
      
    case ID_PROCESS_SELECT:
      wxExProcess::ConfigDialog(this);
      break;
  
    case ID_PROCESS_RUN:
      m_Process.Execute(wxEmptyString);
      break;
      
    case ID_SHELL_COMMAND:
        m_STCShell->Prompt("\nHello '" + event.GetString() + "' from the shell");
      break;
      
    case ID_SHOW_VCS:
      {
      wxFileDialog openFileDialog(this, _("Open File"), "", "",
        "All files (*.*)|*.*", wxFD_OPEN|wxFD_FILE_MUST_EXIST);
  
      if (openFileDialog.ShowModal() == wxID_CANCEL)
        return;     // the user changed idea...
          
      wxArrayString ar;
      ar.Add(openFileDialog.GetPath());
      wxExVCS vcs(ar);
      wxLogMessage(vcs.GetName());
      
      if (vcs.GetEntry().SupportKeywordExpansion())
      {
        wxLogMessage("supports keyword expansion");
      }
      }
      break;
  
    case ID_STATISTICS_SHOW:
      m_Notebook->AddPage(m_Statistics.Show(m_Notebook), "Statistics");
      break;
  
    case ID_STC_CONFIG_DLG:
      wxExSTC::ConfigDialog(
        this,
        "Editor Options",
        wxExSTC::STC_CONFIG_MODELESS | wxExSTC::STC_CONFIG_WITH_APPLY);
      break;
      
    case ID_STC_ENTRY_DLG:
      {
      wxString text;
      
      for (auto i = 0; i < 100; i++)
      {
        text += wxString::Format("Hello from line: %d\n", i);
      }
      
      wxExSTCEntryDialog dlg(
        this,
        "Hello world",
        text,      
        "Greetings from " + wxTheApp->GetAppDisplayName());
        
        dlg.ShowModal();
      }
      break;
      
    case ID_STC_FLAGS:
      {
      long value = wxGetNumberFromUser(
        "Input:",
        wxEmptyString,
        "STC Open Flag",
        m_FlagsSTC,
        0,
        0xFFFF);
  
      if (value != -1)
      {
        m_FlagsSTC = value;
      }
      }
      break;
      
    case ID_STC_SPLIT:
      {
      wxExSTC* stc = new wxExSTC(*m_STC);
      m_Notebook->AddPage(
        stc,
        wxString::Format("stc%d", stc->GetId()),
        m_STC->GetFileName().GetFullName());
      stc->SetDocPointer(m_STC->GetDocPointer());
      }
      break;
      
    default:
      wxFAIL;
      break;
    }
  }
}