CDialogEnableMultiple::CDialogEnableMultiple(
    const vector<COARsample *> *pvpSamples,
    bool bAllowUserNameOverride,
    wxWindow *parent) : 
  wxDialog(
    parent,wxID_ANY,g_psDisable,
    wxDefaultPosition, wxDefaultSize,
    mainApp::DIALOG_STYLE),
    m_pReview(NULL),
    m_pCombo(NULL),
    m_nListSize((int) pvpSamples->size())
{
  vector<COARsample *>::const_iterator itr;
  size_t nSampleCount = pvpSamples->size();
  int n = 0;
  COARsample *pSample;

  m_vnEnabled.reserve(nSampleCount);
  m_vnDisabled.reserve(nSampleCount);
  m_vpSampleEnabled.reserve(nSampleCount);
  m_vpSampleDisabled.reserve(nSampleCount);
  for(itr = pvpSamples->begin();
    itr != pvpSamples->end();
    ++itr)
  {
    n++;
    pSample = *itr;
    if(!pSample->IsSampleType()) {}
    else if(pSample->IsEnabled())
    {
      m_vnEnabled.push_back(n);
      m_vpSampleEnabled.push_back(pSample);
    }
    else
    {
      m_vnDisabled.push_back(n);
      m_vpSampleDisabled.push_back(pSample);
    }
  }
  if(HasSamples())
  {
    wxBoxSizer *pSizer = new wxBoxSizer(wxVERTICAL);
    wxWindow *pWindowTop(NULL);
    int nSizeTOP = wxALIGN_LEFT | wxALL;
    bool bEnable = false;
    if(m_vpSampleEnabled.empty())
    {
      pWindowTop = new wxStaticText(this,wxID_ANY,g_psEnable);
      bEnable = true;
      SetTitle(g_psEnable);
    }
    else if(m_vpSampleDisabled.empty())
    {
      pWindowTop = new wxStaticText(this,wxID_ANY,g_psDisable);
    }
    else
    {
      const wxChar *pChoices[2] = {g_psDisable,g_psEnable};
      wxArrayString choices(2,pChoices);
      m_pCombo = new wxComboBox(this,wxID_ANY,"",
        wxDefaultPosition, wxDefaultSize, choices,wxCB_READONLY);
      pWindowTop = m_pCombo;
      m_pCombo->SetSelection(0);
      nSizeTOP = wxALL | wxEXPAND;
    }
    m_pListBox = new wxListBox(
      this,wxID_ANY,wxDefaultPosition, wxSize(-1,200),
      0,NULL, wxLB_EXTENDED | wxLB_NEEDED_SB);
    m_pReview = new CEnableDisableMultiple(this);
    m_pPanelUser = new CPanelUserID(
      this,wxID_ANY,wxID_ANY,m_pReview,
      UID_BTN_OK | UID_BTN_CANCEL | 
      UID_SPACER_BTN_RIGHT | UID_SEND_BTN_EVENTS,
      !bAllowUserNameOverride);
    m_pPanelUser->Enable(false);
    pSizer->Add(pWindowTop,0,nSizeTOP,ID_BORDER);
    pSizer->Add(m_pListBox,1,(wxALL ^ wxTOP) | wxEXPAND,ID_BORDER);
    pSizer->Add(m_pPanelUser,0,(wxALL ^ wxTOP) | wxEXPAND, ID_BORDER);
    SetSizer(pSizer);
    pSizer->Layout();
    _SetupList(bEnable);
    CentreOnParent();
#ifdef __WXMAC__
    Fit();
#endif
  }
}
示例#2
0
CGridCMF::CGridCMF(
  CDialogCMF *parent,
  wxWindowID id,
  COARfile *pFile,
  COARsampleSort *pSort)
  : _CGridEdit(parent,id,false),
    m_pParent(parent),
    m_pFile(pFile),
    m_pSort(pSort)
{
  wxString s;
  vector<int> vnSample;
  COARsample *pSample;
  size_t n = m_pFile->GetSampleCount();
  size_t i;
  int j = 0;

  m_vpSample.reserve(n);
  vnSample.reserve(n);
    // a little overkill because of ladders and controls
  for(i = 0; i < n; i++)
  {
    j++;
    pSample = m_pSort->GetSample(i);
    if(pSample->IsSampleType() && !pSample->IsDisabled())
    {
      m_vpSample.push_back(pSample);
      vnSample.push_back(j);
    }
  }

  n = m_vpSample.size();
  if(!n)
  {
    CreateGrid(1,1);
    SetCellValue(0,0,"There are no samples");
    SetReadOnly(0,0,true);
    AutoSize();
  }
  else
  {
    int ii;
    CreateGrid((int)n, (int)COLUMN_COUNT);
    SetRowLabelAlignment(wxALIGN_LEFT,wxALIGN_CENTRE);
    for(i = 0; i < n; i++)
    {
      ii = (int)i;
      pSample = m_vpSample.at(i);
      s = CGridAnalysis::FormatRowLabel(
        vnSample.at(i), (int)n, pSample->GetName());
      SetRowLabelValue((int)i,s);
      SetBoolCell(ii,EXCLUDE);
      SetBoolCell(ii,PARTIAL);
      SetCellEditor(ii,SPECIMEN_TYPE,_CreateTypeEditor());
      SetReadOnly(ii,EMPTY_LOCI,true);
    }
    for(i = 0; i < (size_t) COLUMN_COUNT; i++)
    {
      s = COL_LABELS[i];
      SetColLabelValue((int)i,s);
    }
    SetColLabelAlignment(wxALIGN_LEFT,wxALIGN_CENTRE);
  }
}