Beispiel #1
0
void GUITextBox::OnKeyDown(UCHAR key)
{
	SetShift(keys[VK_SHIFT]);

	if(GetText())
	{
		if((IsAlpabetic(key) || key == VK_SPACE) &&
			GetTextLength() < GetMaxTextLength())
		{
			char* new_text = new char[strlen(GetText())+2];
			if(GetShift())
				sprintf(new_text, "%s%c\0", GetText(), key);
			else
				sprintf(new_text, "%s%c\0", GetText(), tolower(key));

			try
			{
				delete[] GetText();
			}
			catch(...)
			{
				WriteToLog("Exception in GUITextBox::OnKeyDown()");
			}
			SetText(new_text);
			SetTextLength(strlen(GetText()));
		}
		else if(key == VK_BACK)
		{
			UINT len = strlen(GetText());
			if(len > 0)
			{
				string s = string(GetText());
				char* new_text = new char[len];

				sprintf(new_text, "%s\0", s.substr(0, s.length()-1).c_str());
				

				try
				{
					delete[] GetText();
				}
				catch(...)
				{
					WriteToLog("Exception in GUITextBox::OnKeyDown()");
				}
				SetText(new_text);
				SetTextLength(strlen(GetText()));
			}
		}
	}
	else
	{
		char* new_text = new char[1];
		if(GetShift())
			new_text[0] = key;
		else
			new_text[0] = tolower(key);
		SetText(new_text);
	}
}
Beispiel #2
0
GUITextBox::GUITextBox()
{
	Init();
	SetCaption(NULL);
	SetCaptionFont(NULL);
	SetCaptionColor(DEFAULT_TEXT_COLOR);
	SetText("");
	SetTextFont(NULL);
	SetTextColor(DEFAULT_TEXT_COLOR);
	SetTextCaretPos(0);
	SetShift(false);
	SetTextLength(0);
	SetMaxTextLength(DEFAULT_MAX_TEXT_LENGTH);
}
Beispiel #3
0
bool CGridCMF::TransferDataToGrid()
{
  size_t n = m_vpSample.size();
  bool bRtn = (n > 0);
  if(bRtn)
  {

    // loop through samples

    const CLabSettings &lab(m_pFile->GetLabSettings());
    wxString sName;
    wxString sCat;
    COARsample *pSample;
    const CLabNameStrings *pNameStr;
    size_t i;

    for(i = 0; i < n; i++)
    {
      pSample = m_vpSample.at(i);

      // sample name and category

      sName = pSample->GetName();
      pNameStr = lab.GetLabStrings();
      if(pNameStr == NULL)
      {
        sCat = DEFAULT;
      }
      else
      {
        sCat = pNameStr->GetCategory(sName);
        if(sCat.IsEmpty())
        {
          sCat = DEFAULT;
        }
      }


      // now set cell values

      SetBoolValue((int)i,EXCLUDE,false);
      SetCellValue((int)i,SPECIMEN_TYPE,sCat);
      SetCellValue((int)i,SAMPLE,pSample->GetName());
      SetTextLength((int)i,SAMPLE,nwxXmlCMFSpecimen::LEN_SPECIMEN_ID);
      SetTextLength((int)i,SOURCE_ID,nwxXmlCMFSpecimen::LEN_SOURCE_ID);
      SetTextLength((int)i,CASE_ID,nwxXmlCMFSpecimen::LEN_CASE_ID);
      SetTextLength((int)i,COMMENT,nwxXmlCMFSpecimen::LEN_SPECIMEN_COMMENT);
    }
    UpdateEmptyLoci();
    nwxGrid::UpdateLabelSizes(this);
    AutoSizeColumn(EXCLUDE);
    AutoSizeColumn(SAMPLE);
    AutoSizeColumn(PARTIAL);

    // compute size of SPECIMENT_TYPE columns
    int nWidth = wxSystemSettings::GetMetric(wxSYS_VSCROLL_X);
    const char *ps = CLabSpecimenCategory::LongestType();
    wxClientDC dc(this);
    dc.SetFont(GetDefaultCellFont());
    wxSize sz = dc.GetTextExtent(ps);
    if(!nWidth)
    {
      nWidth = 20;
    }
    nWidth += sz.GetWidth();
    nWidth += 6;
    SetColSize(SPECIMEN_TYPE,nWidth);
    sz = dc.GetTextExtent(
      "This is sample text to determine the width of the comment column.");
    nWidth = sz.GetWidth();
    nWidth += 2;
    SetColSize(COMMENT,nWidth);
  }
  return bRtn;
}