Example #1
0
// The `main program' equivalent, creating the windows and returning the
// main frame
bool MyApp::OnInit()
{
  // Create the main frame window
  main_frame = new MyMainFrame((wxFrame *) NULL, wxID_ANY, _T("wxFrame sample"),
     wxPoint(100, 100), wxSize(300, 200));

  main_frame->CreateToolBar(wxNO_BORDER|wxTB_VERTICAL, ID_TOOLBAR);
  InitToolbar(main_frame->GetToolBar());

  button = new wxButton( main_frame, ID_REPARENT, _T("Press to reparent!") );

  // Create the mini frame window
  mini_frame = new MyMiniFrame( main_frame, wxID_ANY, _T("wxMiniFrame sample"),
     wxPoint(100, 100), wxSize(220, 100));
  mini_frame_exists = true;

  mini_frame->CreateToolBar(wxNO_BORDER|wxTB_HORIZONTAL|wxTB_FLAT, ID_TOOLBAR);
  InitToolbar(mini_frame->GetToolBar());

  main_frame->SetIcon(wxICON(mondrian));
  mini_frame->SetIcon(wxICON(mondrian));

  SetTopWindow(main_frame);

  main_frame->Show(true);
  mini_frame->Show(true);

  return true;
}
Example #2
0
// The `main program' equivalent, creating the windows and returning the
// main frame
bool MyApp::OnInit()
{
  // Create the main frame window
  main_frame = new MyMainFrame((wxFrame *) NULL, wxID_ANY, _T("wxFrame sample"),
     wxPoint(100, 100), wxSize(300, 200));

  main_frame->SetSizeHints( 100,100, 400,400 );

  wxMenu *file_menu = new wxMenu;
  file_menu->Append(wxID_EXIT, _T("E&xit\tAlt-Q"));
  file_menu->Append(ID_SET_SIZE_TO_150_150, _T("Set frame size to 150,150\tF2"));
  file_menu->Append(ID_SET_SIZE_TO_200_200, _T("Set frame size to 200,200\tF3"));
  file_menu->Append(ID_SET_MAX_SIZE_TO_150_150, _T("Set frame max size to 150,150\tF4"));
  file_menu->Append(ID_SET_MAX_SIZE_TO_300_300, _T("Set frame max size to 300,300\tF5"));
  
  wxMenuBar *menu_bar = new wxMenuBar;
  menu_bar->Append(file_menu, _T("&File"));
  main_frame->SetMenuBar(menu_bar);

  main_frame->Connect( ID_SET_SIZE_TO_150_150,  wxID_ANY,
                    wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MyMainFrame::OnSetSize_150_150) );
  main_frame->Connect( ID_SET_SIZE_TO_200_200, wxID_ANY,
                    wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MyMainFrame::OnSetSize_200_200) );
  main_frame->Connect( ID_SET_MAX_SIZE_TO_150_150,  wxID_ANY,
                    wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MyMainFrame::OnSetMaxSize_150_150) );
  main_frame->Connect( ID_SET_MAX_SIZE_TO_300_300, wxID_ANY,
                    wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MyMainFrame::OnSetMaxSize_300_300) );

  main_frame->CreateToolBar(wxNO_BORDER|wxTB_VERTICAL, ID_TOOLBAR);
  InitToolbar(main_frame->GetToolBar());

  button = new wxButton( main_frame, ID_REPARENT, _T("Press to reparent!") );

  // Create the mini frame window
  mini_frame = new MyMiniFrame( main_frame, wxID_ANY, _T("wxMiniFrame sample"),
     wxPoint(100, 100), wxSize(220, 100));
  mini_frame_exists = true;

  mini_frame->CreateToolBar(wxNO_BORDER|wxTB_HORIZONTAL|wxTB_FLAT, ID_TOOLBAR);
  InitToolbar(mini_frame->GetToolBar());

  main_frame->SetIcon(wxICON(mondrian));
  mini_frame->SetIcon(wxICON(mondrian));

  SetTopWindow(main_frame);

  main_frame->Show(true);
  mini_frame->Show(true);

  return true;
}
Ihandle* InitDialog(void)
{
  Ihandle* dialog;   /* dialog containing the canvas */
  Ihandle* content;  /* dialog content */

  Ihandle* toolbar=InitToolbar();                                                 /* buttons tool bar */
  gc.canvas = IupSGLCanvas(640,480,(Icallback) repaint_cb, (Icallback) resize_cb);   /* canvas to paint with OpenGL */ 
  gc.msgbar = IupSMessageBar("Message...",20);     /* a msg bar */

  content = IupVbox(toolbar,gc.canvas,gc.msgbar,NULL);

  /* create the dialog and set its attributes */
  dialog = IupSDialog("Trabalho 1 - Nino",content, (Icallback) exit_cb, "NO");
 
  return dialog;
}
Example #4
0
LRESULT HexEdit_OnNotify(MAINWND *mainWnd, HWND hwnd, UINT idCtrl, NMHDR *hdr)
{
    HWND hwndHV = GetActiveHexView(hwnd);

    if(hdr->hwndFrom == mainWnd->hwndTabView)
    {
        TCITEM tci = { TCIF_PARAM };

        TabCtrl_GetItem(mainWnd->hwndTabView, TabCtrl_GetCurSel(mainWnd->hwndTabView), &tci);

        // has the user clicked a file-tab?
        if(hdr->code == TCN_SELCHANGE)
        {
            HexSetCurFile(hwnd, TabCtrl_GetCurSel(mainWnd->hwndTabView), TRUE);

            OnFileChange(mainWnd);
            return 0;
        }
        else if(hdr->code == TCN_CLOSING)
        {
            // prompt close if
            if(HexFileCloseNotify(hwnd, hwndHV) == IDCANCEL)
                return TRUE;

            return 0;
        }
        else if(hdr->code == TCN_CLOSE)
        {
            // ask user if they want to save changes
            if(HexFileCloseNotify(hwnd, hwndHV) == IDCANCEL)
                return 0;

            //SetCurFile(hwnd, TabCtrl_GetCurSel(mainWnd->hwndTabView));
            //DestroyWindow((HWND)tci.lParam);
            HexCloseFile(mainWnd, TabCtrl_GetCurSel(mainWnd->hwndTabView));
            return 0;
        }
    }

    // double-click in a statusbar pane?
    if(hdr->hwndFrom == mainWnd->hwndStatusBar && hdr->code == NM_DBLCLK)
    {
        NMMOUSE *nmmouse;

        // statusbar is the only window at present which sends double-clicks
        nmmouse = (NMMOUSE *)hdr;

        // toggle the Readonly/Insert/Overwrite mode
        if(nmmouse->dwItemSpec == 4)
        {
            ToggleEditorMode(hwndHV);
            UpdateStatusBarText(mainWnd->hwndStatusBar, hwndHV);
        }

        return 0;
    }

    if(hdr->code == TBN_DROPDOWN)
    {
        if(GetParent(hdr->hwndFrom) == mainWnd->hwndStatusBar)
        {
            StatusBar_DropDownTB(mainWnd, hwndHV, (NMTOOLBAR *)hdr);
        }

        if(hdr->hwndFrom == mainWnd->hwndToolbar)
        {
            HexPasteSpecialDlg2(hwnd);
        }

        return 0;
    }

    /*	if(hdr->code == DWN_ISDOCKABLE)
    	{
    		RECT rc1, rc2;

    		// Get main window "outer" rectangle
    		GetWindowRect(hwnd, &rc1);

    		// Get main window "inner" rectangle
    		GetClientRect(hwnd, &rc2);
    		MapWindowPoints(hwnd, 0, (POINT *)&rc2, 2);
    		InflateRect(&rc2, -2, -2);

    		return DockWnd_GetDockSide(hwnd, (NMDOCKWNDQUERY *)hdr, &rc1, &rc2);
    	}*/

    if(hdr->code == DWN_SAVESETTINGS)
    {
        NMDOCKWNDCREATE *nmdw = (NMDOCKWNDCREATE *)hdr;

        TRACEA("  DWN_SAVESETTINGS: %d\n", nmdw->uId);

        switch(nmdw->hdr.idFrom)
        {
        case DWID_TYPEVIEW:
        case DWID_ALLTYPES:
            SaveTypeView(nmdw->hwndClient, nmdw->hKey);
            break;
        }

        return 0;
    }

    if(hdr->code == DWN_UPDATE_CONTENT)
    {
        NMDOCKWND *nmdw = (NMDOCKWND *)hdr;

        HWND hwndHV = GetActiveHexView(hwnd);

        switch(nmdw->hdr.idFrom)
        {
        case DWID_HIGHLIGHT:
            UpdateHighlights(TRUE);
            break;
        }

        return 0;
    }

    if(hdr->code == DWN_CREATE_CONTENT)
    {
        NMDOCKWNDCREATE *nmdw = (NMDOCKWNDCREATE *)hdr;

        TRACEA("DWN_CREATE_CONTENT: %d\n", hdr->idFrom);

        switch(nmdw->hdr.idFrom)
        {
        case DWID_TOOLBAR:
            mainWnd->hwndToolbar = InitToolbar(hdr->hwndFrom);
            return (LONG)mainWnd->hwndToolbar;

        case DWID_SEARCHBAR:
            return (LONG)CreateSearchBar(hdr->hwndFrom);

        case DWID_ALLTYPES:
            //SendMessage(hwndTB, TB_SETSTATE, IDM_TOOLS_TYPEVIEW, DockWnd_IsOpen(g_hwndMain, DWID_TYPEVIEW) ? TBSTATE_CHECKED|TBSTATE_ENABLED : TBSTATE_ENABLED);
            return (LONG)CreateTypeView(hdr->hwndFrom, nmdw->hKey, TRUE);//TEXT("struct ALL"));

        case DWID_TYPEVIEW:
            //SendMessage(hwndTB, TB_SETSTATE, IDM_TOOLS_TYPEVIEW, DockWnd_IsOpen(g_hwndMain, DWID_TYPEVIEW) ? TBSTATE_CHECKED|TBSTATE_ENABLED : TBSTATE_ENABLED);
            return (LONG)CreateTypeView(hdr->hwndFrom, nmdw->hKey, 0);

        case DWID_HIGHLIGHT:
            return (LONG)CreateHighlightView(hdr->hwndFrom);

        case DWID_STRINGS:
            return (LONG)CreateStringsView(hdr->hwndFrom);
        }
    }
    else if(hdr->code == DWN_DOCKCHANGE)
    {
        NMDOCKWND *nmdw = (NMDOCKWND *)hdr;

        switch(nmdw->hdr.idFrom)
        {
        case DWID_TOOLBAR:
            SendMessage(DockWnd_GetContents(mainWnd->hwndMain, DWID_TOOLBAR),
                        TB_SETPARENT, (WPARAM)hdr->hwndFrom, 0);

            return 0;
        }
    }
    else if(hdr->code == DWN_CLOSING)
    {
        NMDOCKWND *nmdw = (NMDOCKWND *)hdr;

        switch(nmdw->hdr.idFrom)
        {
        case DWID_TYPEVIEW:
            break;
        }
        return 0;
    }

    return DefWindowProc(hwnd, WM_NOTIFY, idCtrl, (LONG)hdr);
}
Example #5
0
/**
 * @brief Initializes main window.
 */
MainFrame::MainFrame()
    :wxFrame(NULL,wxID_ANY,wxT("UltraDefrag"))
{
    g_mainFrame = this;
    m_vList = NULL;
    m_cMap = NULL;
    m_currentJob = NULL;
    m_busy = false;
    m_paused = false;

    // set main window icon
    SetIcons(wxICON(appicon));

    // read configuration
    ReadAppConfiguration();
    ProcessCommandEvent(ID_ReadUserPreferences);

    // set main window title
    wxString *instdir = new wxString();
    //genBTC re-arranged the below, A LOT.
    wxStandardPaths stdpaths;
    wxFileName exepath(stdpaths.GetExecutablePath());
    wxString cd = exepath.GetPath();
    if((wxGetEnv(wxT("UD_INSTALL_DIR"),instdir))&&(cd.CmpNoCase(*instdir) == 0)) {
        itrace("current directory matches installation location, so it isn't portable");
        itrace("installation location: %ls",instdir->wc_str());
        m_title = new wxString(wxT(VERSIONINTITLE));
    } else {
        itrace("current directory differs from installation location, so it is portable");
        itrace("current directory: %ls",cd.wc_str());
        wxSetEnv(wxT("UD_IS_PORTABLE"),wxT("1"));
        m_title = new wxString(wxT(VERSIONINTITLE_PORTABLE));
    }
    //genBTC re-arranged the above, A LOT.
    ProcessCommandEvent(ID_SetWindowTitle);
    delete instdir;

    // set main window size and position
    SetSize(m_width,m_height);
    if(!m_saved){
        CenterOnScreen();
        GetPosition(&m_x,&m_y);
    }
    Move(m_x,m_y);
    if(m_maximized) Maximize(true);

    SetMinSize(wxSize(DPI(MAIN_WINDOW_MIN_WIDTH),DPI(MAIN_WINDOW_MIN_HEIGHT)));

    // create menu, tool and status bars
    InitMenu(); InitToolbar(); InitStatusBar();

	//make sizer1 to hold the the tabbed "notebook". And make the notebook
	wxBoxSizer* bSizer1;
	bSizer1 = new wxBoxSizer( wxVERTICAL );
	m_notebook1 = new wxNotebook( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );

	//make a panel inside the notebook to hold the m_splitter
	m_panel1 = new wxPanel( m_notebook1, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );

    // create list of volumes and cluster map (with splitter as parent)
    m_splitter = new wxSplitterWindow(m_panel1,wxID_ANY, wxDefaultPosition,wxDefaultSize, 
                                      wxSP_3D | wxCLIP_CHILDREN);
    m_splitter->SetMinimumPaneSize(DPI(MIN_PANEL_HEIGHT));

    m_vList = new DrivesList(m_splitter,wxLC_REPORT | wxLC_NO_SORT_HEADER | 
                             wxLC_HRULES | wxLC_VRULES | wxBORDER_NONE);

    m_cMap = new ClusterMap(m_splitter);

    m_splitter->SplitHorizontally(m_vList,m_cMap);

    int height = GetClientSize().GetHeight();
    int maxPanelHeight = height - DPI(MIN_PANEL_HEIGHT) - m_splitter->GetSashSize();
    if(m_separatorPosition < DPI(MIN_PANEL_HEIGHT)) m_separatorPosition = DPI(MIN_PANEL_HEIGHT);
    else if(m_separatorPosition > maxPanelHeight) m_separatorPosition = maxPanelHeight;
    m_splitter->SetSashPosition(m_separatorPosition);

    // update frame layout so we'll be able to initialize
    // list of volumes and cluster map properly
    wxSizeEvent evt(wxSize(m_width,m_height));
    ProcessEvent(evt); m_splitter->UpdateSize();

    InitVolList();
    m_vList->SetFocus();

    // populate list of volumes
    m_listThread = new ListThread();

    //make sizer2 to Fit the splitter, and initialize it.
	wxBoxSizer* bSizer2;
	bSizer2 = new wxBoxSizer( wxVERTICAL );
	bSizer2->Add( m_splitter, 1, wxEXPAND, 1 );
	m_panel1->SetSizer( bSizer2 );

	//Finish Tab1 - Add the Panel1(Splitter+sizer2) to the notebook.
	m_notebook1->AddPage( m_panel1, wxT("Drives"), false );

	//make a 2nd panel inside the notebook to hold the 2nd page(a grid)
	m_panel2 = new wxPanel( m_notebook1, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );

    m_filesList = new FilesList(m_panel2,wxLC_REPORT /* | wxLC_SINGLE_SEL  | wxLC_NO_SORT_HEADER*/ \
                                        | wxLC_VIRTUAL | wxLC_HRULES | wxLC_VRULES | wxBORDER_NONE);
    InitFilesList();

	//make sizer3 to Fit the page2list, and initialize it.
	wxBoxSizer* bSizer3;
	bSizer3 = new wxBoxSizer( wxVERTICAL );
	bSizer3->Add( m_filesList, 1, wxEXPAND, 1 );
	m_panel2->SetSizer( bSizer3 );
    bSizer3->Fit( m_panel2 );

	//Finish Tab 2 - Add the Panel2(page2list+sizer3) to the notebook.
	m_notebook1->AddPage( m_panel2, wxT("Files"), false );

    //Finish Notebook & initialize
	bSizer1->Add( m_notebook1, 1, wxEXPAND, 1 );
	this->SetSizer( bSizer1 );

    // check the boot time defragmenter presence
    wxFileName btdFile(wxT("%SystemRoot%\\system32\\defrag_native.exe"));
    btdFile.Normalize();
    bool btd = btdFile.FileExists();
    m_menuBar->FindItem(ID_BootEnable)->Enable(btd);
    m_menuBar->FindItem(ID_BootScript)->Enable(btd);
    m_toolBar->EnableTool(ID_BootEnable,btd);
    m_toolBar->EnableTool(ID_BootScript,btd);
    if(btd && ::winx_bootex_check(L"defrag_native") > 0){
        m_menuBar->FindItem(ID_BootEnable)->Check(true);
        m_toolBar->ToggleTool(ID_BootEnable,true);
        m_btdEnabled = true;
    } else {
        m_btdEnabled = false;
    }

    // launch threads for time consuming operations
    m_btdThread = btd ? new BtdThread() : NULL;
    m_configThread = new ConfigThread();
    m_crashInfoThread = new CrashInfoThread();

    wxConfigBase *cfg = wxConfigBase::Get();
    int ulevel = (int)cfg->Read(wxT("/Upgrade/Level"),1);
    wxMenuItem *item = m_menuBar->FindItem(ID_HelpUpgradeNone + ulevel);
    if(item) item->Check();

    m_upgradeThread = new UpgradeThread(ulevel);

    // set system tray icon
    m_systemTrayIcon = new SystemTrayIcon();
    if(!m_systemTrayIcon->IsOk()){
        etrace("system tray icon initialization failed");
        wxSetEnv(wxT("UD_MINIMIZE_TO_SYSTEM_TRAY"),wxT("0"));
    }
    SetSystemTrayIcon(wxT("tray"),wxT("UltraDefrag"));

    // set localized text
    ProcessCommandEvent(ID_LocaleChange + g_locale->GetLanguage());

    // allow disk processing
    m_jobThread = new JobThread();

    //create query thread to perform queries without blocking the GUI
    //(sort of like jobs) - may not be good to have both possibly running at once.
    //Create Query Tab, Tab #3.
    InitQueryMenu();
    
    UD_DisableTool(ID_Stop);    //change stop icon to be not always enabled.
}
Example #6
0
FrameMain::FrameMain()
: wxFrame(nullptr, -1, "", wxDefaultPosition, wxSize(920,700), wxDEFAULT_FRAME_STYLE | wxCLIP_CHILDREN)
, context(agi::util::make_unique<agi::Context>())
{
	StartupLog("Entering FrameMain constructor");

#ifdef __WXGTK__
	// XXX HACK XXX
	// We need to set LC_ALL to "" here for input methods to work reliably.
	setlocale(LC_ALL, "");

	// However LC_NUMERIC must be "C", otherwise some parsing fails.
	setlocale(LC_NUMERIC, "C");
#endif
#ifdef __APPLE__
	// When run from an app bundle, LC_CTYPE defaults to "C", which breaks on
	// anything involving unicode and in some cases number formatting.
	// The right thing to do here would be to query CoreFoundation for the user's
	// locale and add .UTF-8 to that, but :effort:
	LOG_D("locale") << setlocale(LC_ALL, nullptr);
	setlocale(LC_CTYPE, "en_US.UTF-8");
	LOG_D("locale") << setlocale(LC_ALL, nullptr);
#endif

	StartupLog("Initializing context models");
	memset(context.get(), 0, sizeof(*context));
	context->ass = new AssFile;

	StartupLog("Initializing context controls");
	context->subsController = new SubsController(context.get());
	context->ass->AddCommitListener(&FrameMain::UpdateTitle, this);
	context->subsController->AddFileOpenListener(&FrameMain::OnSubtitlesOpen, this);
	context->subsController->AddFileSaveListener(&FrameMain::UpdateTitle, this);

	context->audioController = new AudioController(context.get());
	context->audioController->AddAudioOpenListener(&FrameMain::OnAudioOpen, this);
	context->audioController->AddAudioCloseListener(&FrameMain::OnAudioClose, this);

	context->local_scripts = new Automation4::LocalScriptManager(context.get());

	// Initialized later due to that the selection controller is currently the subtitles grid
	context->selectionController = nullptr;

	context->videoController = VideoContext::Get(); // derp
	context->videoController->AddVideoOpenListener(&FrameMain::OnVideoOpen, this);

	StartupLog("Initializing context frames");
	context->parent = this;
	context->previousFocus = nullptr;

	StartupLog("Install PNG handler");
	wxImage::AddHandler(new wxPNGHandler);
#ifndef __APPLE__
	wxSafeYield();
#endif

	StartupLog("Apply saved Maximized state");
	if (OPT_GET("App/Maximized")->GetBool()) Maximize(true);

	StartupLog("Initialize toolbar");
	InitToolbar();

	StartupLog("Initialize menu bar");
	menu::GetMenuBar("main", this, context.get());

	StartupLog("Create status bar");
	CreateStatusBar(2);

	StartupLog("Set icon");
#ifdef _WIN32
	SetIcon(wxICON(wxicon));
#else
	wxIcon icon;
	icon.CopyFromBitmap(GETIMAGE(wxicon));
	SetIcon(icon);
#endif

	StartupLog("Create views and inner main window controls");
	context->dialog = new DialogManager;
	InitContents();
	OPT_SUB("Video/Detached/Enabled", &FrameMain::OnVideoDetach, this, agi::signal::_1);

	StartupLog("Complete context initialization");
	context->videoController->SetContext(context.get());

	StartupLog("Set up drag/drop target");
	SetDropTarget(new AegisubFileDropTarget(this));

	StartupLog("Load default file");
	context->subsController->Close();

	StartupLog("Display main window");
	AddFullScreenButton(this);
	Show();
	SetDisplayMode(1, 1);

	// Version checker
	StartupLog("Possibly perform automatic updates check");
	if (OPT_GET("App/First Start")->GetBool()) {
		OPT_SET("App/First Start")->SetBool(false);
#ifdef WITH_UPDATE_CHECKER
		int result = wxMessageBox(_("Do you want Aegisub to check for updates whenever it starts? You can still do it manually via the Help menu."),_("Check for updates?"), wxYES_NO | wxCENTER);
		OPT_SET("App/Auto/Check For Updates")->SetBool(result == wxYES);
		config::opt->Flush();
#endif
	}

#ifdef WITH_UPDATE_CHECKER
	PerformVersionCheck(false);
#endif

	Bind(FILE_LIST_DROPPED, &FrameMain::OnFilesDropped, this);

	StartupLog("Leaving FrameMain constructor");
}