void ImageResource::RenderPreview(wxPaintDC & dc, wxPanel & previewPanel, gd::Project & project)
{
    wxLogNull noLog; //We take care of errors.

    wxSize size = previewPanel.GetSize();

    //Checkerboard background
    dc.SetBrush(gd::CommonBitmapProvider::Get()->transparentBg);
    dc.DrawRectangle(0,0, size.GetWidth(), size.GetHeight());

    wxString fullFilename = GetAbsoluteFile(project);

    if ( !wxFile::Exists(fullFilename) )
        return;

    wxBitmap bmp( fullFilename, wxBITMAP_TYPE_ANY);
    if ( bmp.GetWidth() != 0 && bmp.GetHeight() != 0 && (bmp.GetWidth() > previewPanel.GetSize().x || bmp.GetHeight() > previewPanel.GetSize().y) )
    {
        //Rescale to fit in previewPanel
        float xFactor = static_cast<float>(previewPanel.GetSize().x)/static_cast<float>(bmp.GetWidth());
        float yFactor = static_cast<float>(previewPanel.GetSize().y)/static_cast<float>(bmp.GetHeight());
        float factor = std::min(xFactor, yFactor);

        wxImage image = bmp.ConvertToImage();
        if ( bmp.GetWidth()*factor >= 5 && bmp.GetHeight()*factor >= 5)
            bmp = wxBitmap(image.Scale(bmp.GetWidth()*factor, bmp.GetHeight()*factor));
    }

    //Display image in the center
    if ( bmp.IsOk() )
        dc.DrawBitmap(bmp,
                      (size.GetWidth() - bmp.GetWidth()) / 2,
                      (size.GetHeight() - bmp.GetHeight()) / 2,
                      true /* use mask */);
}
Beispiel #2
0
    ExampleFrame(
      wxApp& app,
      wxWindow* parent,
      const wxString& title,
      ExampleInfoDisplay* info_disp,
      wxGLContext* context)
      : wxFrame(parent, wxID_ANY, title, wxDefaultPosition, wxDefaultSize)
      , info_display(info_disp)
      , main_panel(
          new wxPanel(this, wxID_ANY, wxDefaultPosition, wxDefaultSize))
      , gl_canvas(
          new ExampleGLCanvas((wxEvtHandler*)this, (wxWindow*)main_panel))
      , gl_context(context)
      , frame_no(0)
      , fps_frame_no(0)
      , fps_time(0.0)
      , prim_count(0.0)
      , idle_call_count(0) {
        assert(info_display);
        assert(gl_canvas);
        assert(gl_context);

        wxBoxSizer* main_sizer = new wxBoxSizer(wxVERTICAL);
        main_panel->SetClientSize(800, 600);
        main_sizer->Add(main_panel, 1, wxEXPAND);

        wxStatusBar* status_bar = new wxStatusBar(this);
        main_sizer->Add(status_bar, 0, wxEXPAND);

        wxBoxSizer* gl_sizer = new wxBoxSizer(wxVERTICAL);
        gl_sizer->Add(gl_canvas, 1, wxEXPAND);
        main_panel->SetSizer(gl_sizer);

        SetSize(
          main_panel->GetSize().GetWidth(),
          main_panel->GetSize().GetHeight() +
            status_bar->GetSize().GetHeight());
        SetSizer(main_sizer);
        Layout();
        Show();

        gl_context->SetCurrent(*gl_canvas);

        // TODO: this won't work very well in "UNICODE" builds
        oglplus::ExampleParams params(app.argc, (char**)app.argv);
        example = oglplus::makeExample(params);
        os_clock.reset();

        HandleResize();

        Connect(wxEVT_CLOSE_WINDOW, wxCloseEventHandler(ExampleFrame::OnClose));
        Connect(wxEVT_MOTION, wxMouseEventHandler(ExampleFrame::OnMouseEvent));
        Connect(wxEVT_SIZE, wxSizeEventHandler(ExampleFrame::OnResize));
        SetExtraStyle(wxWS_EX_PROCESS_IDLE);
        wxIdleEvent::SetMode(wxIDLE_PROCESS_SPECIFIED);
        Connect(wxEVT_IDLE, wxIdleEventHandler(ExampleFrame::OnIdle));
    }
Beispiel #3
0
void rviewLookScaleDialog::OnSize(int w, int h)
{
    int x, y, aux, boff;

    GetClientSize(&x, &y);
    panel->SetSize(0, 0, x, y);
    aux = x - 3*lkscale_border - lkscale_bwidth;
    collName->SetSize(lkscale_border, lkscale_border, aux, lkscale_theight);
    scaleString->SetSize(lkscale_border, lkscale_border + lkscale_theight, aux, lkscale_theight);
    aux += 2*lkscale_border;
    boff = lkscale_border + lkscale_theight - lkscale_bheight;
    okBut->SetSize(aux, boff, lkscale_bwidth, lkscale_bheight);
    cancelBut->SetSize(aux, boff + lkscale_theight, lkscale_bwidth, lkscale_bheight);
}
Beispiel #4
0
bool wxNotificationMessageWindow::AddAction(wxWindowID actionid, const wxString &label)
{
    wxSizer* msgSizer = m_messagePanel->GetSizer();
    if ( m_buttonSizer == NULL )
    {
        msgSizer->Detach(m_closeBtn);
        m_closeBtn->Hide();
        m_buttonSizer = new wxBoxSizer(wxVERTICAL);
        msgSizer->Add(m_buttonSizer, wxSizerFlags(0).Center().Border());
    }

    wxButton* actionButton = new wxButton(m_messagePanel, actionid, label);
    actionButton->Bind(wxEVT_BUTTON, &wxNotificationMessageWindow::OnActionButtonClicked, this);
    PrepareNotificationControl(actionButton, false);
    int borderDir = (m_buttonSizer->GetChildren().empty()) ? 0 : wxTOP;
    m_buttonSizer->Add(actionButton, wxSizerFlags(0).Border(borderDir).Expand());

    return true;
}
Beispiel #5
0
void ObjectBottomBar::ShowActorViewer(bool show)
{
	m_ViewerPanel->Show(show);
	Layout();
}