void ValueCurveButton::RenderNewBitmap() {
    int sz = 24;
    if (GetContentScaleFactor() > 1.9) {
        sz *= GetContentScaleFactor();
    }
    wxBitmap bmp(sz, sz);
    
    wxMemoryDC dc(bmp);
    dc.SetBrush(*wxLIGHT_GREY_BRUSH);
    dc.DrawRectangle(0, 0, sz - 1, sz - 1);
    dc.SetPen(*wxBLACK_PEN);
    float lastY = sz - 1 - (GetValue()->GetValueAt(0)) * sz;
    
    for (int x = 1; x < sz; x++) {
        float x1 = x;
        x1 /= sz;
        float y = (GetValue()->GetValueAt(x1)) * sz;
        y = sz - 1 - y;
        dc.DrawLine(x - 1, lastY, x, y);
        lastY = y;
    }
    if (GetContentScaleFactor() > 1.9) {
        SetBitmap(wxBitmap(bmp.ConvertToImage(), -1, GetContentScaleFactor()));
    } else {
        SetBitmap(bmp);
    }
}
void DragEffectBitmapButton::SetEffect(RenderableEffect *eff, int sz)
{
    mEffect = eff;
    if (eff != nullptr) {
        SetBitmap(eff->GetEffectIcon(sz, GetContentScaleFactor() < 1.5));
        SetToolTip(eff->ToolTip());
    }
}
int CVideoControlSoft::getHeight()
{
#ifdef __WXGTK__
    double scale_factor = GetContentScaleFactor();
#else
    double scale_factor = 1.0f;
#endif
    return GetSize().y * scale_factor;
}
Exemple #4
0
void DendrogramPanel::OnIdle(wxIdleEvent& event)
{
    if (isResize && isWindowActive) {
        isResize = false;
        
        wxSize sz = GetClientSize();
        if (sz.x > 0 && sz.y > 0) {
            if (layer_bm)  {
                delete layer_bm;
                layer_bm = 0;
            }

            double scale_factor = GetContentScaleFactor();
            layer_bm = new wxBitmap;
            layer_bm->CreateScaled(sz.x, sz.y, 32, scale_factor);

            if (root) init();
        }
    }
    event.Skip();
}
void CVideoControlSoft::OnPaint(wxPaintEvent& event)
{
#ifdef __WXGTK__
    double scale_factor = GetContentScaleFactor();
#else
    double scale_factor = 1.0f;
#endif
    GLTexture * glTexture = nullptr;
    //printf("OnPaint Soft Render begin \n"); 
#ifndef WIN32
    if(!renderBitmapOpenGL->IsInit())
    {
        renderBitmapOpenGL->Init(this);
        
    }
#endif
    
    std::clock_t start;
    start = std::clock();    
    

    int width = GetWindowWidth() * scale_factor;
    int height = GetWindowHeight() * scale_factor;
    if(width == 0 || height == 0)
        return;
	
	if (quitWindow)
        return;

#ifdef WIN32
    renderBitmapOpenGL->SetCurrent(*this);
#else
    if(updateContext)
    {
        renderBitmapOpenGL->SetCurrent(*this);
        updateContext = false;
    }   
#endif
    

    if (openCLEngine == nullptr)
    {
		openCLEngine = new COpenCLEngine();

		if (openCLEngine != nullptr)
			openclContext = openCLEngine->GetInstance();

		openclEffectYUV = new COpenCLEffectVideoYUV(openclContext);
    }

    nbFrame++;
    printf("Nb Frame per Seconds : %d \n",nbFrame);


    if (videoRenderStart && initStart)
    {
		//nbFrame = 0;
        if(!fpsTimer->IsRunning())
            fpsTimer->Start(1000);
	}

	if(videoRenderStart)
	{
        glTexture = RenderToGLTexture();
        if(glTexture != nullptr)
            printf("glTexture id : %d \n",glTexture->GetTextureID());
    }
    
    if(videoRenderStart && glTexture != nullptr)
    {       
        renderBitmapOpenGL->CreateScreenRender(width, height, CRgbaquad(0,0,0,0));

        if(glTexture != nullptr)
        {
            
            muVideoEffect.lock();
            int enableopenCL = videoEffectParameter.enableOpenCL;
            muVideoEffect.unlock();
            
            int inverted = 1;
            int x = (width - glTexture->GetWidth()) / 2;
            int y = (height  - glTexture->GetHeight()) / 2;
            if(openclContext->IsSharedContextCompatible())
                inverted = 0;
               
            if(!enableopenCL)
                inverted = 1;
                
            if(isffmpegDecode)
                inverted = 1;
                
            //printf("Inverted %d Enable OpenCL %d \n",inverted, enableopenCL);
            printf("flipH : %d flipV : %d inverted : %d \n", flipH, flipV, inverted);
            muVideoEffect.lock();
            renderBitmapOpenGL->RenderWithEffect(x,y, glTexture, &videoEffectParameter, flipH, flipV, inverted);
            printf("Rotation : %d \n",videoEffectParameter.rotation);
            muVideoEffect.unlock();
            
             
        }

        muVideoEffect.lock();
        if(videoEffectParameter.showFPS)
        {
            renderBitmapOpenGL->Print(0, 1, CConvertUtility::ConvertToUTF8(msgFrame));
        }
        muVideoEffect.unlock();

        muSubtitle.lock();

        if(subtilteUpdate && pictureSubtitle != nullptr)
        {
            renderBitmapOpenGL->SetSubtitle(pictureSubtitle);

            delete pictureSubtitle;
            pictureSubtitle = nullptr;

            subtilteUpdate = false;
        }
        else if(subtilteUpdate)
        {
            renderBitmapOpenGL->DeleteSubtitle();
            subtilteUpdate = false;
        }

        muSubtitle.unlock();

        if(videoEffectParameter.enableSubtitle)
        {
            renderBitmapOpenGL->ShowSubtitle();
        }    
	}
	else
	{
		renderBitmapOpenGL->CreateScreenRender(width, height, CRgbaquad(0,0,0,0));
	}

	this->SwapBuffers();

    if(deleteTexture && glTexture != nullptr)
        delete glTexture;
    

    double duration = ( std::clock() - start ) / (double) CLOCKS_PER_SEC;


    std::cout<<"Video OnPaint Time : "<< duration <<'\n';
    

   // printf("OnPaint end \n");
}
Exemple #6
0
/**
 * Constructor of the main frame.
 */
MainFrame::MainFrame( wxWindow* parent ) :
    projectCurrentlyEdited(0),
    ribbon(NULL),
    ribbonFileBt(NULL),
    ribbonSceneEditorButtonBar(NULL),
    buildToolsPnl(NULL),
    mainFrameWrapper(NULL, NULL, this, NULL, NULL, NULL, &scenesLockingShortcuts, wxGetCwd()),
    startPage(NULL),
    projectManager(NULL)
{

    //(*Initialize(MainFrame)
    wxBoxSizer* ribbonSizer;
    wxMenuItem* MenuItem1;
    wxFlexGridSizer* FlexGridSizer2;
    wxMenuItem* MenuItem42;
    wxMenuItem* MenuItem41;
    wxFlexGridSizer* FlexGridSizer1;

    Create(parent, wxID_ANY, _("GDevelop"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_STYLE, _T("wxID_ANY"));
    SetClientSize(wxSize(850,700));
    {
    	wxIcon FrameIcon;
    	FrameIcon.CopyFromBitmap(wxBitmap(wxImage(_T("res/icon16.png"))));
    	SetIcon(FrameIcon);
    }
    FlexGridSizer1 = new wxFlexGridSizer(0, 1, 0, 0);
    FlexGridSizer1->AddGrowableCol(0);
    FlexGridSizer1->AddGrowableRow(1);
    ribbonSizer = new wxBoxSizer(wxVERTICAL);
    FlexGridSizer1->Add(ribbonSizer, 1, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 0);
    Panel1 = new wxPanel(this, ID_PANEL1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL, _T("ID_PANEL1"));
    FlexGridSizer2 = new wxFlexGridSizer(0, 1, 0, 0);
    FlexGridSizer2->AddGrowableCol(0);
    FlexGridSizer2->AddGrowableRow(0);
    editorsNotebook = new wxAuiNotebook(Panel1, ID_AUINOTEBOOK1, wxDefaultPosition, wxDefaultSize, wxAUI_NB_TAB_SPLIT|wxAUI_NB_TAB_MOVE|wxAUI_NB_SCROLL_BUTTONS|wxAUI_NB_TOP|wxNO_BORDER);
    FlexGridSizer2->Add(editorsNotebook, 1, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 0);
    infoBar = new wxInfoBar(Panel1,ID_CUSTOM1);
    FlexGridSizer2->Add(infoBar, 1, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 0);
    Panel1->SetSizer(FlexGridSizer2);
    FlexGridSizer2->Fit(Panel1);
    FlexGridSizer2->SetSizeHints(Panel1);
    FlexGridSizer1->Add(Panel1, 1, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 0);
    SetSizer(FlexGridSizer1);
    MenuItem1 = new wxMenuItem((&openContextMenu), ID_MENUITEM1, _("Open an example"), wxEmptyString, wxITEM_NORMAL);
    openContextMenu.Append(MenuItem1);
    MenuItem10 = new wxMenuItem((&saveContextMenu), ID_MENUITEM2, _("Save as..."), wxEmptyString, wxITEM_NORMAL);
    MenuItem10->SetBitmap(gd::SkinHelper::GetIcon("saveas", 16));
    saveContextMenu.Append(MenuItem10);
    MenuItem41 = new wxMenuItem((&decomposerContextMenu), ID_MENUITEM4, _("Decompose an animated GIF"), wxEmptyString, wxITEM_NORMAL);
    MenuItem41->SetBitmap(wxBitmap(wxImage(_T("res/importgif.png"))));
    decomposerContextMenu.Append(MenuItem41);
    MenuItem42 = new wxMenuItem((&decomposerContextMenu), ID_MENUITEM5, _("Decompose a RPG Maker character"), wxEmptyString, wxITEM_NORMAL);
    MenuItem42->SetBitmap(wxBitmap(wxImage(_T("res/importrpgmaker.png"))));
    decomposerContextMenu.Append(MenuItem42);
    MenuItem43 = new wxMenuItem((&decomposerContextMenu), ID_MENUITEM6, _("Decompose a spritesheet"), wxEmptyString, wxITEM_NORMAL);
    MenuItem43->SetBitmap(wxBitmap(wxImage(_T("res/spritesheet16.png"))));
    decomposerContextMenu.Append(MenuItem43);
    autoSaveTimer.SetOwner(this, ID_TIMER1);
    autoSaveTimer.Start(180000, false);
    MenuItem2 = new wxMenuItem((&fileMenu), ID_MENUITEM7, _("New\tCtrl+N"), wxEmptyString, wxITEM_NORMAL);
    MenuItem2->SetBitmap(gd::SkinHelper::GetIcon("new", 16));
    fileMenu.Append(MenuItem2);
    fileMenu.AppendSeparator();
    MenuItem3 = new wxMenuItem((&fileMenu), ID_MENUITEM9, _("Open\tCtrl+O"), wxEmptyString, wxITEM_NORMAL);
    MenuItem3->SetBitmap(gd::SkinHelper::GetIcon("open", 16));
    fileMenu.Append(MenuItem3);
    MenuItem4 = new wxMenuItem((&fileMenu), ID_MENUITEM10, _("Open an example"), wxEmptyString, wxITEM_NORMAL);
    fileMenu.Append(MenuItem4);
    menuRecentFiles = new wxMenu();
    MenuItem23 = new wxMenuItem(menuRecentFiles, toBeDeletedMenuItem, _("useless"), wxEmptyString, wxITEM_NORMAL);
    menuRecentFiles->Append(MenuItem23);
    fileMenu.Append(ID_MENUITEM26, _("Recently opened"), menuRecentFiles, wxEmptyString);
    fileMenu.AppendSeparator();
    MenuItem6 = new wxMenuItem((&fileMenu), ID_MENUITEM12, _("Save\tCtrl+S"), wxEmptyString, wxITEM_NORMAL);
    MenuItem6->SetBitmap(gd::SkinHelper::GetIcon("save", 16));
    fileMenu.Append(MenuItem6);
    MenuItem7 = new wxMenuItem((&fileMenu), ID_MENUITEM13, _("Save as..."), wxEmptyString, wxITEM_NORMAL);
    MenuItem7->SetBitmap(gd::SkinHelper::GetIcon("saveas", 16));
    fileMenu.Append(MenuItem7);
    MenuItem12 = new wxMenuItem((&fileMenu), ID_MENUITEM16, _("Save all\tCtrl+Shift+S"), wxEmptyString, wxITEM_NORMAL);
    MenuItem12->SetBitmap(gd::SkinHelper::GetIcon("save_all", 16));
    fileMenu.Append(MenuItem12);
    fileMenu.AppendSeparator();
    fileMenu.AppendSeparator();
    MenuItem15 = new wxMenuItem((&fileMenu), ID_MENUITEM19, _("Close the current project"), wxEmptyString, wxITEM_NORMAL);
    MenuItem15->SetBitmap(gd::SkinHelper::GetIcon("close", 16));
    fileMenu.Append(MenuItem15);
    fileMenu.AppendSeparator();
    MenuItem13 = new wxMenuItem((&fileMenu), ID_MENUITEM17, _("Options"), wxEmptyString, wxITEM_NORMAL);
    MenuItem13->SetBitmap(gd::SkinHelper::GetIcon("options", 16));
    fileMenu.Append(MenuItem13);
    fileMenu.AppendSeparator();
    MenuItem22 = new wxMenuItem((&fileMenu), ID_MENUITEM27, _("Help\tF1"), wxEmptyString, wxITEM_NORMAL);
    MenuItem22->SetBitmap(gd::SkinHelper::GetIcon("help", 16));
    fileMenu.Append(MenuItem22);
    fileMenu.AppendSeparator();
    MenuItem8 = new wxMenuItem((&fileMenu), ID_MENUITEM14, _("Quit"), _("Quit GDevelop"), wxITEM_NORMAL);
    fileMenu.Append(MenuItem8);
    menuRecentFiles->Delete(toBeDeletedMenuItem);
    MenuItem16 = new wxMenuItem((&helpMenu), ID_MENUITEM20, _("Help"), wxEmptyString, wxITEM_NORMAL);
    MenuItem16->SetBitmap(gd::SkinHelper::GetIcon("help", 16));
    helpMenu.Append(MenuItem16);
    MenuItem19 = new wxMenuItem((&helpMenu), ID_MENUITEM23, _("Tutorial"), wxEmptyString, wxITEM_NORMAL);
    helpMenu.Append(MenuItem19);
    helpMenu.AppendSeparator();
    MenuItem21 = new wxMenuItem((&helpMenu), ID_MENUITEM25, _("Check for updates"), wxEmptyString, wxITEM_NORMAL);
    helpMenu.Append(MenuItem21);
    helpMenu.AppendSeparator();
    MenuItem20 = new wxMenuItem((&helpMenu), ID_MENUITEM24, _("Official web site"), wxEmptyString, wxITEM_NORMAL);
    MenuItem20->SetBitmap(gd::SkinHelper::GetIcon("site", 16));
    helpMenu.Append(MenuItem20);
    MenuItem17 = new wxMenuItem((&helpMenu), ID_MENUITEM21, _("About..."), wxEmptyString, wxITEM_NORMAL);
    MenuItem17->SetBitmap(wxBitmap(wxImage(_T("res/icon16.png"))));
    helpMenu.Append(MenuItem17);
    MenuItem11 = new wxMenuItem((&disabledFileMenu), ID_MENUITEM3, _("Please stop the preview before continuing"), wxEmptyString, wxITEM_NORMAL);
    disabledFileMenu.Append(MenuItem11);
    MenuItem11->Enable(false);
    SetSizer(FlexGridSizer1);
    Layout();
    Center();

    Connect(ID_AUINOTEBOOK1,wxEVT_COMMAND_AUINOTEBOOK_PAGE_CLOSE,(wxObjectEventFunction)&MainFrame::OneditorsNotebookPageClose);
    Connect(ID_AUINOTEBOOK1,wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGED,(wxObjectEventFunction)&MainFrame::OnNotebook1PageChanged);
    Connect(ID_MENUITEM1,wxEVT_COMMAND_MENU_SELECTED,(wxObjectEventFunction)&MainFrame::OnOpenExampleSelected);
    Connect(ID_MENUITEM2,wxEVT_COMMAND_MENU_SELECTED,(wxObjectEventFunction)&MainFrame::OnMenuSaveAsSelected);
    Connect(ID_MENUITEM4,wxEVT_COMMAND_MENU_SELECTED,(wxObjectEventFunction)&MainFrame::OnDecomposeGIFSelected);
    Connect(ID_MENUITEM5,wxEVT_COMMAND_MENU_SELECTED,(wxObjectEventFunction)&MainFrame::OnDecomposeRPGSelected);
    Connect(ID_MENUITEM6,wxEVT_COMMAND_MENU_SELECTED,(wxObjectEventFunction)&MainFrame::OnDecomposeSSSelected);
    Connect(ID_TIMER1,wxEVT_TIMER,(wxObjectEventFunction)&MainFrame::OnautoSaveTimerTrigger);
    Connect(ID_MENUITEM7,wxEVT_COMMAND_MENU_SELECTED,(wxObjectEventFunction)&MainFrame::OnMenuNewSelected);
    Connect(ID_MENUITEM9,wxEVT_COMMAND_MENU_SELECTED,(wxObjectEventFunction)&MainFrame::OnMenuOpenSelected);
    Connect(ID_MENUITEM10,wxEVT_COMMAND_MENU_SELECTED,(wxObjectEventFunction)&MainFrame::OnOpenExampleSelected);
    Connect(ID_MENUITEM12,wxEVT_COMMAND_MENU_SELECTED,(wxObjectEventFunction)&MainFrame::OnMenuSaveSelected);
    Connect(ID_MENUITEM13,wxEVT_COMMAND_MENU_SELECTED,(wxObjectEventFunction)&MainFrame::OnMenuSaveAsSelected);
    Connect(ID_MENUITEM16,wxEVT_COMMAND_MENU_SELECTED,(wxObjectEventFunction)&MainFrame::OnMenuSaveAllSelected);
    Connect(ID_MENUITEM19,wxEVT_COMMAND_MENU_SELECTED,(wxObjectEventFunction)&MainFrame::OnCloseCurrentProjectSelected);
    Connect(ID_MENUITEM17,wxEVT_COMMAND_MENU_SELECTED,(wxObjectEventFunction)&MainFrame::OnMenuPrefSelected);
    Connect(ID_MENUITEM27,wxEVT_COMMAND_MENU_SELECTED,(wxObjectEventFunction)&MainFrame::OnMenuAideSelected);
    Connect(ID_MENUITEM14,wxEVT_COMMAND_MENU_SELECTED,(wxObjectEventFunction)&MainFrame::OnQuit);
    Connect(ID_MENUITEM20,wxEVT_COMMAND_MENU_SELECTED,(wxObjectEventFunction)&MainFrame::OnMenuAideSelected);
    Connect(ID_MENUITEM23,wxEVT_COMMAND_MENU_SELECTED,(wxObjectEventFunction)&MainFrame::OnMenuTutoSelected);
    Connect(ID_MENUITEM25,wxEVT_COMMAND_MENU_SELECTED,(wxObjectEventFunction)&MainFrame::OnMenuItem36Selected);
    Connect(ID_MENUITEM24,wxEVT_COMMAND_MENU_SELECTED,(wxObjectEventFunction)&MainFrame::OnMenuSiteSelected);
    Connect(ID_MENUITEM21,wxEVT_COMMAND_MENU_SELECTED,(wxObjectEventFunction)&MainFrame::OnAbout);
    Connect(wxID_ANY,wxEVT_CLOSE_WINDOW,(wxObjectEventFunction)&MainFrame::OnClose);
    Connect(wxEVT_SIZE,(wxObjectEventFunction)&MainFrame::OnResize);
    //*)
    Connect( wxID_FILE1, wxID_FILE9, wxEVT_COMMAND_MENU_SELECTED, ( wxObjectEventFunction )&MainFrame::OnRecentClicked );
    Connect( idRibbonNew, wxEVT_COMMAND_RIBBONBUTTON_CLICKED, ( wxObjectEventFunction )&MainFrame::OnMenuNewSelected );
    Connect( idRibbonOpen, wxEVT_COMMAND_RIBBONBUTTON_CLICKED, ( wxObjectEventFunction )&MainFrame::OnMenuOpenSelected );
    Connect( idRibbonOpen, wxEVT_COMMAND_RIBBONBUTTON_DROPDOWN_CLICKED, ( wxObjectEventFunction )&MainFrame::OnRibbonOpenDropDownClicked );
    Connect( idRibbonSave, wxEVT_COMMAND_RIBBONBUTTON_CLICKED, ( wxObjectEventFunction )&MainFrame::OnMenuSaveSelected );
    Connect( idRibbonSave, wxEVT_COMMAND_RIBBONBUTTON_DROPDOWN_CLICKED, ( wxObjectEventFunction )&MainFrame::OnRibbonSaveDropDownClicked );
    Connect( idRibbonSaveAll, wxEVT_COMMAND_RIBBONBUTTON_CLICKED, ( wxObjectEventFunction )&MainFrame::OnRibbonSaveAllClicked );
    Connect( idRibbonOptions, wxEVT_COMMAND_RIBBONBUTTON_CLICKED, ( wxObjectEventFunction )&MainFrame::OnMenuPrefSelected );
    Connect( idRibbonHelp, wxEVT_COMMAND_RIBBONBUTTON_CLICKED, ( wxObjectEventFunction )&MainFrame::OnMenuAideSelected );
    Connect( idRibbonTuto, wxEVT_COMMAND_RIBBONBUTTON_CLICKED, ( wxObjectEventFunction )&MainFrame::OnMenuTutoSelected );
    Connect( idRibbonForum, wxEVT_COMMAND_RIBBONBUTTON_CLICKED, ( wxObjectEventFunction )&MainFrame::OnMenuForumSelected );
    Connect( idRibbonUpdate, wxEVT_COMMAND_RIBBONBUTTON_CLICKED, ( wxObjectEventFunction )&MainFrame::OnMenuItem36Selected );
    Connect( idRibbonWebSite, wxEVT_COMMAND_RIBBONBUTTON_CLICKED, ( wxObjectEventFunction )&MainFrame::OnMenuSiteSelected );
    Connect( idRibbonCredits, wxEVT_COMMAND_RIBBONBUTTON_CLICKED, ( wxObjectEventFunction )&MainFrame::OnAbout );
    Connect( ID_RIBBON, wxEVT_COMMAND_RIBBONBAR_PAGE_CHANGING, ( wxObjectEventFunction )&MainFrame::OnRibbonPageChanging );
    Connect( ID_RIBBON, wxEVT_COMMAND_RIBBONBAR_HELP_CLICKED, ( wxObjectEventFunction )&MainFrame::OnRibbonHelpBtClick );
    Connect( ID_RIBBON, wxEVT_COMMAND_RIBBONBAR_TOGGLED, ( wxObjectEventFunction )&MainFrame::OnRibbonToggleBtClick );

    #ifdef GD_NO_UPDATE_CHECKER //Remove the menu item to check for updates
    helpMenu.Delete(MenuItem21); //(useful when GD is distributed on a system managing updates by itself).
    #endif

    //Update the file menu with exporting items
    for (unsigned int i = 0;i<gd::PlatformManager::Get()->GetAllPlatforms().size();++i)
    {
        std::shared_ptr<gd::ProjectExporter> exporter = gd::PlatformManager::Get()->GetAllPlatforms()[i]->GetProjectExporter();
        if ( exporter != std::shared_ptr<gd::ProjectExporter>()
             && !exporter->GetProjectExportButtonLabel().empty() )
        {
            long id = wxNewId();

            fileMenu.Insert(10, id, exporter->GetProjectExportButtonLabel());
            Connect( id, wxEVT_COMMAND_MENU_SELECTED, ( wxObjectEventFunction )&MainFrame::OnMenuCompilationSelected );
            idToPlatformExportMenuMap[id] = gd::PlatformManager::Get()->GetAllPlatforms()[i].get();
        }
    }

    wxIconBundle icons;
    icons.AddIcon("res/icon16.png");
    icons.AddIcon("res/icon24.png");
    #if defined(LINUX) || defined(MACOS)
    icons.AddIcon("res/icon32linux.png");
    icons.AddIcon("res/icon48linux.png");
    icons.AddIcon("res/icon64linux.png");
    icons.AddIcon("res/icon128linux.png");
    #else
    icons.AddIcon("res/icon32.png");
    icons.AddIcon("res/icon48.png");
    icons.AddIcon("res/icon128.png");
    #endif
    SetIcons(icons);

    SetDropTarget(new DnDFileEditor(*this));

    //Set the content scale factor, for "retina" screens support.
    gd::GUIContentScaleFactor::Set(GetContentScaleFactor());

    wxConfigBase *pConfig = wxConfigBase::Get();

    //Deactivate menu
    SetMenuBar(NULL);

    //Prepare autosave
    PrepareAutosave();

    //Prepare recent list
    m_recentlist.SetMaxEntries( 9 );
    m_recentlist.SetAssociatedMenu( menuRecentFiles );
    for ( int i = 0;i < 9;i++ )
    {
        wxString result;
        pConfig->Read( wxString::Format( _T( "/Recent/%d" ), i ), &result );
        m_recentlist.Append( result );
    }

    //Create status bar
    wxStatusBar * statusBar = new wxStatusBar(this);
    static int widths[2] = { -1, 175 };
    statusBar->SetFieldsCount(2);
    statusBar->SetStatusWidths(2, widths);
    statusBar->SetStatusText( "2008-2014", 1 );
    SetStatusBar(statusBar);

    std::vector<wxWindow*> controlsToBeDisabledOnPreview; //Used below:

    //Ribbon setup
    long ribbonStyle = wxRIBBON_BAR_DEFAULT_STYLE;
    bool hidePageTabs = false;
    pConfig->Read( _T( "/Skin/HidePageTabs" ), &hidePageTabs );
    if ( hidePageTabs )
    {
        ribbonStyle &= ~wxRIBBON_BAR_SHOW_PAGE_LABELS;
    }
    ribbon = new wxRibbonBar(this, ID_RIBBON);
    ribbon->SetWindowStyle(ribbonStyle);
    bool hideLabels = false;
    pConfig->Read( _T( "/Skin/HideLabels" ), &hideLabels );
    {
        wxRibbonPage * ribbonProjectPage = new wxRibbonPage(ribbon, wxID_ANY, _("Projects"));
        ProjectManager::CreateRibbonPage(ribbonProjectPage);
    }
    {
        wxRibbonPage * ribbonEditorPage = new wxRibbonPage(ribbon, wxID_ANY, _("Images bank"));
        //
        {
            wxRibbonPanel *ribbonPanel = new wxRibbonPanel(ribbonEditorPage, wxID_ANY, _("Adding resources"), gd::SkinHelper::GetRibbonIcon("list"), wxDefaultPosition, wxDefaultSize, wxRIBBON_PANEL_DEFAULT_STYLE);
            wxRibbonButtonBar *ribbonBar = new wxRibbonButtonBar(ribbonPanel, wxID_ANY);
            ribbonBar->AddButton(ResourcesEditor::idRibbonAdd, !hideLabels ? _("Add an image") : "", gd::SkinHelper::GetRibbonIcon("add"), _("Add an image to the resources"));
            ribbonBar->AddButton(ResourcesEditor::idRibbonAddFromLibrary, !hideLabels ? _("Add from the library") : "", gd::SkinHelper::GetRibbonIcon("addFromLibrary"), _("Add an image from a library of images"));
            ribbonBar->AddButton(ResourcesEditor::idRibbonAddDossier, !hideLabels ? _("Add a virtual folder") : "", gd::SkinHelper::GetRibbonIcon("virtualfolderadd"), _("Add a virtual folder to organize resources"));
            controlsToBeDisabledOnPreview.push_back(ribbonBar);
        }
        {
            wxRibbonPanel *ribbonPanel = new wxRibbonPanel(ribbonEditorPage, wxID_ANY, _("List management"), gd::SkinHelper::GetRibbonIcon("list"), wxDefaultPosition, wxDefaultSize, wxRIBBON_PANEL_DEFAULT_STYLE);
            wxRibbonButtonBar *ribbonBar = new wxRibbonButtonBar(ribbonPanel, wxID_ANY);
            ribbonBar->AddButton(ResourcesEditor::idRibbonDel, !hideLabels ? _("Delete") : "", gd::SkinHelper::GetRibbonIcon("delete"), _("Delete the selected resource"));
            ribbonBar->AddButton(ResourcesEditor::idRibbonDeleteUnused, !hideLabels ? _("Remove useless resources") : "", gd::SkinHelper::GetRibbonIcon("deleteunknown"), _("Check if there are useless resources that can be removed"));
            ribbonBar->AddButton(ResourcesEditor::idRibbonUp, !hideLabels ? _("Move up") : "", gd::SkinHelper::GetRibbonIcon("up"));
            ribbonBar->AddButton(ResourcesEditor::idRibbonDown, !hideLabels ? _("Move down") : "", gd::SkinHelper::GetRibbonIcon("down"));
            ribbonBar->AddButton(ResourcesEditor::idRibbonRefresh, !hideLabels ? _("Refresh") : "", gd::SkinHelper::GetRibbonIcon("refresh"), _("Refresh the list, if you've done changes in another window"));
            controlsToBeDisabledOnPreview.push_back(ribbonBar);
        }

        {
            wxRibbonPanel *ribbonPanel = new wxRibbonPanel(ribbonEditorPage, wxID_ANY, _("View"), gd::SkinHelper::GetRibbonIcon("edit"), wxDefaultPosition, wxDefaultSize, wxRIBBON_PANEL_DEFAULT_STYLE);
            wxRibbonButtonBar *ribbonBar = new wxRibbonButtonBar(ribbonPanel, wxID_ANY);
            ribbonBar->AddButton(ResourcesEditor::idRibbonShowPreview, !hideLabels ? _("Preview") : "", gd::SkinHelper::GetRibbonIcon("view"), _("Show a panel with the image displayed inside"));
            ribbonBar->AddButton(ResourcesEditor::idRibbonShowPropertyGrid, !hideLabels ? _("Properties") : "", gd::SkinHelper::GetRibbonIcon("editprop"), _("Show the properties of the resource"));
            controlsToBeDisabledOnPreview.push_back(ribbonBar);
        }
        {
            wxRibbonPanel *ribbonPanel = new wxRibbonPanel(ribbonEditorPage, wxID_ANY, _("Help"), gd::SkinHelper::GetRibbonIcon("help"), wxDefaultPosition, wxDefaultSize, wxRIBBON_PANEL_DEFAULT_STYLE);
            wxRibbonButtonBar *ribbonBar = new wxRibbonButtonBar(ribbonPanel, wxID_ANY);
            ribbonBar->AddButton(ResourcesEditor::idRibbonHelp, !hideLabels ? _("Help") : "", gd::SkinHelper::GetRibbonIcon("help"), _("Open the online help"));
            controlsToBeDisabledOnPreview.push_back(ribbonBar);
        }
    }
    {
        wxRibbonPage * ribbonEditorPage = new wxRibbonPage(ribbon, wxID_ANY, _("Scene"));
        ribbonSceneEditorButtonBar = gd::LayoutEditorCanvas::CreateRibbonPage(ribbonEditorPage);
    }
    {
        wxRibbonPage * ribbonEditorPage = new wxRibbonPage(ribbon, wxID_ANY, _("Events"));
        EventsEditor::CreateRibbonPage(ribbonEditorPage);
    }
    {
        wxRibbonPage * ribbonEditorPage = new wxRibbonPage(ribbon, wxID_ANY, _("Objects"));
        gd::ObjectsEditor::CreateRibbonPage(ribbonEditorPage);
    }
    {
        wxRibbonPage * ribbonEditorPage = new wxRibbonPage(ribbon, wxID_ANY, _("Code"));
        CodeEditor::CreateRibbonPage(ribbonEditorPage);
    }
    ribbon->Realize();
    ribbonSizer->Add(ribbon, 0, wxEXPAND);

    //Create ribbon "File" custom button
    ribbonFileBt = new wxStaticBitmap(ribbon, idRibbonFileBt, wxNullBitmap);
    ribbonFileBt->Connect(wxEVT_LEAVE_WINDOW, wxMouseEventHandler(MainFrame::OnRibbonFileBtLeave), NULL, this);
    ribbonFileBt->Connect(wxEVT_ENTER_WINDOW, wxMouseEventHandler(MainFrame::OnRibbonFileBtEnter), NULL, this);
    ribbonFileBt->Connect(wxEVT_LEFT_DOWN, wxMouseEventHandler(MainFrame::OnRibbonFileBtClick), NULL, this);

    //Load wxAUI
    m_mgr.SetManagedWindow( this );

    gd::SkinHelper::ApplyCurrentSkin(m_mgr);
    gd::SkinHelper::ApplyCurrentSkin(*editorsNotebook);
    gd::SkinHelper::ApplyCurrentSkin(*ribbon);

    RealizeRibbonCustomButtons();

    //Create start page
    startPage = new StartHerePage(editorsNotebook, *this);
    editorsNotebook->AddPage(startPage, _("Start page"));

    //Create project manager
    projectManager = new ProjectManager(this, *this);
    projectManager->ConnectEvents();

    //Create project properties panel
    projectPropertiesPnl = new ProjectPropertiesPnl(this);

    //Create build tools panel
    buildToolsPnl = new BuildToolsPnl(this, projectManager);

    //Setup panes and load user configuration
    m_mgr.AddPane( projectManager, wxAuiPaneInfo().Name( wxT( "PM" ) ).Caption( _( "Project manager" ) ).Left().MaximizeButton( true ).MinimizeButton( false ).MinSize(170,100) );
    m_mgr.AddPane( Panel1, wxAuiPaneInfo().Name( wxT( "EP" ) ).Caption( _( "Main editor" ) ).Center().CaptionVisible(false).CloseButton( false ).MaximizeButton( true ).MinimizeButton( false ) );
    m_mgr.AddPane( ribbon, wxAuiPaneInfo().Name( wxT( "RP" ) ).Caption( _( "Ribbon" ) ).Top().PaneBorder(false).CaptionVisible(false).Movable(false).Floatable(false).CloseButton( false ).MaximizeButton( false ).MinimizeButton( false ).Resizable(false) );
    m_mgr.AddPane( buildToolsPnl, wxAuiPaneInfo().Name( wxT( "CT" ) ).Caption( _( "Compilation tools" ) ).Bottom().MaximizeButton( true ).MinimizeButton( false ).Show(false).MinSize(120,130));
    m_mgr.AddPane( projectPropertiesPnl, wxAuiPaneInfo().Name( wxT( "PP" ) ).Caption( _( "Project properties" ) ).Float().Show(false) );

    wxString result;
    pConfig->Read( _T( "/Workspace/Actuel" ), &result );
    if ( result != "" )
        m_mgr.LoadPerspective( result , true );

    //Ensure that names are corrected ( Useful in particular to ensure that these name are in the selected language ).
    m_mgr.GetPane(projectManager).Caption(_( "Project manager" ));
    m_mgr.GetPane(buildToolsPnl).Caption(_( "Compilation tools" ));
    m_mgr.GetPane(projectPropertiesPnl).Caption(_( "Project properties" ));

    //Change ribbon pane height.
    bool hidePanels = false;
    pConfig->Read( _T( "/Skin/HidePanels" ), &hidePanels );
    ribbon->ShowPanels(!hidePanels);
    m_mgr.GetPane(ribbon).MinSize(1, ribbon->GetBestSize().GetHeight()+4);

    m_mgr.SetFlags( wxAUI_MGR_ALLOW_FLOATING | wxAUI_MGR_ALLOW_ACTIVE_PANE | wxAUI_MGR_TRANSPARENT_HINT
                    | wxAUI_MGR_TRANSPARENT_DRAG | wxAUI_MGR_HINT_FADE | wxAUI_MGR_NO_VENETIAN_BLINDS_FADE );

    m_mgr.Update();
    UpdateNotebook();

    infoBar->SetShowHideEffects(wxSHOW_EFFECT_SLIDE_TO_BOTTOM, wxSHOW_EFFECT_BLEND);

    //Construct the lightweight wrapper used by editors to access to the main frame.
    mainFrameWrapper = gd::MainFrameWrapper(ribbon, ribbonSceneEditorButtonBar, this, &m_mgr, editorsNotebook, infoBar, &scenesLockingShortcuts, wxGetCwd());
    mainFrameWrapper.AddControlToBeDisabledOnPreview(projectManager);
    for (unsigned int i = 0;i<controlsToBeDisabledOnPreview.size();++i) mainFrameWrapper.AddControlToBeDisabledOnPreview(controlsToBeDisabledOnPreview[i]);

    SetSize(900,740);
    Center();
    Maximize(true);
}
// Prepare the GUI to start the game.
void CFrame::StartGame(const std::string& filename)
{
  if (m_bGameLoading)
    return;
  m_bGameLoading = true;

  GetToolBar()->EnableTool(IDM_PLAY, false);
  GetMenuBar()->FindItem(IDM_PLAY)->Enable(false);

  if (SConfig::GetInstance().bRenderToMain)
  {
    // Game has been started, hide the game list
    m_GameListCtrl->Disable();
    m_GameListCtrl->Hide();

    m_RenderParent = m_Panel;
    m_RenderFrame = this;
    if (SConfig::GetInstance().bKeepWindowOnTop)
      m_RenderFrame->SetWindowStyle(m_RenderFrame->GetWindowStyle() | wxSTAY_ON_TOP);
    else
      m_RenderFrame->SetWindowStyle(m_RenderFrame->GetWindowStyle() & ~wxSTAY_ON_TOP);

    // No, I really don't want TAB_TRAVERSAL being set behind my back,
    // thanks.  (Note that calling DisableSelfFocus would prevent this flag
    // from being set for new children, but wouldn't reset the existing
    // flag.)
    m_RenderParent->SetWindowStyle(m_RenderParent->GetWindowStyle() & ~wxTAB_TRAVERSAL);
  }
  else
  {
    wxRect window_geometry(
        SConfig::GetInstance().iRenderWindowXPos, SConfig::GetInstance().iRenderWindowYPos,
        SConfig::GetInstance().iRenderWindowWidth, SConfig::GetInstance().iRenderWindowHeight);
    // Set window size in framebuffer pixels since the 3D rendering will be operating at
    // that level.
    wxSize default_size{wxSize(640, 480) * (1.0 / GetContentScaleFactor())};
    m_RenderFrame = new CRenderFrame(this, wxID_ANY, _("Dolphin"), wxDefaultPosition, default_size);

    // Convert ClientSize coordinates to frame sizes.
    wxSize decoration_fudge = m_RenderFrame->GetSize() - m_RenderFrame->GetClientSize();
    default_size += decoration_fudge;
    if (!window_geometry.IsEmpty())
      window_geometry.SetSize(window_geometry.GetSize() + decoration_fudge);

    WxUtils::SetWindowSizeAndFitToScreen(m_RenderFrame, window_geometry.GetPosition(),
                                         window_geometry.GetSize(), default_size);

    if (SConfig::GetInstance().bKeepWindowOnTop)
      m_RenderFrame->SetWindowStyle(m_RenderFrame->GetWindowStyle() | wxSTAY_ON_TOP);
    else
      m_RenderFrame->SetWindowStyle(m_RenderFrame->GetWindowStyle() & ~wxSTAY_ON_TOP);

    m_RenderFrame->SetBackgroundColour(*wxBLACK);
    m_RenderFrame->Bind(wxEVT_CLOSE_WINDOW, &CFrame::OnRenderParentClose, this);
    m_RenderFrame->Bind(wxEVT_ACTIVATE, &CFrame::OnActive, this);
    m_RenderFrame->Bind(wxEVT_MOVE, &CFrame::OnRenderParentMove, this);
#ifdef _WIN32
    // The renderer should use a top-level window for exclusive fullscreen support.
    m_RenderParent = m_RenderFrame;
#else
    // To capture key events on Linux and Mac OS X the frame needs at least one child.
    m_RenderParent = new wxPanel(m_RenderFrame, IDM_MPANEL, wxDefaultPosition, wxDefaultSize, 0);
#endif

    m_RenderFrame->Show();
  }

#if defined(__APPLE__)
  m_RenderFrame->EnableFullScreenView(true);
#endif

  wxBusyCursor hourglass;

  DoFullscreen(SConfig::GetInstance().bFullscreen);

  if (!BootManager::BootCore(filename))
  {
    DoFullscreen(false);
    // Destroy the renderer frame when not rendering to main
    if (!SConfig::GetInstance().bRenderToMain)
      m_RenderFrame->Destroy();
    m_RenderFrame = nullptr;
    m_RenderParent = nullptr;
    m_bGameLoading = false;
    UpdateGUI();
  }
  else
  {
#if defined(HAVE_X11) && HAVE_X11
    if (SConfig::GetInstance().bDisableScreenSaver)
      X11Utils::InhibitScreensaver(X11Utils::XDisplayFromHandle(GetHandle()),
                                   X11Utils::XWindowFromHandle(GetHandle()), true);
#endif

#ifdef _WIN32
    // Prevents Windows from sleeping, turning off the display, or idling
    EXECUTION_STATE shouldScreenSave =
        SConfig::GetInstance().bDisableScreenSaver ? ES_DISPLAY_REQUIRED : 0;
    SetThreadExecutionState(ES_CONTINUOUS | shouldScreenSave | ES_SYSTEM_REQUIRED);
#endif

    m_RenderParent->SetFocus();

    wxTheApp->Bind(wxEVT_KEY_DOWN, &CFrame::OnKeyDown, this);
    wxTheApp->Bind(wxEVT_RIGHT_DOWN, &CFrame::OnMouse, this);
    wxTheApp->Bind(wxEVT_RIGHT_UP, &CFrame::OnMouse, this);
    wxTheApp->Bind(wxEVT_MIDDLE_DOWN, &CFrame::OnMouse, this);
    wxTheApp->Bind(wxEVT_MIDDLE_UP, &CFrame::OnMouse, this);
    wxTheApp->Bind(wxEVT_MOTION, &CFrame::OnMouse, this);
    m_RenderParent->Bind(wxEVT_SIZE, &CFrame::OnRenderParentResize, this);
  }
}
Exemple #8
0
AboutDolphin::AboutDolphin(wxWindow *parent, wxWindowID id,
		const wxString &title, const wxPoint &position,
		const wxSize& size, long style)
	: wxDialog(parent, id, title, position, size, style)
{
	const unsigned char* dolphin_logo_bin = dolphin_logo_png;
	size_t dolphin_logo_size = sizeof dolphin_logo_png;
#ifdef __APPLE__
	double scaleFactor = 1.0;
	if (GetContentScaleFactor() >= 2)
	{
		dolphin_logo_bin = dolphin_logo_2x_png;
		dolphin_logo_size = sizeof dolphin_logo_2x_png;
		scaleFactor = 2.0;
	}
#endif
	wxMemoryInputStream istream(dolphin_logo_bin, dolphin_logo_size);
	wxImage iDolphinLogo(istream, wxBITMAP_TYPE_PNG);
#ifdef __APPLE__
	wxGenericStaticBitmap* const sbDolphinLogo = new wxGenericStaticBitmap(this, wxID_ANY,
			wxBitmap(iDolphinLogo, -1, scaleFactor));
#else
	wxGenericStaticBitmap* const sbDolphinLogo = new wxGenericStaticBitmap(this, wxID_ANY,
			wxBitmap(iDolphinLogo));
#endif

	const wxString DolphinText = _("Dolphin");
	const wxString RevisionText = scm_desc_str;
	const wxString CopyrightText = _("(c) 2003-2015+ Dolphin Team. \"GameCube\" and \"Wii\" are trademarks of Nintendo. Dolphin is not affiliated with Nintendo in any way.");
	const wxString BranchText = wxString::Format(_("Branch: %s"), scm_branch_str);
	const wxString BranchRevText = wxString::Format(_("Revision: %s"), scm_rev_git_str);
	const wxString CompiledText = wxString::Format(_("Compiled: %s @ %s"), __DATE__, __TIME__);
	const wxString CheckUpdateText = _("Check for updates: ");
	const wxString Text = _("\n"
		"Dolphin is a free and open-source GameCube and Wii emulator.\n"
		"\n"
		"This software should not be used to play games you do not legally own.\n");
	const wxString LicenseText = _("License");
	const wxString AuthorsText = _("Authors");
	const wxString SupportText = _("Support");

	wxStaticText* const Dolphin = new wxStaticText(this, wxID_ANY, DolphinText);
	wxTextCtrl* const Revision = new wxTextCtrl(this, wxID_ANY, RevisionText, wxDefaultPosition, wxDefaultSize, wxNO_BORDER | wxTE_NO_VSCROLL);
	BanishBackground(Revision);
	wxStaticText* const Copyright = new wxStaticText(this, wxID_ANY, CopyrightText);
	wxTextCtrl* const Branch = new wxTextCtrl(this, wxID_ANY, "", wxDefaultPosition, wxSize(300, 50), wxNO_BORDER | wxTE_NO_VSCROLL);
	BanishBackground(Branch);
	wxStaticText* const Message = new wxStaticText(this, wxID_ANY, Text);
	wxStaticText* const UpdateText = new wxStaticText(this, wxID_ANY, CheckUpdateText);
	wxStaticText* const FirstSpacer = new wxStaticText(this, wxID_ANY, wxString("  |  "));
	wxStaticText* const SecondSpacer = new wxStaticText(this, wxID_ANY, wxString("  |  "));
	wxHyperlinkCtrl* const Download = new wxHyperlinkCtrl(this, wxID_ANY, "dolphin-emu.org/download", "https://dolphin-emu.org/download/");
	wxHyperlinkCtrl* const License = new wxHyperlinkCtrl(this, wxID_ANY, LicenseText, "https://github.com/dolphin-emu/dolphin/blob/master/license.txt");
	wxHyperlinkCtrl* const Authors = new wxHyperlinkCtrl(this, wxID_ANY, AuthorsText, "https://github.com/dolphin-emu/dolphin/graphs/contributors");
	wxHyperlinkCtrl* const Support = new wxHyperlinkCtrl(this, wxID_ANY, SupportText, "https://forums.dolphin-emu.org/");

	wxFont DolphinFont = Dolphin->GetFont();
	wxFont RevisionFont = Revision->GetFont();
	wxFont CopyrightFont = Copyright->GetFont();
	wxFont BranchFont = Branch->GetFont();

	DolphinFont.SetPointSize(36);
	Dolphin->SetFont(DolphinFont);

	RevisionFont.SetWeight(wxFONTWEIGHT_BOLD);
	Revision->SetFont(RevisionFont);

	Revision->SetEditable(false);
	Revision->SetWindowStyle(wxNO_BORDER);

	BranchFont.SetPointSize(7);
	Branch->SetFont(BranchFont);

	Branch->SetEditable(false);
	Branch->AppendText(BranchText + "\n");
	Branch->AppendText(BranchRevText + "\n");
	Branch->AppendText(CompiledText);

	CopyrightFont.SetPointSize(7);
	Copyright->SetFont(CopyrightFont);
	Copyright->SetFocus();

	wxBoxSizer* const sCheckUpdates = new wxBoxSizer(wxHORIZONTAL);
	sCheckUpdates->Add(UpdateText);
	sCheckUpdates->Add(Download);

	wxBoxSizer* const sLinks = new wxBoxSizer(wxHORIZONTAL);
	sLinks->Add(License);
	sLinks->Add(FirstSpacer);
	sLinks->Add(Authors);
	sLinks->Add(SecondSpacer);
	sLinks->Add(Support);

	wxBoxSizer* const sInfo = new wxBoxSizer(wxVERTICAL);
	sInfo->Add(Dolphin);
	sInfo->AddSpacer(5);
	sInfo->Add(Revision);
	sInfo->AddSpacer(10);
	sInfo->Add(Branch);
	sInfo->Add(sCheckUpdates);
	sInfo->Add(Message);
	sInfo->Add(sLinks);

	wxBoxSizer* const sLogo = new wxBoxSizer(wxVERTICAL);
	sLogo->AddSpacer(75);
	sLogo->Add(sbDolphinLogo);
	sLogo->AddSpacer(40);

	wxBoxSizer* const sMainHor = new wxBoxSizer(wxHORIZONTAL);
	sMainHor->AddSpacer(30);
	sMainHor->Add(sLogo);
	sMainHor->AddSpacer(30);
	sMainHor->Add(sInfo);
	sMainHor->AddSpacer(30);

	wxBoxSizer* const sFooter = new wxBoxSizer(wxVERTICAL);
	sFooter->AddSpacer(15);
	sFooter->Add(Copyright, 0, wxALIGN_BOTTOM | wxALIGN_CENTER);
	sFooter->AddSpacer(5);

	wxBoxSizer* const sMain = new wxBoxSizer(wxVERTICAL);
	sMain->Add(sMainHor, 1, wxEXPAND);
	sMain->Add(sFooter, 0, wxEXPAND);

	SetSizerAndFit(sMain);
	Center();
	SetFocus();
}
Exemple #9
0
void DendrogramPanel::init() {
    
    isLayerValid = false;
    
    wxSize sz = this->GetClientSize();
    double hh = sz.y;
    double ww = sz.x;
    
    for (int i=0; i<end_nodes.size(); i++) {
        delete end_nodes[i];
    }
    end_nodes.clear();
    
    
    if (layer_bm == NULL) {
        double scale_factor = GetContentScaleFactor();
        layer_bm = new wxBitmap;
        layer_bm->CreateScaled(ww, hh, 32, scale_factor);
    }
    
    margin = 10.0;
    
    heightPerLeaf = (hh - margin - margin) / (double)leaves;
    widthPerLevel = (ww - margin - margin)/ (double)levels;
    
    currentY = 10;
    
    wxMemoryDC dc;
    dc.SelectObject(*layer_bm);
    dc.Clear();
    dc.SetFont(*GdaConst::extra_small_font);
    
    int start_y = 0;
    accessed_node.clear();
    
    
    bool draw_node = nelements < 10000;
    if (draw_node) {
        doDraw(dc, -(nelements-2) - 1, start_y);
    } else {
        wxString nodraw_msg = _("(Dendrogram is too complex to draw. Please view clustering results in map.)");
        dc.DrawText(nodraw_msg, 20, 20);
    }

    // draw verticle line
    if (!isMovingSplitLine) {
        int v_start =  ww - margin - 30 - (ww - 2*margin - 30) * cutoffDistance / maxDistance;
        wxPoint v_p0(v_start, 0);
        wxPoint v_p1(v_start, hh);
        if (split_line == NULL) {
            split_line = new DendroSplitLine(v_p0, v_p1);
        } else {
            split_line->update(v_p0, v_p1);
        }
    }
    
    
    dc.SelectObject(wxNullBitmap);
    
    isLayerValid = true;
    Refresh();
}