void CDCTableWidget::onContextMenu(const QPoint& pt) { QMenu menu(this); bool bDlgNoteEditing = G_MainFrame()->isDlgNoteEditing(); // new QAction* pActionNew = menu.addAction(tr("New..."), this, SLOT(onNewNoteItem())); QIcon icon1(QString::fromUtf8(":/res/calendar.png")); pActionNew->setIcon(icon1); // edit QAction* pActionEdit = menu.addAction(tr("Edit..."), this, SLOT(onEditNoteItem())); QIcon icon2(QString::fromUtf8(":/res/edit.png")); pActionEdit->setIcon(icon2); // delete QAction* pActionDelete = menu.addAction(tr("Delete"), this, SLOT(onDeleteNoteItem())); QIcon icon3(QString::fromUtf8(":/res/delete.png")); pActionDelete->setIcon(icon3); pActionEdit->setEnabled(selectionModel()->selectedRows().length()); pActionDelete->setEnabled(selectionModel()->selectedRows().length()); if(bDlgNoteEditing) { pActionNew->setEnabled(false); pActionEdit->setEnabled(false); pActionDelete->setEnabled(false); } menu.exec(QCursor::pos()); }
void frmMDFEditor::CreateControls() { frmMDFEditor* itemFrame = this; wxMenuBar* menuBar = new wxMenuBar; wxMenu* itemMenu3 = new wxMenu; itemMenu3->Append( ID_MENUITEM_NEW, _( "Create New MDF File" ), wxEmptyString, wxITEM_NORMAL ); itemMenu3->AppendSeparator(); itemMenu3->Append( ID_MENUITEM_OPEN, _( "Open MDF file..." ), wxEmptyString, wxITEM_NORMAL ); itemMenu3->Append( ID_MENUITEM_SAVE, _( "Save MDF File..." ), wxEmptyString, wxITEM_NORMAL ); itemMenu3->AppendSeparator(); itemMenu3->Append( ID_MENUITEM_DOWNLOAD, _( "Download MDF file..." ), wxEmptyString, wxITEM_NORMAL ); itemMenu3->Append( ID_MENUITEM_UPLOAD, _( "Upload MDF file..." ), wxEmptyString, wxITEM_NORMAL ); itemMenu3->AppendSeparator(); itemMenu3->Append( ID_MENUITEM_EXIT, _( "Exit" ), wxEmptyString, wxITEM_NORMAL ); menuBar->Append( itemMenu3, _( "File" ) ); wxMenu* itemMenu13 = new wxMenu; itemMenu13->Append( ID_MENUITEM_ADD, _( "Add MDF Item..." ), wxEmptyString, wxITEM_NORMAL ); itemMenu13->Append( ID_MENUITEM_REMOVE, _( "Remove MDF Item..." ), wxEmptyString, wxITEM_NORMAL ); menuBar->Append( itemMenu13, _( "Edit" ) ); itemFrame->SetMenuBar( menuBar ); wxPanel* itemPanel = new wxPanel; itemPanel->Create( itemFrame, ID_PANEL, wxDefaultPosition, wxDefaultSize, wxSUNKEN_BORDER | wxTAB_TRAVERSAL ); wxBoxSizer* itemBoxSizer = new wxBoxSizer( wxVERTICAL ); itemPanel->SetSizer( itemBoxSizer ); wxToolBar* itemToolBar = new wxToolBar; itemToolBar->Create( itemPanel, ID_TOOLBAR3, wxDefaultPosition, wxDefaultSize, wxTB_FLAT | wxTB_HORIZONTAL ); wxBitmap itemtool19Bitmap( itemFrame->GetBitmapResource( wxT( "deffile.xpm" ) ) ); wxBitmap itemtool19BitmapDisabled; itemToolBar->AddTool( ID_TOOL_NEW, wxEmptyString, itemtool19Bitmap, itemtool19BitmapDisabled, wxITEM_NORMAL, _( "Create new MDF file" ), wxEmptyString ); wxBitmap itemtool20Bitmap( itemFrame->GetBitmapResource( wxT( "open.xpm" ) ) ); wxBitmap itemtool20BitmapDisabled; itemToolBar->AddTool( ID_TOOL_LOAD, wxEmptyString, itemtool20Bitmap, itemtool20BitmapDisabled, wxITEM_NORMAL, _( "Load MDF file" ), wxEmptyString ); wxBitmap itemtool21Bitmap( itemFrame->GetBitmapResource( wxT( "save.xpm" ) ) ); wxBitmap itemtool21BitmapDisabled; itemToolBar->AddTool( ID_TOOL_SAVE, wxEmptyString, itemtool21Bitmap, itemtool21BitmapDisabled, wxITEM_NORMAL, _( "Save MDF file" ), wxEmptyString ); wxBitmap itemtool22Bitmap( itemFrame->GetBitmapResource( wxT( "filesaveas.xpm" ) ) ); wxBitmap itemtool22BitmapDisabled; itemToolBar->AddTool( ID_TOOL_UPLOAD, wxEmptyString, itemtool22Bitmap, itemtool22BitmapDisabled, wxITEM_NORMAL, _( "Upload MDF file" ), wxEmptyString ); wxBitmap itemtool23Bitmap( itemFrame->GetBitmapResource( wxT( "redo.xpm" ) ) ); wxBitmap itemtool23BitmapDisabled; itemToolBar->AddTool( ID_TOOL_DOWNLOAD, wxEmptyString, itemtool23Bitmap, itemtool23BitmapDisabled, wxITEM_NORMAL, _( "Upload MDF file" ), wxEmptyString ); itemToolBar->AddSeparator(); wxBitmap itemtool25Bitmap( itemFrame->GetBitmapResource( wxT( "New1.xpm" ) ) ); wxBitmap itemtool25BitmapDisabled; itemToolBar->AddTool( ID_TOOL_ADD_ITEM, wxEmptyString, itemtool25Bitmap, itemtool25BitmapDisabled, wxITEM_NORMAL, _( "Add MDF item" ), wxEmptyString ); wxBitmap itemtool26Bitmap( itemFrame->GetBitmapResource( wxT( "delete.xpm" ) ) ); wxBitmap itemtool26BitmapDisabled; itemToolBar->AddTool( ID_TOOL_REMOVE_ITEM, wxEmptyString, itemtool26Bitmap, itemtool26BitmapDisabled, wxITEM_NORMAL, _( "Remove MDF item" ), wxEmptyString ); itemToolBar->Realize(); itemBoxSizer->Add( itemToolBar, 0, wxGROW | wxALL, 5 ); m_mdfTree = new wxTreeCtrl; m_mdfTree->Create( itemPanel, ID_TREECTRL, wxDefaultPosition, wxSize( 400, 300 ), wxTR_HAS_BUTTONS | wxTR_FULL_ROW_HIGHLIGHT | wxTR_LINES_AT_ROOT | wxTR_ROW_LINES | wxTR_SINGLE ); itemBoxSizer->Add( m_mdfTree, 0, wxGROW | wxALL, 2 ); m_htmlInfoWnd = new wxHtmlWindow; m_htmlInfoWnd->Create( itemPanel, ID_HTMLWINDOW2, wxDefaultPosition, wxSize( 200, 150 ), wxHW_SCROLLBAR_AUTO | wxSUNKEN_BORDER | wxHSCROLL | wxVSCROLL ); m_htmlInfoWnd->SetPage( _( "<html><h4>No data</h4></html>" ) ); itemBoxSizer->Add( m_htmlInfoWnd, 0, wxGROW | wxALL, 5 ); // Connect events and objects m_mdfTree->Connect( ID_TREECTRL, wxEVT_LEFT_DOWN, wxMouseEventHandler( frmMDFEditor::OnLeftDown ), NULL, this ); m_mdfTree->Connect( ID_TREECTRL, wxEVT_LEFT_DCLICK, wxMouseEventHandler( frmMDFEditor::OnLeftDClick ), NULL, this ); wxImageList* itemImageList = new wxImageList( 16, 16, true, 5 ); { wxImage icon0( Home_xpm ); icon0.Rescale( 16, 16 ); itemImageList->Add( icon0 ); wxImage icon1( Folder_Add_xpm ); icon1.Rescale( 16, 16 ); itemImageList->Add( icon1 ); wxImage icon2( Info_xpm ); icon2.Rescale( 16, 16 ); itemImageList->Add( icon2 ); wxImage icon3( copy_xpm ); icon3.Rescale( 16, 16 ); itemImageList->Add( icon3 ); wxImage icon4( copy_xpm ); icon4.Rescale( 16, 16 ); itemImageList->Add( icon4 ); } m_mdfTree->AssignImageList( itemImageList ); addDefaultContent(); }