NCBI C++ Toolkit Cross Reference

  C++/src/gui/core/winmask_files_dlg.cpp


/* $Id: winmask_files_dlg.cpp 23363 2011-03-14 22:45:59Z falkrb $ * =========================================================================== * * PUBLIC DOMAIN NOTICE * National Center for Biotechnology Information * * This software/database is a "United States Government Work" under the * terms of the United States Copyright Act. It was written as part of * the author's official duties as a United States Government employee and * thus cannot be copyrighted. This software/database is freely available * to the public for use. The National Library of Medicine and the U.S. * Government have not placed any restriction on its use or reproduction. * * Although all reasonable efforts have been taken to ensure the accuracy * and reliability of the software and data, the NLM and the U.S. * Government do not and cannot warrant the performance or results that * may be obtained by using this software or data. The NLM and the U.S. * Government disclaim all warranties, express or implied, including * warranties of performance, merchantability or fitness for any particular * purpose. * * Please cite the author in any work or product based on this material. * * =========================================================================== * * Authors: Yury Voronov * * File Description: * */ #include <ncbi_pch.hpp> #include <gui/core/winmask_files_dlg.hpp> #include <gui/widgets/wx/wx_utils.hpp> #include <wx/sizer.h> #include <wx/bitmap.h> #include <wx/icon.h> #include <wx/button.h> #include <wx/textctrl.h> #include <wx/stattext.h> #include <wx/statbox.h> #include <wx/checklst.h> #include <wx/treectrl.h> #include <wx/wupdlock.h> #include <wx/dirdlg.h> #include <wx/valgen.h> #include <wx/valtext.h> #include <wx/checkbox.h> ////@begin XPM images ////@end XPM images BEGIN_NCBI_SCOPE IMPLEMENT_DYNAMIC_CLASS( CWinMaskFilesDlg, CDialog ) BEGIN_EVENT_TABLE( CWinMaskFilesDlg, CDialog ) ////@begin CWinMaskFilesDlg event table entries EVT_TEXT( ID_WINMASK_PATH, CWinMaskFilesDlg::OnWinmaskPathTextUpdated ) EVT_BUTTON( ID_BROWSE_BTN, CWinMaskFilesDlg::OnBrowseBtnClick ) EVT_CHECKBOX( ID_PREFERRED_WAY, CWinMaskFilesDlg::OnEnvPreferredClick ) ////@end CWinMaskFilesDlg event table entries END_EVENT_TABLE() CWinMaskFilesDlg::CWinMaskFilesDlg() { Init(); } CWinMaskFilesDlg::CWinMaskFilesDlg( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style ) { Init(); Create(parent, id, caption, pos, size, style); } bool CWinMaskFilesDlg::Create( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style ) { ////@begin CWinMaskFilesDlg creation SetExtraStyle(wxWS_EX_BLOCK_EVENTS); CDialog::Create( parent, id, caption, pos, size, style ); CreateControls(); if (GetSizer()) { GetSizer()->SetSizeHints(this); } Centre(); ////@end CWinMaskFilesDlg creation return true; } CWinMaskFilesDlg::~CWinMaskFilesDlg() { ////@begin CWinMaskFilesDlg destruction ////@end CWinMaskFilesDlg destruction } void CWinMaskFilesDlg::Init() { ////@begin CWinMaskFilesDlg member initialisation m_DirPath = wxEmptyString; m_WinMaskPathCtrl = NULL; m_MasksList = NULL; m_HelpLine = NULL; ////@end CWinMaskFilesDlg member initialisation } void CWinMaskFilesDlg::CreateControls() { ////@begin CWinMaskFilesDlg content construction CWinMaskFilesDlg* itemCDialog1 = this; wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxVERTICAL); itemCDialog1->SetSizer(itemBoxSizer2); wxStaticBox* itemStaticBoxSizer3Static = new wxStaticBox(itemCDialog1, wxID_ANY, _("WindowMasker data files for BLAST")); wxStaticBoxSizer* itemStaticBoxSizer3 = new wxStaticBoxSizer(itemStaticBoxSizer3Static, wxVERTICAL); itemBoxSizer2->Add(itemStaticBoxSizer3, 1, wxGROW|wxALL, 5); wxFlexGridSizer* itemFlexGridSizer4 = new wxFlexGridSizer(0, 2, 0, 0); itemFlexGridSizer4->AddGrowableRow(1); itemFlexGridSizer4->AddGrowableCol(1); itemStaticBoxSizer3->Add(itemFlexGridSizer4, 1, wxGROW|wxLEFT, 5); wxStaticText* itemStaticText5 = new wxStaticText( itemCDialog1, wxID_STATIC, _("Path:"), wxDefaultPosition, wxDefaultSize, 0 ); itemFlexGridSizer4->Add(itemStaticText5, 0, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL|wxALL, 5); wxBoxSizer* itemBoxSizer6 = new wxBoxSizer(wxHORIZONTAL); itemFlexGridSizer4->Add(itemBoxSizer6, 0, wxGROW|wxALIGN_CENTER_VERTICAL, 5); m_WinMaskPathCtrl = new wxTextCtrl( itemCDialog1, ID_WINMASK_PATH, wxEmptyString, wxDefaultPosition, wxSize(itemCDialog1->ConvertDialogToPixels(wxSize(200, -1)).x, -1), 0 ); itemBoxSizer6->Add(m_WinMaskPathCtrl, 1, wxALIGN_CENTER_VERTICAL|wxALL, 5); m_WinMaskPathBtn = new wxButton( itemCDialog1, ID_BROWSE_BTN, _("..."), wxDefaultPosition, wxSize(itemCDialog1->ConvertDialogToPixels(wxSize(20, -1)).x, -1), 0 ); itemBoxSizer6->Add(m_WinMaskPathBtn, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); itemFlexGridSizer4->Add(5, 5, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5); wxCheckBox* m_PreferredWay = new wxCheckBox( itemCDialog1, ID_PREFERRED_WAY, _("Prefer environment (WINDOW_MASKER_PATH)/predefined (ncbi.ini)"), wxDefaultPosition, wxDefaultSize, 0 ); m_PreferredWay->SetValue(true); itemFlexGridSizer4->Add(m_PreferredWay, 0, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL|wxALL, 5); wxStaticText* itemStaticText9 = new wxStaticText( itemCDialog1, wxID_STATIC, _("Masks:"), wxDefaultPosition, wxDefaultSize, 0 ); itemFlexGridSizer4->Add(itemStaticText9, 0, wxALIGN_LEFT|wxALIGN_TOP|wxALL, 5); wxArrayString m_MasksListStrings; m_MasksList = new wxCheckListBox( itemCDialog1, ID_CHECKLISTBOX, wxDefaultPosition, wxSize(-1, itemCDialog1->ConvertDialogToPixels(wxSize(-1, 80)).y), m_MasksListStrings, wxLB_NEEDED_SB ); itemFlexGridSizer4->Add(m_MasksList, 1, wxGROW|wxGROW|wxALL, 5); m_HelpLine = new wxStaticText( itemCDialog1, wxID_STATIC, _("Help"), wxDefaultPosition, wxDefaultSize, 0 ); itemBoxSizer2->Add(m_HelpLine, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5); wxStdDialogButtonSizer* itemStdDialogButtonSizer12 = new wxStdDialogButtonSizer; itemBoxSizer2->Add(itemStdDialogButtonSizer12, 0, wxALIGN_RIGHT|wxALL, 5); wxButton* itemButton13 = new wxButton( itemCDialog1, wxID_OK, _("&OK"), wxDefaultPosition, wxDefaultSize, 0 ); itemStdDialogButtonSizer12->AddButton(itemButton13); wxButton* itemButton14 = new wxButton( itemCDialog1, wxID_CANCEL, _("&Cancel"), wxDefaultPosition, wxDefaultSize, 0 ); itemStdDialogButtonSizer12->AddButton(itemButton14); itemStdDialogButtonSizer12->Realize(); // Set validators //m_WinMaskPathCtrl->SetValidator( wxTextValidator(wxFILTER_ASCII, NULL) ); m_PreferredWay->SetValidator( wxGenericValidator(& m_Params.m_EnvPreferred) ); ////@end CWinMaskFilesDlg content construction } bool CWinMaskFilesDlg::TransferDataToWindow() { m_MasksList->Clear(); ITERATE( vector<string>, mask_itr, m_Params.m_Masks ){ m_MasksList->Append( ToWxString( *mask_itr ) ); } ITERATE( vector<int>, ix_itr, m_Params.m_ChosenIdxs ){ m_MasksList->Check( *ix_itr ); } m_HelpLine->SetLabel( ToWxString( m_Params.m_HelpText ) ); bool rv = wxWindow::TransferDataToWindow(); x_OnEnvPreferred( m_Params.m_EnvPreferred ); Layout(); return rv; } bool CWinMaskFilesDlg::TransferDataFromWindow() { if( wxWindow::TransferDataFromWindow() ){ if( !m_Params.m_EnvPreferred ){ m_Params.m_LocalPath = m_WinMaskPathCtrl->GetValue(); } m_Params.m_ChosenIdxs.clear(); for( int i = 0; i < (int)m_MasksList->GetCount(); i++ ){ if( m_MasksList->IsChecked( i ) ){ m_Params.m_ChosenIdxs.push_back( i ); } } return true; } return false; } void CWinMaskFilesDlg::OnWinmaskPathTextUpdated( wxCommandEvent& event ) { ////@begin wxEVT_COMMAND_TEXT_UPDATED event handler for ID_WINMASK_PATH in CWinMaskFilesDlg. // Before editing this code, remove the block markers. event.Skip(); ////@end wxEVT_COMMAND_TEXT_UPDATED event handler for ID_WINMASK_PATH in CWinMaskFilesDlg. } void CWinMaskFilesDlg::OnBrowseBtnClick( wxCommandEvent& event ) { wxString path = m_WinMaskPathCtrl->GetValue(); wxDirDialog dlg( this ); dlg.SetPath( path ); if( dlg.ShowModal() != wxID_OK ){ return; } path = dlg.GetPath(); m_WinMaskPathCtrl->SetValue( path ); } void CWinMaskFilesDlg::OnEnvPreferredClick( wxCommandEvent& event ) { x_OnEnvPreferred( event.IsChecked() ); } void CWinMaskFilesDlg::x_OnEnvPreferred( bool preferred ) { if( preferred ){ m_Params.m_LocalPath = m_WinMaskPathCtrl->GetValue(); m_WinMaskPathCtrl->SetValue( m_Params.m_PredefPath ); m_WinMaskPathCtrl->Disable(); m_WinMaskPathBtn->Disable(); } else { m_WinMaskPathCtrl->SetValue( m_Params.m_LocalPath ); m_WinMaskPathCtrl->Enable(); m_WinMaskPathBtn->Enable(); } } bool CWinMaskFilesDlg::ShowToolTips() { return true; } wxBitmap CWinMaskFilesDlg::GetBitmapResource( const wxString& name ) { // Bitmap retrieval ////@begin CWinMaskFilesDlg bitmap retrieval wxUnusedVar(name); return wxNullBitmap; ////@end CWinMaskFilesDlg bitmap retrieval } wxIcon CWinMaskFilesDlg::GetIconResource( const wxString& name ) { // Icon retrieval ////@begin CWinMaskFilesDlg icon retrieval wxUnusedVar(name); return wxNullIcon; ////@end CWinMaskFilesDlg icon retrieval } END_NCBI_SCOPE

source navigation ]   [ diff markup ]   [ identifier search ]   [ freetext search ]   [ file search ]  

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.