void SFTPTreeView::OnMenuNewFile(wxCommandEvent& event) { wxTreeListItems items; m_treeListCtrl->GetSelections(items); if(items.size() != 1) return; MyClientData* cd = GetItemData(items.at(0)); CHECK_PTR_RET(cd); if(!cd->IsFolder()) { return; } wxString defaultValue; static size_t s_untitledCounter = 0; defaultValue << "Untitled" << ++s_untitledCounter; wxString new_name = ::wxGetTextFromUser(_("Enter the new file name:"), _("New File"), defaultValue); if(!new_name.IsEmpty()) { wxString fullpath = cd->GetFullPath(); fullpath << "/" << new_name; wxTreeListItem fileItem = DoAddFile(items.at(0), fullpath); if(fileItem.IsOk()) { DoOpenFile(fileItem); } } }
void PHPWorkspaceView::OnOpenFile(wxCommandEvent& e) { wxTreeItemId item = DoGetSingleSelection(); if(item.IsOk() == false) return; DoOpenFile(item); }
VOID DIALOG_FileOpen(VOID) { OPENFILENAMEW openfilename; WCHAR szPath[MAX_PATH]; static const WCHAR szDefaultExt[] = { 't','x','t',0 }; static const WCHAR txt_files[] = { '*','.','t','x','t',0 }; ZeroMemory(&openfilename, sizeof(openfilename)); lstrcpyW(szPath, txt_files); openfilename.lStructSize = sizeof(openfilename); openfilename.hwndOwner = Globals.hMainWnd; openfilename.hInstance = Globals.hInstance; openfilename.lpstrFilter = Globals.szFilter; openfilename.lpstrFile = szPath; openfilename.nMaxFile = ARRAY_SIZE(szPath); openfilename.Flags = OFN_ENABLETEMPLATE | OFN_ENABLEHOOK | OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST | OFN_HIDEREADONLY | OFN_ENABLESIZING; openfilename.lpfnHook = OfnHookProc; openfilename.lpTemplateName = MAKEINTRESOURCEW(IDD_OFN_TEMPLATE); openfilename.lpstrDefExt = szDefaultExt; Globals.encOfnCombo = ENCODING_ANSI; Globals.bOfnIsOpenDialog = TRUE; if (GetOpenFileNameW(&openfilename)) DoOpenFile(openfilename.lpstrFile, Globals.encOfnCombo); }
VOID DIALOG_FileOpen(VOID) { OPENFILENAME openfilename; TCHAR szDir[MAX_PATH]; TCHAR szPath[MAX_PATH]; ZeroMemory(&openfilename, sizeof(openfilename)); GetCurrentDirectory(SIZEOF(szDir), szDir); if (Globals.szFileName[0] == 0) _tcscpy(szPath, txt_files); else _tcscpy(szPath, Globals.szFileName); openfilename.lStructSize = sizeof(openfilename); openfilename.hwndOwner = Globals.hMainWnd; openfilename.hInstance = Globals.hInstance; openfilename.lpstrFilter = Globals.szFilter; openfilename.lpstrFile = szPath; openfilename.nMaxFile = SIZEOF(szPath); openfilename.lpstrInitialDir = szDir; openfilename.Flags = OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST | OFN_HIDEREADONLY; openfilename.lpstrDefExt = szDefaultExt; if (GetOpenFileName(&openfilename)) { if (FileExists(openfilename.lpstrFile)) DoOpenFile(openfilename.lpstrFile); else AlertFileNotFound(openfilename.lpstrFile); } }
void HtMainFrame::OnRecentFilesSelected (wxCommandEvent &event) { int index = event.GetId() - history.GetBaseId(); wxString selFile = history.GetHistoryFile(index); DoOpenFile(selFile); }
/*********************************************************************** * HandleCommandLine * * Handle command line options * * ARGUMENTS: * - command line options passed to the program (as string): * char *cmdline * RETURNS: none */ static void HandleCommandLine(char *cmdline) { /* file name is passed in the command line */ if (*cmdline) { /* Remove double-quotes from filename */ /* Double-quotes are not allowed in Windows filenames */ if (cmdline[0] == '"') { char *wc; cmdline++; wc = cmdline; while (*wc && *wc != '"') wc++; *wc = 0; } if (FileExists(cmdline)) { DoOpenFile(cmdline); InvalidateRect(Globals.hMainWnd, NULL, false); } else { switch (AlertFileDoesNotExist(cmdline)) { case IDYES: SetFileName(cmdline); UpdateWindowCaption(); break; case IDNO: break; case IDCANCEL: DestroyWindow(Globals.hMainWnd); break; } } } }
/*********************************************************************** * NOTEPAD_OnDropFiles * * WM_DROPFILES window message handle function * * ARGUMENTS: * - handle of window: * HWND hWnd * - drop info: * HDROP hDrop * RETURNS: none */ static void NOTEPAD_OnDropFiles(HWND hWnd, HDROP hDrop) { char FileName[MAX_PATH]; //HANDLE hDrop = (HANDLE)wParam; DragQueryFile(hDrop, 0, FileName, ARRAY_SIZE(FileName)); DragFinish(hDrop); DoOpenFile(FileName); }
void PHPWorkspaceView::OnItemActivated(wxTreeEvent& event) { ItemData* itemData = DoGetItemData(event.GetItem()); if(itemData && itemData->IsFile()) { DoOpenFile(event.GetItem()); } else { event.Skip(); } }
void HtMainFrame::OnFileOpen (wxCommandEvent &WXUNUSED(event)) { wxFileDialog dialog(this, wxT("Escolha um arquivo"), wxT(""), wxT(""), _("All files (*.*)|*.*"), wxFD_OPEN | wxFD_FILE_MUST_EXIST); if (dialog.ShowModal() == wxID_OK) { wxString path = dialog.GetPath(); DoOpenFile(path); } }
void DatabaseExplorer::OnOpenWithDBE(clCommandEvent& e) { // get the file name e.Skip(); if(FileExtManager::IsFileType(e.GetFileName(), FileExtManager::TypeDatabase)) { e.Skip(false); // Open the databse file DoOpenFile(e.GetFileName()); } }
void DatabaseExplorer::OnOpenWithDBE(clCommandEvent& e) { // get the file name e.Skip(); const wxFileName& filename = e.GetFileName(); if(filename.GetExt() == wxT("erd")) { e.Skip(false); DoOpenFile(filename); } }
void NeatpadOpenFile(HWND hwnd, TCHAR *szFile) { TCHAR *name; // save current file's position! SaveFileData(g_szFileName, hwnd); _tcscpy(g_szFileName, szFile); name = _tcsrchr(g_szFileName, '\\'); _tcscpy(g_szFileTitle, name ? name+1 : szFile); DoOpenFile(hwnd, g_szFileName, g_szFileTitle); }
STDMETHODIMP CMonoDump::SetFileName(LPCOLESTR pszFileName,const AM_MEDIA_TYPE *pmt) { CString new_fn = CString(pszFileName); CString old_fn = filename; // try to open the file filename = new_fn; HRESULT hr = DoOpenFile(); DoCloseFile(); if (FAILED(hr)) { filename = old_fn; } return hr; }
void SFTPTreeView::OnItemActivated(wxTreeEvent& event) { event.Skip(); MyClientData* cd = GetItemData(event.GetItem()); CHECK_PTR_RET(cd); if(cd->IsFolder()) { wxTreeItemId item = event.GetItem(); if(m_treeCtrl->IsExpanded(item)) { m_treeCtrl->CallAfter(&wxTreeCtrl::Collapse, item); } else { m_treeCtrl->CallAfter(&wxTreeCtrl::Expand, item); } } else { DoOpenFile(cd->GetFullPath()); } }
static void HandleCommandLine(LPWSTR cmdline) { /* skip white space */ while (*cmdline == ' ') cmdline++; if (*cmdline) { /* file name is passed on the command line */ if (cmdline[0] == '"') { cmdline++; cmdline[lstrlenW(cmdline) - 1] = 0; } szFileTitle[0] = 0; GetFileTitleW(cmdline, szFileTitle, sizeof(szFileTitle)/sizeof(WCHAR)); DoOpenFile(cmdline); UpdateWindowCaption(); } }
void SFTPTreeView::DoLoadSession() { // Now that we have successfully opened the connection, try to load the last saved session for this account const SFTPSessionInfo& sess = GetSession(true); if(sess.IsOk()) { wxString msg; msg << _("Would you like to load the saved session for this account?"); wxStandardID ans = ::PromptForYesNoCancelDialogWithCheckbox(msg, "sftp-load-session-dlg"); if(ans == wxID_YES) { // we have a session for this account, load it // Load the files const std::vector<wxString>& files = sess.GetFiles(); std::for_each(files.begin(), files.end(), [&](const wxString& path) { DoOpenFile(path); }); const wxString& rootFolder = sess.GetRootFolder(); if(!rootFolder.IsEmpty()) { m_textCtrlQuickJump->ChangeValue(rootFolder); CallAfter(&SFTPTreeView::DoBuildTree, rootFolder); } } } }
/** * Start file open operation, mount volume when needed and according to file type * create file output stream or read directory content. * @return NS_OK when file or directory opened successfully, error code otherwise */ nsresult nsGIOInputStream::DoOpen() { nsresult rv; GError *error = nullptr; NS_ASSERTION(mHandle == nullptr, "already open"); mHandle = g_file_new_for_uri( mSpec.get() ); GFileInfo *info = g_file_query_info(mHandle, "standard::*", G_FILE_QUERY_INFO_NONE, nullptr, &error); if (error) { if (error->domain == G_IO_ERROR && error->code == G_IO_ERROR_NOT_MOUNTED) { // location is not yet mounted, try to mount g_error_free(error); if (NS_IsMainThread()) return NS_ERROR_NOT_CONNECTED; error = nullptr; rv = MountVolume(); if (rv != NS_OK) { return rv; } // get info again info = g_file_query_info(mHandle, "standard::*", G_FILE_QUERY_INFO_NONE, nullptr, &error); // second try to get file info from remote files after media mount if (!info) { g_warning("Unable to get file info: %s", error->message); rv = MapGIOResult(error); g_error_free(error); return rv; } } else { g_warning("Unable to get file info: %s", error->message); rv = MapGIOResult(error); g_error_free(error); return rv; } } // Get file type to handle directories and file differently GFileType f_type = g_file_info_get_file_type(info); if (f_type == G_FILE_TYPE_DIRECTORY) { // directory rv = DoOpenDirectory(); } else if (f_type != G_FILE_TYPE_UNKNOWN) { // file rv = DoOpenFile(info); } else { g_warning("Unable to get file type."); rv = NS_ERROR_FILE_NOT_FOUND; } if (info) g_object_unref(info); return rv; }
BOOL WINAPI SoundProc(HWND hwndDlg, WORD wMessage, WPARAM wParam, LPARAM lParam) { static HWND hSoundWaveDuring, hSoundWaveAfter, hFileText, hSoundEdit, hPlay, hBrowse; static UINT uMaxSoundRadioButton; /* upper boundary of uSoundButtonSelected */ switch (wMessage) { case WM_INITDIALOG: if (CanPlayWave()) { hSoundWaveDuring = GetDlgItem(hwndDlg, IDM_SOUND_WAVE_DURING); hSoundWaveAfter = GetDlgItem(hwndDlg, IDM_SOUND_WAVE_AFTER); hFileText = GetDlgItem(hwndDlg, IDM_SOUND_FILE_TEXT); hSoundEdit = GetDlgItem(hwndDlg, IDM_SOUND_EDIT); hPlay = GetDlgItem(hwndDlg, IDM_SOUND_PLAY); hBrowse = GetDlgItem(hwndDlg, IDM_SOUND_BROWSE); EnableWindow(hSoundWaveDuring, TRUE); EnableWindow(hSoundWaveAfter, TRUE); WinAssert(hFileText); EnableWindow(hFileText, TRUE); EnableWindow(hSoundEdit, TRUE); EnableWindow(hPlay, TRUE); EnableWindow(hBrowse, TRUE); SetDlgItemText(hwndDlg, IDM_SOUND_EDIT, lpumb->szSoundName); uMaxSoundRadioButton = IDM_SOUND_WAVE_AFTER; } else /* Can't play wave */ { uMaxSoundRadioButton = IDM_SOUND_BEEP; } uSoundButtonSelectedTmp = uSoundButtonSelected; /* initialize temp value */ CheckRadioButton(hwndDlg, IDM_SOUND_NONE, uMaxSoundRadioButton, uSoundButtonSelectedTmp); //#ifdef NEEDME CenterDialog(GetParent(hwndDlg), hwndDlg); //#endif return TRUE; case WM_COMMAND: switch (LOWORD(wParam)) { case IDM_SOUND_NONE: case IDM_SOUND_BEEP: case IDM_SOUND_WAVE_DURING: case IDM_SOUND_WAVE_AFTER: uSoundButtonSelectedTmp = LOWORD(wParam); CheckRadioButton(hwndDlg, IDM_SOUND_NONE, uMaxSoundRadioButton, uSoundButtonSelectedTmp); break; case IDM_SOUND_PLAY: GetDlgItemText(hwndDlg, IDM_SOUND_EDIT, lpumb->szSoundName, WIZUNZIP_MAX_PATH); #ifdef __BORLANDC__ #pragma warn -pro #endif #ifdef WIN32 (*lpSndPlaySound)((LPSTR)lpumb->szSoundName, NULL, SND_ASYNC|SND_NOSTOP); #else (*lpSndPlaySound)((LPSTR)lpumb->szSoundName, SND_ASYNC|SND_NOSTOP); #endif #ifdef __BORLANDC__ #pragma warn .pro #endif break; case IDM_SOUND_BROWSE: if (DoOpenFile(hwndDlg, lpumb->szSoundName)) { /* transfer to command window */ SetDlgItemText(hwndDlg, IDM_SOUND_EDIT, lpumb->szSoundName); } break; case IDOK: uSoundButtonSelected = uSoundButtonSelectedTmp; WritePrivateProfileString(szAppName, szSoundOptKey, SoundOptsTbl[uSoundButtonSelected-IDM_SOUND_NONE], szWizUnzipIniFile); GetDlgItemText(hwndDlg, IDM_SOUND_EDIT, lpumb->szSoundName, WIZUNZIP_MAX_PATH); WritePrivateProfileString(szAppName, szSoundNameKey, lpumb->szSoundName, szWizUnzipIniFile); EndDialog(hwndDlg, TRUE); break; case IDCANCEL: /* restore former value of sound file name */ GetPrivateProfileString(szAppName, szSoundNameKey, szDfltWaveFile, lpumb->szSoundName, WIZUNZIP_MAX_PATH, szWizUnzipIniFile); EndDialog(hwndDlg, FALSE); break; case IDM_SOUND_HELP: WinHelp(hwndDlg,szHelpFileName,HELP_CONTEXT, (DWORD)(HELPID_SOUND_OPTIONS)); break; } return TRUE; } return FALSE; }
static void HandleCommandLine(LPTSTR cmdline) { int opt_print=0; while (*cmdline == _T(' ') || *cmdline == _T('-') || *cmdline == _T('/')) { TCHAR option; if (*cmdline++ == _T(' ')) continue; option = *cmdline; if (option) cmdline++; while (*cmdline == _T(' ')) cmdline++; switch(option) { case 'p': case 'P': opt_print=1; break; } } if (*cmdline) { /* file name is passed in the command line */ LPCTSTR file_name = NULL; BOOL file_exists = FALSE; TCHAR buf[MAX_PATH]; if (cmdline[0] == _T('"')) { cmdline++; cmdline[lstrlen(cmdline) - 1] = 0; } file_name = cmdline; if (FileExists(file_name)) { file_exists = TRUE; } else if (!HasFileExtension(cmdline)) { static const TCHAR txt[] = _T(".txt"); /* try to find file with ".txt" extension */ if (!_tcscmp(txt, cmdline + _tcslen(cmdline) - _tcslen(txt))) { file_exists = FALSE; } else { _tcsncpy(buf, cmdline, MAX_PATH - _tcslen(txt) - 1); _tcscat(buf, txt); file_name = buf; file_exists = FileExists(file_name); } } if (file_exists) { DoOpenFile(file_name); InvalidateRect(Globals.hMainWnd, NULL, FALSE); if (opt_print) DIALOG_FilePrint(); } else { switch (AlertFileDoesNotExist(file_name)) { case IDYES: DoOpenFile(file_name); break; case IDNO: break; } } } }
/*********************************************************************** * * NOTEPAD_WndProc */ static LRESULT WINAPI NOTEPAD_WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch (msg) { case WM_CREATE: Globals.hMenu = GetMenu(hWnd); break; case WM_COMMAND: if (HIWORD(wParam) == EN_CHANGE || HIWORD(wParam) == EN_HSCROLL || HIWORD(wParam) == EN_VSCROLL) DIALOG_StatusBarUpdateCaretPos(); if ((HIWORD(wParam) == EN_CHANGE)) NOTEPAD_EnableSearchMenu(); NOTEPAD_MenuCommand(LOWORD(wParam)); break; case WM_DESTROYCLIPBOARD: /*MessageBox(Globals.hMainWnd, "Empty clipboard", "Debug", MB_ICONEXCLAMATION);*/ break; case WM_CLOSE: if (DoCloseFile()) { if (Globals.hFont) DeleteObject(Globals.hFont); DestroyWindow(hWnd); } break; case WM_QUERYENDSESSION: if (DoCloseFile()) { return 1; } break; case WM_DESTROY: SetWindowLongPtr(Globals.hEdit, GWLP_WNDPROC, (LONG_PTR)Globals.EditProc); SaveSettings(); PostQuitMessage(0); break; case WM_SIZE: { if (Globals.bShowStatusBar == TRUE && Globals.bWrapLongLines == FALSE) { RECT rcStatusBar; HDWP hdwp; if (!GetWindowRect(Globals.hStatusBar, &rcStatusBar)) break; hdwp = BeginDeferWindowPos(2); if (hdwp == NULL) break; hdwp = DeferWindowPos(hdwp, Globals.hEdit, NULL, 0, 0, LOWORD(lParam), HIWORD(lParam) - (rcStatusBar.bottom - rcStatusBar.top), SWP_NOZORDER | SWP_NOMOVE); if (hdwp == NULL) break; hdwp = DeferWindowPos(hdwp, Globals.hStatusBar, NULL, 0, 0, LOWORD(lParam), LOWORD(wParam), SWP_NOZORDER); if (hdwp != NULL) EndDeferWindowPos(hdwp); } else SetWindowPos(Globals.hEdit, NULL, 0, 0, LOWORD(lParam), HIWORD(lParam), SWP_NOZORDER | SWP_NOMOVE); break; } // The entire client area is covered by edit control and by // the status bar. So there is no need to erase main background. // This resolves the horrible fliker effect during windows resizes. case WM_ERASEBKGND: return 1; case WM_SETFOCUS: SetFocus(Globals.hEdit); break; case WM_DROPFILES: { TCHAR szFileName[MAX_PATH]; HDROP hDrop = (HDROP) wParam; DragQueryFile(hDrop, 0, szFileName, SIZEOF(szFileName)); DragFinish(hDrop); DoOpenFile(szFileName); break; } case WM_CHAR: case WM_INITMENUPOPUP: NOTEPAD_InitMenuPopup((HMENU)wParam, lParam); break; default: if (msg == aFINDMSGSTRING) { FINDREPLACE *pFindReplace = (FINDREPLACE *) lParam; Globals.find = *(FINDREPLACE *) lParam; if (pFindReplace->Flags & FR_FINDNEXT) NOTEPAD_FindNext(pFindReplace, FALSE, TRUE); else if (pFindReplace->Flags & FR_REPLACE) NOTEPAD_FindNext(pFindReplace, TRUE, TRUE); else if (pFindReplace->Flags & FR_REPLACEALL) NOTEPAD_ReplaceAll(pFindReplace); else if (pFindReplace->Flags & FR_DIALOGTERM) NOTEPAD_FindTerm(); break; } return DefWindowProc(hWnd, msg, wParam, lParam); } return 0; }
HtMainFrame::HtMainFrame (const wxString &title, const wxPoint &pos, const wxSize &size, long flags) : wxAuiMDIParentFrame(0, wxID_ANY, title, pos, size, flags | wxBORDER_NONE | wxFRAME_NO_WINDOW_MENU), history(9, HT_FileHistory_Base) { // logger logger = new wxLogWindow(this, wxT("Logger"), false); wxLog::SetActiveTarget(logger); aui_manager.SetManagedWindow(this); SetIcon(wxICON(hterminator)); HtArtProvider &art = wxGetApp().art_provider; art.Add(wxT("images/common.png"), HTArtId_Common, wxT("image/png"), true, wxSize(16, 15)); art.Add(wxT("images/main_tb.png"), HTArtId_MainTb, wxT("image/png"), true, wxSize(16, 16)); art.Add(wxT("images/view_tb.png"), HTArtId_ViewTb, wxT("image/png"), true, wxSize(16, 15)); art.Add(wxT("images/nav_tb.png"), HTArtId_NavTb, wxT("image/png"), true, wxSize(16, 15)); #if wxUSE_MENUS CreateMenu(art); #endif //~wxUSE_MENUS BookmarksPanel *bookmarks = new BookmarksPanel(this, wxID_ANY); wxAuiToolBar *tb_main = new wxAuiToolBar(this, HT_Toolbar_Main/*, wxDefaultPosition, wxDefaultSize, wxAUI_TB_DEFAULT_STYLE | wxAUI_TB_OVERFLOW*/); tb_main->SetToolBitmapSize(wxSize(16, 15)); tb_main->AddTool(HT_FileNew, _("New"), art.GetBitmap(HTArtId_MainTb, HTArt_New), _("New (Ctrl+N)")); tb_main->AddTool(HT_FileOpen, _("Open"), art.GetBitmap(HTArtId_MainTb, HTArt_Open), _("Open (Ctrl+O)")); tb_main->AddTool(HT_FileSave, _("Save"), art.GetBitmap(HTArtId_MainTb, HTArt_Save), _("Save (Ctrl+S)"))->SetDisabledBitmap(art.GetBitmap(HTArtId_MainTb, HTArt_SaveGr)); tb_main->AddSeparator(); tb_main->AddTool(HT_EditCut, _("Cut"), art.GetBitmap(HTArtId_MainTb, HTArt_Cut), _("Cut (Ctrl+X)"))->SetDisabledBitmap(art.GetBitmap(HTArtId_MainTb, HTArt_CutGr)); tb_main->AddTool(HT_EditCopy, _("Copy"), art.GetBitmap(HTArtId_MainTb, HTArt_Copy), _("Copy (Ctrl+C)"))->SetDisabledBitmap(art.GetBitmap(HTArtId_MainTb, HTArt_CopyGr)); tb_main->AddTool(HT_EditPaste, _("Paste"), art.GetBitmap(HTArtId_MainTb, HTArt_Paste), _("Paste (Ctrl+V)"))->SetDisabledBitmap(art.GetBitmap(HTArtId_MainTb, HTArt_PasteGr)); tb_main->AddSeparator(); tb_main->AddTool(HT_EditUndo, _("Undo"), art.GetBitmap(HTArtId_MainTb, HTArt_Undo), _("Undo (Ctrl+Z)"))->SetDisabledBitmap(art.GetBitmap(HTArtId_MainTb, HTArt_UndoGr)); tb_main->AddTool(HT_EditRedo, _("Redo"), art.GetBitmap(HTArtId_MainTb, HTArt_Redo), _("Redo (Ctrl+Y)"))->SetDisabledBitmap(art.GetBitmap(HTArtId_MainTb, HTArt_RedoGr)); tb_main->SetToolDropDown(HT_EditUndo, true); tb_main->SetToolDropDown(HT_FileOpen, true); tb_main->Realize(); wxAuiToolBar *tb_view = new wxAuiToolBar(this, HT_Toolbar_View/*, wxDefaultPosition, wxDefaultSize, wxAUI_TB_DEFAULT_STYLE | wxAUI_TB_OVERFLOW*/); wxChoice *tablelist = new wxChoice(tb_view, HT_Tool_TableList); tb_view->AddControl(tablelist, _("Table")); tb_view->AddTool(HT_ViewAddTable, _("Add Table"), art.GetBitmap(HTArtId_ViewTb, HTArt_AddTable), _("Add table")); tablelist->Append(wxT("ASCII default")); tablelist->SetSelection(0); wxAuiToolBar *tb_nav = new wxAuiToolBar(this, HT_Toolbar_Navigation/*, wxDefaultPosition, wxDefaultSize, wxAUI_TB_DEFAULT_STYLE | wxAUI_TB_OVERFLOW*/); tb_nav->SetToolBitmapSize(wxSize(16, 15)); tb_nav->AddTool(HT_EditFindForw, _("Find backward"), art.GetBitmap(HTArtId_NavTb, HTArt_SearchBack), _("Find Backward")); tb_nav->AddControl(new wxComboBox(tb_nav, HT_Tool_SearchBox, wxT(""), wxDefaultPosition, wxSize(200, 20))); tb_nav->AddTool(HT_EditFindBack, _("Find forward"), art.GetBitmap(HTArtId_NavTb, HTArt_SearchForw), _("Find Forward")); wxComboBox *jump_hex = new wxComboBox(tb_nav, HT_Tool_JumpHex, wxT(""), wxDefaultPosition, wxSize(115, 20)); jump_hex->SetForegroundColour(wxColor(128, 0, 0)); tb_nav->AddControl(jump_hex, _("Jump hex")); wxComboBox *jump_dec = new wxComboBox(tb_nav, HT_Tool_JumpDec, wxT(""), wxDefaultPosition, wxSize(140, 20)); //jump_dec->SetFont(wxFont(10, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL, false)); jump_dec->SetForegroundColour(wxColor(0, 0, 128)); tb_nav->AddControl(jump_dec, _("Jump decimal")); tb_nav->Realize(); aui_manager.AddPane(tb_main, wxAuiPaneInfo().ToolbarPane().Top().LeftDockable(false).RightDockable(false)); aui_manager.AddPane(tb_view, wxAuiPaneInfo().ToolbarPane().Top().Position(1).LeftDockable(false).RightDockable(false)); aui_manager.AddPane(tb_nav, wxAuiPaneInfo().ToolbarPane().Top().Row(1).LeftDockable(false).RightDockable(false)); aui_manager.AddPane(bookmarks, wxAuiPaneInfo().Right().PinButton().CloseButton().MinimizeButton().MinSize(150, 100) .BestSize(180, 100).FloatingSize(250, 200).Caption("Bookmarks").Name("bookmarks")); statusbar = new wxStatusBar(this, wxID_ANY, wxSB_FLAT); statusbar->SetFieldsCount(1); statusbar->PushStatusText(_("Ready")); SetStatusBar(statusbar); wxAuiMDIParentFrame::GetClientWindow()->Connect( wxEVT_COMMAND_AUINOTEBOOK_PAGE_CLOSE, wxAuiNotebookEventHandler(HtMainFrame::OnNotebookPageClose)); jump_hex->Connect(wxEVT_TEXT_ENTER, wxCommandEventHandler(HtMainFrame::OnJumpHexTextEnter)); //jump_hex->Connect(wxEVT_TEXT, wxCommandEventHandler(HtMainFrame::OnJumpHexTextEnter)); #ifdef WXDEBUG DebugPanel *debugPanel = new DebugPanel(this, HT_DebugPanel); aui_manager.AddPane(debugPanel, wxAuiPaneInfo().Right().PinButton().CloseButton().MinimizeButton() .MinSize(150, 100).BestSize(240, 100).FloatingSize(250, 200).Caption("Debug Info").Name("debug_pane")); aui_manager.GetPane("bookmarks").Hide(); wxAuiMDIParentFrame::GetClientWindow()->Connect( wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGED, wxAuiNotebookEventHandler(HtMainFrame::OnNotebookPageChange)); #endif aui_manager.Update(); // TEMP ----------------- //DoOpenFile(wxT("D:/Projects/ricardojricken/trunk/hexterminator/test/1452 - Metroid - Zero Mission (EU) (M5).gba")); DoOpenFile("test/1452 - Metroid - Zero Mission (EU) (M5).gba"); }
// // WM_COMMAND message handler for main window // UINT CommandHandler(HWND hwnd, UINT nCtrlId, UINT nCtrlCode, HWND hwndFrom) { RECT rect; switch(nCtrlId) { case IDM_FILE_NEW: // reset to an empty file SetWindowFileName(hwnd, _T("Untitled"), FALSE); TextView_Clear(g_hwndTextView); g_szFileTitle[0] = '\0'; g_fFileChanged = FALSE; return 0; case IDM_FILE_OPEN: // get a filename to open if(ShowOpenFileDlg(hwnd, g_szFileName, g_szFileTitle)) { DoOpenFile(hwnd, g_szFileName, g_szFileTitle); } return 0; case IDM_FILE_SAVE: MessageBox(hwnd, _T("Not implemented"), APP_TITLE, MB_ICONINFORMATION); return 0; case IDM_FILE_SAVEAS: // does nothing yet if(ShowSaveFileDlg(hwnd, g_szFileName, g_szFileTitle)) { MessageBox(hwnd, _T("Not implemented"), APP_TITLE, MB_ICONINFORMATION); } return 0; case IDM_FILE_PRINT: DeleteDC( ShowPrintDlg(hwnd) ); return 0; case IDM_FILE_EXIT: PostMessage(hwnd, WM_CLOSE, 0, 0); return 0; case IDM_EDIT_UNDO: case WM_UNDO: SendMessage(g_hwndTextView, WM_UNDO, 0, 0); return 0; case IDM_EDIT_REDO: SendMessage(g_hwndTextView, TXM_REDO, 0, 0); return 0; case IDM_EDIT_COPY: case WM_COPY: SendMessage(g_hwndTextView, WM_COPY, 0, 0); return 0; case IDM_EDIT_CUT: case WM_CUT: SendMessage(g_hwndTextView, WM_CUT, 0, 0); return 0; case IDM_EDIT_PASTE: case WM_PASTE: SendMessage(g_hwndTextView, WM_PASTE, 0, 0); return 0; case IDM_EDIT_DELETE: case WM_CLEAR: SendMessage(g_hwndTextView, WM_CLEAR, 0, 0); return 0; case IDM_EDIT_FIND: ShowFindDlg(hwnd, FIND_PAGE); return 0; case IDM_EDIT_REPLACE: ShowFindDlg(hwnd, REPLACE_PAGE); return 0; case IDM_EDIT_GOTO: ShowFindDlg(hwnd, GOTO_PAGE); return 0; case IDM_EDIT_SELECTALL: TextView_SelectAll(g_hwndTextView); return 0; case IDM_VIEW_OPTIONS: ShowOptions(hwnd); return 0; case IDM_VIEW_LINENUMBERS: g_fLineNumbers = !g_fLineNumbers; TextView_SetStyleBool(g_hwndTextView, TXS_LINENUMBERS, g_fLineNumbers); return 0; case IDM_VIEW_LONGLINES: g_fLongLines = !g_fLongLines; TextView_SetStyleBool(g_hwndTextView, TXS_LONGLINES, g_fLongLines); return 0; case IDM_VIEW_STATUSBAR: g_fShowStatusbar = !g_fShowStatusbar; ShowWindow(g_hwndStatusbar, SW_HIDE); GetClientRect(hwnd, &rect); PostMessage(hwnd, WM_SIZE, 0, MAKEWPARAM(rect.right, rect.bottom)); return 0; case IDM_VIEW_SAVEEXIT: g_fSaveOnExit = !g_fSaveOnExit; return 0; case IDM_VIEW_SAVENOW: SaveRegSettings(); return 0; case IDM_HELP_ABOUT: ShowAboutDlg(hwnd); return 0; default: return 0; } }
static VOID MainWndCommand(PMAIN_WND_INFO Info, WORD CmdId, HWND hControl) { static TCHAR szFileName[MAX_PATH]; static TCHAR szDocumentName[MAX_PATH]; UNREFERENCED_PARAMETER(hControl); switch (CmdId) { case ID_NEW: { OPEN_EDIT_INFO OpenInfo; INT Ret; OpenInfo.CreateNew = TRUE; LoadAndFormatString(hInstance, IDS_DEFAULT_NAME, &OpenInfo.lpDocumentName, ++Info->ImagesCreated); Ret = DialogBox(hInstance, MAKEINTRESOURCE(IDD_NEWDOCSEL), Info->hSelf, NewDocSelDlgProc); if (Ret != -1) { OpenInfo.DocType = Ret; CreateEditWindow(Info, &OpenInfo); } } break; case ID_BOLD: MessageBox(NULL, _T("Bingo"), NULL, 0); break; case ID_OPEN: { OPEN_EDIT_INFO OpenInfo; if (DoOpenFile(Info->hSelf, szFileName, /* full file path */ szDocumentName)) /* file name */ { OpenInfo.CreateNew = FALSE; OpenInfo.lpDocumentPath = szFileName; OpenInfo.lpDocumentName = szDocumentName; CreateEditWindow(Info, &OpenInfo); } } break; case ID_EXIT: SendMessage(Info->hSelf, WM_CLOSE, 0, 0); break; /* Window Menu */ case ID_WINDOW_TILE_HORZ: SendMessage(Info->hMdiClient, WM_MDITILE, MDITILE_HORIZONTAL, 0); break; case ID_WINDOW_TILE_VERT: SendMessage(Info->hMdiClient, WM_MDITILE, MDITILE_VERTICAL, 0); break; case ID_WINDOW_CASCADE: SendMessage(Info->hMdiClient, WM_MDICASCADE, 0, 0); break; case ID_WINDOW_ARRANGE: SendMessage(Info->hMdiClient, WM_MDIICONARRANGE, 0, 0); break; case ID_WINDOW_NEXT: SendMessage(Info->hMdiClient, WM_MDINEXT, 0, 0); break; /* Help Menu */ case ID_ABOUT: DialogBox(hInstance, MAKEINTRESOURCE(IDD_ABOUTBOX), Info->hSelf, AboutDialogProc); break; } }
void DlgFileExplorer::DoInitDialog() { connect(ui->Browser,SIGNAL(DoRefreshControls()),this,SLOT(RefreshControls())); connect(ui->Browser,SIGNAL(DoAddFiles()),this,SLOT(accept())); connect(ui->Browser,SIGNAL(DoOpenFile()),this,SLOT(OpenFile())); ui->Browser->DoInitDialog(); }
static LRESULT CALLBACK WndProc(HWND hwnd, UINT uMessage, WPARAM wparam, LPARAM lparam) { switch (uMessage) { case WM_PAINT: { PAINTSTRUCT ps; BeginPaint(hwnd, &ps); SetMapMode(ps.hdc, MM_ANISOTROPIC); /* Set the window extent to a sane value in case the metafile doesn't */ SetWindowExtEx(ps.hdc, width, height, NULL); SetViewportExtEx(ps.hdc, width, height, NULL); SetViewportOrgEx(ps.hdc, deltax, deltay, NULL); if (isEnhanced && enhmf) { RECT r; GetClientRect(hwnd, &r); PlayEnhMetaFile(ps.hdc, enhmf, &r); } else if (hmf) PlayMetaFile(ps.hdc, hmf); EndPaint(hwnd, &ps); } break; case WM_COMMAND: /* message: command from application menu */ switch (LOWORD(wparam)) { case IDM_OPEN: { WCHAR filename[MAX_PATH]; if (FileOpen(hwnd, filename, sizeof(filename)/sizeof(WCHAR))) { szFileTitle[0] = 0; GetFileTitleW(filename, szFileTitle, sizeof(szFileTitle)/sizeof(WCHAR)); DoOpenFile(filename); UpdateWindowCaption(); } } break; case IDM_SET_EXT_TO_WIN: { RECT r; GetClientRect(hwnd, &r); width = r.right - r.left; height = r.bottom - r.top; deltax = deltay = 0; InvalidateRect( hwnd, NULL, TRUE ); } break; case IDM_LEFT: deltax += 100; InvalidateRect( hwnd, NULL, TRUE ); break; case IDM_RIGHT: deltax -= 100; InvalidateRect( hwnd, NULL, TRUE ); break; case IDM_UP: deltay += 100; InvalidateRect( hwnd, NULL, TRUE ); break; case IDM_DOWN: deltay -= 100; InvalidateRect( hwnd, NULL, TRUE ); break; case IDM_EXIT: DestroyWindow(hwnd); break; default: return DefWindowProcW(hwnd, uMessage, wparam, lparam); } break; case WM_DESTROY: /* message: window being destroyed */ PostQuitMessage(0); break; default: /* Passes it on if unprocessed */ return DefWindowProcW(hwnd, uMessage, wparam, lparam); } return 0; }
INT_PTR CALLBACK GeneralDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { PINFO pInfo = (PINFO)GetWindowLongPtrW(hDlg, GWLP_USERDATA); switch (message) { case WM_INITDIALOG: GeneralOnInit(hDlg, (PINFO)lParam); return TRUE; case WM_COMMAND: { switch(LOWORD(wParam)) { case IDC_SERVERCOMBO: if (HIWORD(wParam) == CBN_SELCHANGE) { INT last, cur; cur = SendDlgItemMessageW(hDlg, IDC_SERVERCOMBO, CB_GETCURSEL, 0, 0); last = SendDlgItemMessageW(hDlg, IDC_SERVERCOMBO, CB_GETCOUNT, 0, 0); if ((cur + 1) == last) MessageBoxW(hDlg, L"SMB is not yet supported", L"RDP error", MB_ICONERROR); else { LoadUsernameHint(hDlg, cur); } } break; case IDC_SAVE: SaveAllSettings(pInfo); SaveRdpSettingsToFile(NULL, pInfo->pRdpSettings); break; case IDC_SAVEAS: DoSaveAs(pInfo); break; case IDC_OPEN: DoOpenFile(pInfo); break; } break; } case WM_CLOSE: { if (pInfo->hLogon) DestroyIcon(pInfo->hLogon); if (pInfo->hConn) DestroyIcon(pInfo->hConn); break; } } return 0; }
HRESULT CMonoDump::OnStartStreaming() { return DoOpenFile(); }
// ---------------------------------------------------------------------------- bool ThreadSearchFrame::OpenGeneric(const wxString& filename, bool addToHistory) // ---------------------------------------------------------------------------- { if (filename.IsEmpty()) return false; // Split the window to show notebook and file panel //(pecan 2008/5/19) if (not GetConfig()->GetThreadSearchPlugin() ) return false; GetConfig()->GetThreadSearchPlugin()->SplitThreadSearchWindow(); wxFileName fname(filename); fname.ClearExt(); fname.SetExt(_T("cbp")); switch(FileTypeOf(filename)) { // // Workspace // ////case ftCodeBlocksWorkspace: //// // verify that it's not the same as the one already open //// if (filename != Manager::Get()->GetProjectManager()->GetWorkspace()->GetFilename() && //// DoCloseCurrentWorkspace()) //// { //// wxBusyCursor wait; // loading a worspace can take some time -> showhourglass //// bool ret = Manager::Get()->GetProjectManager()->LoadWorkspace(filename); //// if (ret && addToHistory) //// AddToRecentProjectsHistory(Manager::Get()->GetProjectManager()->GetWorkspace()->GetFilename()); //// return ret; //// } //// else //// return false; //// break; // // Project // ////case ftCodeBlocksProject: ////{ //// // Make a check whether the project exists in current workspace //// cbProject* prj = Manager::Get()->GetProjectManager()->IsOpen(fname.GetFullPath()); //// if (!prj) //// { //// wxBusyCursor wait; // loading a worspace can take some time -> showhourglass //// return DoOpenProject(filename, addToHistory); //// } //// else //// { //// // NOTE (Morten#1#): A message here will prevent batch-builds from working and is shown sometimes even if correct //// Manager::Get()->GetProjectManager()->SetProject(prj, false); //// return true; //// } ////} // // Source files // case ftHeader: // fallthrough case ftSource: // fallthrough case ftResource: return DoOpenFile(filename, addToHistory); // // For all other files, ask MIME plugin for a suitable handler // default: { ////cbMimePlugin* plugin = Manager::Get()->GetPluginManager()->GetMIMEHandlerForFile(filename); ////// warn user that "Files extension handler" is disabled ////if (!plugin) ////{ //// cbMessageBox(_("Could not open file ") + filename + _(",\nbecause no extension handler could be found."), _("Error"), wxICON_ERROR); //// return false; ////} ////if (plugin->OpenFile(filename) == 0) ////{ //// AddToRecentFilesHistory(filename); //// return true; ////} ////return false; return DoOpenFile(filename, addToHistory); //(pecan 2008/3/15) }//default } return true; }
int DefaultMimeHandler::OpenFile(const wxString& filename) { wxFileName the_file(filename); cbMimeType* mt = FindMimeTypeFor(filename); if (mt) return DoOpenFile(mt, filename); else if (the_file.GetExt().CmpNoCase(_T("htm")) == 0 || the_file.GetExt().CmpNoCase(_T("html")) == 0) { // embedded help viewer (unless the user has added an explicit association manually) m_Html->Open(filename); CodeBlocksDockEvent evt(cbEVT_SHOW_DOCK_WINDOW); evt.pWindow = m_Html; Manager::Get()->ProcessEvent(evt); return 0; } else { // not yet supported. ask the user how to open it. wxString choices[3] = {_("Select an external program to open it"), _("Open it with the associated application"), _("Open it inside the Em::Blocks editor")}; wxSingleChoiceDialog dlg(Manager::Get()->GetAppWindow(), _("Em::Blocks does not yet know how to open this kind of file.\n" "Please select what you want to do with it:"), _("What to do?"), sizeof(choices) / sizeof(choices[0]), choices); dlg.SetSelection(0); PlaceWindow(&dlg); int answer = dlg.ShowModal(); if (answer == wxID_OK) { wxString ext = the_file.GetExt().Lower(); wxString wild = ext.IsEmpty() ? the_file.GetName().Lower() : wxString(_T("*.")) + ext; switch (dlg.GetSelection()) { case 0: // choose external program { wxString prg = ChooseExternalProgram(); if (!prg.IsEmpty()) { mt = new cbMimeType; mt->wildcard = wild; mt->useEditor = false; mt->useAssoc = false; mt->program = prg; mt->programIsModal = cbMessageBox(_("Do you want Em::Blocks to be disabled while the external program is running?"), _("Question"), wxICON_QUESTION | wxYES_NO) == wxID_YES; m_MimeTypes.Add(mt); return DoOpenFile(mt, filename); } break; } case 1: // open with associated app mt = new cbMimeType; mt->wildcard = wild; mt->useEditor = false; mt->useAssoc = true; m_MimeTypes.Add(mt); return DoOpenFile(mt, filename); break; case 2: // open in editor { mt = new cbMimeType; mt->wildcard = wild; mt->useEditor = true; mt->useAssoc = false; m_MimeTypes.Add(mt); return DoOpenFile(mt, filename); break; } default: break; } } else if (answer == wxID_CANCEL) { return 0; // Cancel is interpreted as success, too } else { return -1; } } return -1; }