/* * _DoStdout - put stuff to stdout */ unsigned _DoStdout( LPWDATA w, const void *buff, unsigned size ) { if( w == NULL ) return( 0 ); if( !w->active) _MakeWindowActive( w ); _AddLine( w, buff, size ); _MessageLoop( TRUE ); return( size ); } /* _DoStdout */
/* * _DoPutch - put a character to stdout */ void _DoPutch( LPWDATA w, unsigned ch ) { char tmp[2]; if( w == NULL ) return; if( !w->active) _MakeWindowActive( w ); tmp[0] = ch; tmp[1] = 0; _AddLine( w, tmp, 1 ); _MessageLoop( TRUE ); } /* _DoPutch */
void TextBox::_ReformatText() { // (1): Go through the text ustring and determine where the newline characters can be found, examining one line at a time and adding it to the _text vector. size_t start_pos = 0; size_t newline_pos; ustring temp_str = _text_save; const size_t temp_length = temp_str.length(); _text.clear(); _num_chars = 0; // If font not set, return (leave _text vector empty) if (_font_properties == NULL) { IF_PRINT_WARNING(VIDEO_DEBUG) << "textbox font is invalid" << endl; return; } while (start_pos < temp_length) { newline_pos = temp_str.find(NEWLINE_CHARACTER, start_pos); // If the end of the string has been reached, add the new line and exit if (newline_pos == ustring::npos) { _AddLine(temp_str.substr(start_pos, temp_length - start_pos)); break; } // Otherwise, add the new line segment and proceed to find the next else { _AddLine(temp_str.substr(start_pos, temp_length - newline_pos)); start_pos = newline_pos + 1; } } // (2): Calculate the height of the text and check it against the height of the textbox. int32 text_height = CalculateTextHeight(); if (text_height > _height) { IF_PRINT_WARNING(VIDEO_DEBUG) << "tried to display text of height (" << text_height << ") in a window of lower height (" << _height << ")" << endl; } } // void TextBox::_ReformatText()
void TextBox::_ReformatText() { // (1): Go through the text ustring and determine where the newline characters can be found, examining one line at a time and adding it to the _text vector. size_t newline_pos; size_t startline_pos = 0; const size_t temp_length = _text_save.length(); _text.clear(); _num_chars = 0; // If font not set, return (leave _text vector empty) if(!_font_properties) { IF_PRINT_WARNING(VIDEO_DEBUG) << "textbox font is invalid" << std::endl; return; } while(startline_pos < temp_length) { newline_pos = _text_save.find(NEWLINE_CHARACTER,startline_pos); // If the end of the string has been reached, add the new line and exit if(newline_pos == ustring::npos) { _AddLine(_text_save.substr(startline_pos, temp_length - startline_pos)); break; } // Otherwise, add the new line segment and proceed to find the next else { ustring tmp = _text_save.substr(startline_pos, newline_pos - startline_pos); _AddLine(_text_save.substr(startline_pos, newline_pos - startline_pos)); startline_pos = newline_pos + 1; } } // Update the scissor cache // Stores the positions of the four sides of the rectangle float left = 0.0f; float right = _width; float bottom = 0.0f; float top = _height; VideoManager->PushState(); VideoManager->SetDrawFlags(_xalign, _yalign, VIDEO_BLEND, 0); CalculateAlignedRect(left, right, bottom, top); VideoManager->PopState(); // Create a screen rectangle for the position and apply any scissoring int32 x, y, w, h; x = static_cast<int32>(left < right ? left : right); y = static_cast<int32>(top < bottom ? top : bottom); w = static_cast<int32>(right - left); h = static_cast<int32>(top - bottom); if(w < 0) w = -w; if(h < 0) h = -h; _scissor_rect.Set(x, y, w, h); // Update the text height _text_height = static_cast<float>(CalculateTextHeight()); // Calculate the height of the text and check it against the height of the textbox. if(_text_height > _height) { IF_PRINT_WARNING(VIDEO_DEBUG) << "tried to display text of height (" << _text_height << ") in a window of lower height (" << _height << ")" << std::endl; } // Determine the vertical position of the text based on the alignment if(_text_yalign == VIDEO_Y_TOP) { _text_ypos = top; } else if(_text_yalign == VIDEO_Y_CENTER) { _text_ypos = top - (VideoManager->_current_context.coordinate_system.GetVerticalDirection() * (_height - _text_height) * 0.5f); } else { // (_yalign == VIDEO_Y_BOTTOM) _text_ypos = top - (VideoManager->_current_context.coordinate_system.GetVerticalDirection() * (_height - _text_height)); } // Determine the horizontal position of the text based on the alignment if(_text_xalign == VIDEO_X_LEFT) { _text_xpos = left; } else if(_text_xalign == VIDEO_X_CENTER) { _text_xpos = (left + right) * 0.5f; // * 0.5 equals /2. } else { // (_text_xalign == VIDEO_X_RIGHT) _text_xpos = right; } } // void TextBox::_ReformatText()
CPanelLabGeneral::CPanelLabGeneral( wxWindow *parent) : nwxPanel(parent, wxID_ANY), m_pInfo(NULL), m_pMarker(NULL) { vector<wxString> vsFileTypes; wxRadioButton *pRadio; m_pLabelVolumeName = new wxStaticText(this,wxID_ANY,wxEmptyString); m_pLabelKitName = new wxStaticText(this,wxID_ANY,wxEmptyString); m_pLabelLastUpdateUser = new wxStaticText(this,wxID_ANY,wxEmptyString); wxFont fn = m_pLabelVolumeName->GetFont(); fn.SetWeight(wxFONTWEIGHT_BOLD); m_pLabelVolumeName->SetFont(fn); m_pLabelKitName->SetFont(fn); m_pChoiceILS = new wxChoice(this,wxID_ANY); int nFileTypeStyle = wxRB_GROUP; int nSizerStyle = wxALIGN_CENTER_VERTICAL | wxALIGN_LEFT; wxBoxSizer *pSizerRadioFileType = new wxBoxSizer(wxHORIZONTAL); CDirList::GetTypes(&vsFileTypes); m_vpRadioFileType.reserve(vsFileTypes.size()); for(vector<wxString>::iterator itr = vsFileTypes.begin(); itr != vsFileTypes.end(); ++itr) { pRadio = new wxRadioButton( this, wxID_ANY, *itr, wxDefaultPosition, wxDefaultSize, nFileTypeStyle); pSizerRadioFileType->Add(pRadio,0,nSizerStyle,ID_BORDER << 1); nFileTypeStyle = 0; nSizerStyle = wxALIGN_CENTER_VERTICAL | wxALIGN_LEFT | wxLEFT; m_vpRadioFileType.push_back(pRadio); } m_pRadioRaw = new wxRadioButton( this, wxID_ANY, CParmOsiris::LABEL_DATA_RAW, wxDefaultPosition, wxDefaultSize, wxRB_GROUP); m_pRadioAnalyzed = new wxRadioButton( this, wxID_ANY, CParmOsiris::LABEL_DATA_ANALYZED, wxDefaultPosition, wxDefaultSize); m_pCheckUserOverride = new wxCheckBox(this,wxID_ANY, ALLOW_USER_OVERRIDE); m_pTextProtocol = new wxTextCtrl(this, wxID_ANY); m_pTextLot = new wxTextCtrl(this,wxID_ANY); m_pTextNotes = new wxTextCtrl(this,wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE); wxGridBagSizer *pGridSizer = new wxGridBagSizer(ID_BORDER,ID_BORDER); wxGBPosition gbPos(0,0); _AddLine(wxS(VOLUME_STRING) wxS(" Name: "),m_pLabelVolumeName,pGridSizer, &gbPos); _AddLine(wxS("Reagent Kit: "),m_pLabelKitName,pGridSizer, &gbPos); _AddLine(wxS("Last Update: "),m_pLabelLastUpdateUser, pGridSizer, &gbPos); _AddLine(wxS("File Type: "), pSizerRadioFileType,pGridSizer,&gbPos); wxBoxSizer *pSizerRadio = new wxBoxSizer(wxHORIZONTAL); pSizerRadio->Add(m_pRadioRaw,0,wxALIGN_CENTER_VERTICAL | wxALIGN_LEFT); pSizerRadio->Add(m_pRadioAnalyzed,0,wxALIGN_CENTER_VERTICAL | wxALIGN_LEFT | wxLEFT,ID_BORDER << 1); _AddLine(wxS("Data:"),pSizerRadio,pGridSizer,&gbPos); _AddLine(wxS("Internal Lane Standard: "), m_pChoiceILS,pGridSizer,&gbPos); { wxGBSpan gbSpan(1,2); int nRow = gbPos.GetRow(); pGridSizer->Add( m_pCheckUserOverride,gbPos, gbSpan, wxALIGN_CENTER_VERTICAL | wxALIGN_LEFT | wxLEFT, ID_BORDER); gbPos.SetRow(++nRow); } _AddLine(wxS("Protocol: "), m_pTextProtocol,pGridSizer, &gbPos); _AddLine(wxS("Lot Nr.: "), m_pTextLot, pGridSizer, &gbPos); wxBoxSizer *pSizer = new wxBoxSizer(wxVERTICAL); pSizer->Add(pGridSizer,0,wxEXPAND | wxALL, ID_BORDER); pSizer->Add( new wxStaticText(this,wxID_ANY,"Notes:"), 0,wxLEFT | wxTOP | wxBOTTOM | wxALIGN_LEFT, ID_BORDER); pSizer->Add(m_pTextNotes,1,wxEXPAND | (wxALL ^ wxTOP), ID_BORDER); SetSizer(pSizer); // do not Layout() because TransferDataToWindow() will modify the sizes }