Exemplo n.º 1
0
void dlgAbout::OnInit( wxInitDialogEvent& event )
{
    wxBitmap splashBitmap = wxBITMAP_PNG_FROM_DATA(splash);
    imgLogo->SetBitmap(splashBitmap);
	wxString msg;
    msg << "Version: " << LMS_GetLibraryVersion() << "\n";
    msg << "Build date: " << LMS_GetBuildTimestamp();
	txtVersion->SetLabel(msg);
	txtDescription->SetLabel("");
}
Exemplo n.º 2
0
//-----------------------------------------------------------------------------
// SBGuideIndicators - info about the most recent guide commands
//
SBGuideIndicators::SBGuideIndicators(SBPanel* panel, std::vector<int>& fldWidths)
{
#ifdef ICON_DEV
    wxIcon arrow = wxIcon("SB_arrow_left_16.png", wxBITMAP_TYPE_PNG, 16, 16);
    arrowLeft.CopyFromIcon(arrow);
    arrow = wxIcon("SB_arrow_right_16.png", wxBITMAP_TYPE_PNG, 16, 16);
    arrowRight.CopyFromIcon(arrow);
    arrow = wxIcon("SB_arrow_up_16.png", wxBITMAP_TYPE_PNG, 16, 16);
    arrowUp.CopyFromIcon(arrow);
    arrow = wxIcon("SB_arrow_down_16.png", wxBITMAP_TYPE_PNG, 16, 16);
    arrowDown.CopyFromIcon(arrow);
#else
    arrowLeft = (wxBITMAP_PNG_FROM_DATA(sb_arrow_left_16));
    arrowRight = wxBitmap(wxBITMAP_PNG_FROM_DATA(sb_arrow_right_16));
    arrowUp = wxBitmap(wxBITMAP_PNG_FROM_DATA(sb_arrow_up_16));
    arrowDown = wxBitmap(wxBITMAP_PNG_FROM_DATA(sb_arrow_down_16));
#endif
    int guideAmtWidth;
    int txtHeight;
    wxSize bitmapSize;

    wxColor fgColor(200, 200, 200);           // reduced brightness
    panel->GetTextExtent("5555 ms, 555 px", &guideAmtWidth, &txtHeight);

    // Use default positions for control creation - positioning is handled explicitly in PositionControls()
    bitmapRA = new wxStaticBitmap(panel, wxID_ANY, arrowLeft);
    bitmapSize = bitmapRA->GetSize();
    bitmapRA->Show(false);
    txtRaAmounts = new wxStaticText(panel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(guideAmtWidth, bitmapSize.y), wxALIGN_CENTER);
    txtRaAmounts->SetBackgroundColour(*wxBLACK);
    txtRaAmounts->SetForegroundColour(fgColor);
    txtDecAmounts = new wxStaticText(panel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(guideAmtWidth, bitmapSize.y), wxALIGN_RIGHT);
    txtDecAmounts->SetBackgroundColour(*wxBLACK);
    txtDecAmounts->SetForegroundColour(fgColor);
    bitmapDec = new wxStaticBitmap(panel, wxID_ANY, arrowUp);
    bitmapDec->Show(false);
    parentPanel = panel;
    // Since we don't want separators between the arrows and the text info, we lump the two together and treat them as one field for the purpose
    // of positioning
    fldWidths.push_back(bitmapSize.x + guideAmtWidth + 2 * panel->emWidth);          // RA info
    fldWidths.push_back(bitmapSize.x + guideAmtWidth + 2 * panel->emWidth);          // Dec info
}
Exemplo n.º 3
0
//--------------------------------------------------------------------------------------
// ---SBStateIndicators - the group of all app/session state controls, a mix of static text and bitmap controls
//
SBStateIndicators::SBStateIndicators(SBPanel* panel, std::vector<int>& fldWidths)
{
    parentPanel = panel;
    wxString labels[] = { _("Dark"), _("Cal"), wxEmptyString};

#ifdef ICON_DEV
    icoGreenLed = wxIcon("SB_led_green.ico", wxBITMAP_TYPE_ICO, 16, 16);
    icoYellowLed = wxIcon("SB_led_yellow.ico", wxBITMAP_TYPE_ICO, 16, 16);
    icoRedLed = wxIcon("SB_led_red.ico", wxBITMAP_TYPE_ICO, 16, 16);
#else
    wxBitmap led(wxBITMAP_PNG_FROM_DATA(sb_led_green));
    icoGreenLed.CopyFromBitmap(led);
    led = wxBitmap(wxBITMAP_PNG_FROM_DATA(sb_led_yellow));
    icoYellowLed.CopyFromBitmap(led);
    led = wxBitmap(wxBITMAP_PNG_FROM_DATA(sb_led_red));
    icoRedLed.CopyFromBitmap(led);
#endif
    for (int inx = (int)Field_Darks; inx <= (int)Field_Gear; inx++)
    {
        SBStateIndicatorItem* item = new SBStateIndicatorItem(parentPanel, this, inx, labels[inx - Field_Darks], (SBFieldTypes)(inx), fldWidths);
        stateItems.push_back(item);
        item->UpdateState();
    }
}
Exemplo n.º 4
0
bool lms7suiteApp::OnInit()
{
    wxInitAllImageHandlers();
    wxBitmap splashBitmap = wxBITMAP_PNG_FROM_DATA(splash);
    wxSplashScreen* splash = new wxSplashScreen(splashBitmap,
        wxSPLASH_CENTRE_ON_SCREEN,
        6000, NULL, -1, wxDefaultPosition, wxDefaultSize,
        wxSIMPLE_BORDER | wxSTAY_ON_TOP);
    wxYield(); //linux needs this to load splash image
    wxLongLong t1 = wxGetUTCTimeMillis();
    LMS7SuiteAppFrame* frame = new LMS7SuiteAppFrame(0L);
#ifndef NDEBUG
    std::cout << "Create time " << (wxGetUTCTimeMillis() - t1).ToString() << " ms\n";
#endif
    splash->Destroy();
    frame->SetIcon(wxICON(LMS_ICO));
    frame->Show();
    return true;
}
Exemplo n.º 5
0
ProfileWizard::ProfileWizard(wxWindow *parent, bool firstLight) :
    wxDialog(parent, wxID_ANY, _("New Profile Wizard"), wxDefaultPosition, wxDefaultSize, wxCAPTION | wxCLOSE_BOX),
    m_launchDarks(true)
{
    TitlePrefix = _("New Profile Wizard - ");

    // Create overall vertical sizer
    m_pvSizer = new wxBoxSizer(wxVERTICAL);

#   include "icons/phd2_48.png.h"
    wxBitmap phd2(wxBITMAP_PNG_FROM_DATA(phd2_48));
    m_bitmaps[STATE_GREETINGS] = new wxBitmap(phd2);
    m_bitmaps[STATE_WRAPUP] = new wxBitmap(phd2);
#   include "icons/cam2.xpm"
    m_bitmaps[STATE_CAMERA] = new wxBitmap(cam_icon);
#   include "icons/scope1.xpm"
    m_bitmaps[STATE_MOUNT] = new wxBitmap(scope_icon);
    m_bitmaps[STATE_AUXMOUNT] = new wxBitmap(scope_icon);
#   include "icons/ao.xpm"
    m_bitmaps[STATE_AO] = new wxBitmap(ao_xpm);
#ifndef  __WXGTK__  // this resizing make a later crash in UpdateState with wxGtk
    m_bitmaps[STATE_CAMERA]->SetWidth(55);
    m_bitmaps[STATE_CAMERA]->SetHeight(55);
    m_bitmaps[STATE_MOUNT]->SetWidth(55);
    m_bitmaps[STATE_MOUNT]->SetHeight(55);
    m_bitmaps[STATE_AUXMOUNT]->SetWidth(55);
    m_bitmaps[STATE_AUXMOUNT]->SetHeight(55);
#endif // __WXGTK__

    // Build the superset of UI controls, minus state-specific labels and data
    // User instructions at top
    wxBoxSizer *instrSizer = new wxBoxSizer(wxHORIZONTAL);
    m_bitmap = new wxStaticBitmap(this, wxID_ANY, *m_bitmaps[STATE_GREETINGS], wxDefaultPosition, wxSize(55, 55));
    instrSizer->Add(m_bitmap, 0, wxALIGN_CENTER_VERTICAL | wxFIXED_MINSIZE, 5);

    m_pInstructions = new wxStaticText(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(DialogWidth, 75), wxALIGN_LEFT | wxST_NO_AUTORESIZE);
    wxFont font = m_pInstructions->GetFont();
    font.SetWeight(wxFONTWEIGHT_BOLD);
    m_pInstructions->SetFont(font);
    instrSizer->Add(m_pInstructions, wxSizerFlags().Border(wxALL, 10));
    m_pvSizer->Add(instrSizer);

    // Verbose help block
    m_pHelpGroup = new wxStaticBoxSizer(wxVERTICAL, this, _("More Info"));
    m_pHelpText = new wxStaticText(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(DialogWidth, -1));
    // Vertical sizing of help text will be handled in state machine
    m_pHelpGroup->Add(m_pHelpText, wxSizerFlags().Border(wxLEFT, 10).Border(wxBOTTOM, 10));
    m_pvSizer->Add(m_pHelpGroup, wxSizerFlags().Border(wxALL, 5));

    // Gear label and combo box
    m_pGearGrid = new wxFlexGridSizer(1, 2, 5, 15);
    m_pGearLabel = new wxStaticText(this, wxID_ANY, "Temp:", wxDefaultPosition, wxDefaultSize);
    m_pGearChoice = new wxChoice(this, ID_COMBO, wxDefaultPosition, wxDefaultSize,
                              GuideCamera::List(), 0, wxDefaultValidator, _("Gear"));
    m_pGearGrid->Add(m_pGearLabel, 1, wxALL, 5);
    m_pGearGrid->Add(m_pGearChoice, 1, wxLEFT, 10);
    m_pvSizer->Add(m_pGearGrid, wxSizerFlags().Center().Border(wxALL, 5));

    // Control for pixel-size and focal length
    m_pUserProperties = new wxFlexGridSizer(3, 2, 5, 15);
    m_pPixelSize = new wxSpinCtrlDouble(this, ID_PIXELSIZE, wxEmptyString, wxDefaultPosition,
                                          wxDefaultSize, wxSP_ARROW_KEYS, 0.0, 20.0, 0.0, 0.1);
    m_pPixelSize->SetDigits(2);
    m_PixelSize = m_pPixelSize->GetValue();
    m_pPixelSize->SetToolTip(_("Click Detect to read the pixel size from the camera. Otherwise, you can get this value from your camera documentation or from an online source.  You can use the up/down control "
        "or type in a value directly."));
    m_detectPixelSizeBtn = new wxButton(this, ID_DETECT_PIXELSIZE, _("Detect"));
    m_detectPixelSizeBtn->Enable(false);
    m_detectPixelSizeBtn->SetToolTip(_("Connect to camera and detect pixel size"));
    wxBoxSizer *sizer = new wxBoxSizer(wxHORIZONTAL);
    sizer->Add(m_pPixelSize, 1);
    sizer->Add(m_detectPixelSizeBtn, 0, wxLEFT, 10);
    AddTableEntryPair(this, m_pUserProperties, _("Guide camera un-binned pixel size (microns)"), sizer);
    m_pFocalLength = new wxSpinCtrlDouble(this, ID_FOCALLENGTH, _T("foo2"), wxDefaultPosition,
        wxDefaultSize, wxSP_ARROW_KEYS, 50, 3000, 300, 50);
    m_pFocalLength->SetValue(300);
    m_pFocalLength->SetDigits(0);
    m_pFocalLength->SetToolTip(_("This is the focal length of the guide scope - or the imaging scope if you are using an off-axis-guider or "
        "an adaptive optics device.  You can use the up/down control or type in a value directly."));
    m_FocalLength = (int) m_pFocalLength->GetValue();
    AddTableEntryPair(this, m_pUserProperties, _("Guide scope focal length (mm)"), m_pFocalLength);
    m_pGuideSpeed = new wxSpinCtrlDouble(this, ID_GUIDESPEED, wxEmptyString, wxDefaultPosition,
        wxDefaultSize, wxSP_ARROW_KEYS, 0.2, 1.0, 0.5, 0.1);
    m_pGuideSpeed->SetValue(0.5);
    m_GuideSpeed = 0.5;
    m_pGuideSpeed->SetDigits(2);
    m_pGuideSpeed->SetToolTip(_("The mount guide speed you will use for calibration and guiding, expressed as a multiple of the sidereal rate. If you "
        "don't know, leave the setting at the default value (0.5X)"));
    AddTableEntryPair(this, m_pUserProperties, _("Mount guide speed (n.n x sidereal)"), m_pGuideSpeed);
    m_pvSizer->Add(m_pUserProperties, wxSizerFlags().Center().Border(wxALL, 5));

    // Wrapup panel
    m_pWrapUp = new wxFlexGridSizer(2, 2, 5, 15);
    m_pProfileName = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(250,-1));
    m_pLaunchDarks = new wxCheckBox(this, wxID_ANY, _("Build dark library"));
    m_pLaunchDarks->SetValue(m_launchDarks);
    m_pLaunchDarks->SetToolTip(_("Check this to automatically start the process of building a dark library for this profile."));
    AddTableEntryPair(this, m_pWrapUp, _("Profile Name"), m_pProfileName);
    m_pWrapUp->Add(m_pLaunchDarks, wxSizerFlags().Border(wxTOP, 5).Border(wxLEFT, 10));
    m_pvSizer->Add(m_pWrapUp, wxSizerFlags().Border(wxALL, 10).Expand().Center());

    // Row of buttons for prev, help, next
    wxBoxSizer *pButtonSizer = new wxBoxSizer(wxHORIZONTAL);
    m_pPrevBtn = new wxButton(this, ID_PREV, _("< Back"));
    m_pPrevBtn->SetToolTip(_("Back up to the previous screen"));

    m_pNextBtn = new wxButton(this, ID_NEXT, _("Next >"));
    m_pNextBtn->SetToolTip(_("Move forward to next screen"));

    pButtonSizer->AddStretchSpacer();
    pButtonSizer->Add(
        m_pPrevBtn,
        wxSizerFlags(0).Align(0).Border(wxALL, 5));
    pButtonSizer->Add(
        m_pNextBtn,
        wxSizerFlags(0).Align(0).Border(wxALL, 5));
    m_pvSizer->Add(pButtonSizer, wxSizerFlags().Expand().Border(wxALL, 10));

    // Status bar for error messages
    m_pStatusBar = new wxStatusBar(this, -1);
    m_pStatusBar->SetFieldsCount(1);
    m_pvSizer->Add(m_pStatusBar, 0, wxGROW);

    SetAutoLayout(true);
    SetSizerAndFit(m_pvSizer);
    // Special cases - neither AuxMount nor AO requires an explicit user choice
    m_SelectedAuxMount = _("None");
    m_SelectedAO = _("None");
    if (firstLight)
        m_State = STATE_GREETINGS;
    else
        m_State = STATE_CAMERA;
    UpdateState(0);
}
Exemplo n.º 6
0
AboutDialog::AboutDialog(void) :
wxDialog(pFrame, wxID_ANY, _T("About ") APPNAME, wxDefaultPosition, wxDefaultSize, wxCAPTION | wxCLOSE_BOX)
{
    SetBackgroundColour(*wxWHITE);

    wxBoxSizer *pSizer = new wxBoxSizer(wxHORIZONTAL);

    #include "icons/phd2_64.png.h"
    wxBitmap phd2(wxBITMAP_PNG_FROM_DATA(phd2_64));
    wxStaticBitmap *pImage = new wxStaticBitmap(this, wxID_ANY, phd2);

    wxFileSystem::AddHandler(new wxMemoryFSHandler);
    wxMemoryFSHandler::AddFile("about.html", wxString::Format(
        "<html><body>"
        "<h3>%s %s</h3>"
        "<a href=\"http://openphdguiding.org\">PHD2 home page - openphdguiding.org</a><br>"
        "<a href=\"https://github.com/OpenPHDGuiding\">PHD2 open source project page</a><br><br>"
        "<font size=\"2\">"
        "Credits:<br>"
        "<table>"
        "<tr>"
        "<td>Craig Stark</td>"
        "<td>Bret McKee</td>"
        "</tr>"
        "<tr>"
        "<td>Andy Galasso</td>"
        "<td>Bernhard Reutner-Fischer</td>"
        "</tr>"
        "<tr>"
        "<td>Stefan Elste</td>"
        "<td>Geoffrey Hausheer</td>"
        "</tr>"
        "<tr>"
        "<td>Jared Wellman</td>"
        "<td>John Wainwright</td>"
        "</tr>"
        "<tr>"
        "<td>Sylvain Girard</td>"
        "<td>Bruce Waddington</td>"
        "</tr>"
        "<tr>"
        "<td>Max Chen</td>"
        "<td>Carsten Przygoda</td>"
        "</tr>"
        "<tr>"
        "<td>Hans Lambermont</td>"
        "<td>David Ault</td>"
        "</tr>"
        "<tr>"
        "<td>Markus Wieczorek</td>"
        "<td>Linkage</td>"
        "</tr>"
        "<tr>"
        "<td>Robin Glover</td>"
        "<td>Patrick Chevalley</td>"
        "</tr>"
        "<tr>"
        "<td>Scott Edwards</td>"
        "<td>Eiji Kaneshige</td>"
        "</tr>"
        "<tr>"
        "<td>Konstantin Menshikoff</td>"
        "<td>Jakub Bartas</td>"
        "</tr>"
        "<tr>"
        "<td>Javier R</td>"
        "<td>Oleh Malyi</td>"
        "</tr>"
        "<tr>"
        "<td>Tsung-Chi Wu</td>"
        "<td>Raffi Enficiaud</td>"
        "</tr>"
        "<tr>"
        "<td>Sabin Fota</td>"
        "<td>Dylan O'Donnell</td>"
        "</tr>"
        "<tr>"
        "<td>Katsuhiro Kojima</td>"
        "<td>Simon Taylor</td>"
        "</tr>"
        "<tr>"
        "<td>Hallgeir Holien</td>"
        "<td>Laurent Schmitz</td>"
        "</tr>"
        "<tr>"
        "<td>Atushi Sakauchi</td>"
        "<td>Giorgio Mazzacurati</td>"
        "</tr>"
        "<tr>"
        "<td>G\u00FCnter Scholz</td>"
        "<td>Ray Gralak</td>"
        "</tr>"
        "<tr>"
        "<td>Khalefa Algadi</td>"
        "<td></td>"
        "</tr>"
        "</table><br>"
        "<br>"
        "<br>"
        "Copyright 2006-2013 Craig Stark<br>"
        "Copyright 2009 Geoffrey Hausheer<br>"
        "Copyright 2012-2013 Bret McKee<br>"
        "Copyright 2013 Sylvain Girard<br>"
        "Copyright 2013-2016 Andy Galasso<br>"
        "Copyright 2013-2016 Bruce Waddington<br>"
        "Copyright 2014 Hans Lambermont<br>"
        "Copyright 2014 Robin Glover<br>"
        "Copyright 2014-2015 Max Planck Society<br>"
        "</font>"
        "</body></html>", APPNAME, FULLVER));
    wxHtmlWindow *pHtml;
    pHtml = new wxHtmlWindow(this, ABOUT_LINK, wxDefaultPosition, wxSize(380, 540), wxHW_SCROLLBAR_AUTO);
    pHtml->SetBorders(0);
    pHtml->LoadPage("memory:about.html");
    pHtml->SetSize(pHtml->GetInternalRepresentation()->GetWidth(), pHtml->GetInternalRepresentation()->GetHeight());

    pSizer->Add(pImage, wxSizerFlags(0).Border(wxALL, 10));
    pSizer->Add(pHtml, wxSizerFlags(0).Border(wxALL, 10));

    wxBoxSizer *pTopLevelSizer = new wxBoxSizer(wxVERTICAL);
    pTopLevelSizer->Add(pSizer, wxSizerFlags(0).Expand());
    pTopLevelSizer->Add(CreateButtonSizer(wxOK), wxSizerFlags(0).Expand().Border(wxALL, 10));
    SetSizerAndFit(pTopLevelSizer);
}
Exemplo n.º 7
0
MyCanvas::MyCanvas( wxWindow *parent, wxWindowID id,
                    const wxPoint &pos, const wxSize &size )
    : wxScrolledWindow( parent, id, pos, size, wxSUNKEN_BORDER )
    , m_bmpSmileXpm(smile_xpm)
    , m_iconSmileXpm(smile_xpm)
{
    my_horse_ani = NULL;
    m_ani_images = 0 ;

    SetBackgroundColour(* wxWHITE);

    wxBitmap bitmap( 100, 100 );

    wxMemoryDC dc;
    dc.SelectObject( bitmap );
    dc.SetBrush( wxBrush( wxS("orange") ) );
    dc.SetPen( *wxBLACK_PEN );
    dc.DrawRectangle( 0, 0, 100, 100 );
    dc.SetBrush( *wxWHITE_BRUSH );
    dc.DrawRectangle( 20, 20, 60, 60 );
    dc.SelectObject( wxNullBitmap );

    // try to find the directory with our images
    wxString dir;
    if ( wxFile::Exists(wxT("./horse.png")) )
        dir = wxT("./");
    else if ( wxFile::Exists(wxT("../horse.png")) )
        dir = wxT("../");
    else
        wxLogWarning(wxT("Can't find image files in either '.' or '..'!"));

    wxImage image = bitmap.ConvertToImage();

#if wxUSE_LIBPNG
    if ( !image.SaveFile( dir + wxT("test.png"), wxBITMAP_TYPE_PNG ))
    {
        wxLogError(wxT("Can't save file"));
    }

    image.Destroy();

    if ( image.LoadFile( dir + wxT("test.png") ) )
        my_square = wxBitmap( image );

    image.Destroy();

    if ( !image.LoadFile( dir + wxT("horse.png")) )
    {
        wxLogError(wxT("Can't load PNG image"));
    }
    else
    {
        my_horse_png = wxBitmap( image );
    }

    if ( !image.LoadFile( dir + wxT("toucan.png")) )
    {
        wxLogError(wxT("Can't load PNG image"));
    }
    else
    {
        my_toucan = wxBitmap(image);
    }

    my_toucan_flipped_horiz = wxBitmap(image.Mirror(true));
    my_toucan_flipped_vert = wxBitmap(image.Mirror(false));
    my_toucan_flipped_both = wxBitmap(image.Mirror(true).Mirror(false));
    my_toucan_grey = wxBitmap(image.ConvertToGreyscale());
    my_toucan_head = wxBitmap(image.GetSubImage(wxRect(40, 7, 80, 60)));
    my_toucan_scaled_normal = wxBitmap(image.Scale(110,90,wxIMAGE_QUALITY_NORMAL));
    my_toucan_scaled_high = wxBitmap(image.Scale(110,90,wxIMAGE_QUALITY_HIGH));
    my_toucan_blur = wxBitmap(image.Blur(10));

#endif // wxUSE_LIBPNG

#if wxUSE_LIBJPEG
    image.Destroy();

    if ( !image.LoadFile( dir + wxT("horse.jpg")) )
    {
        wxLogError(wxT("Can't load JPG image"));
    }
    else
    {
        my_horse_jpeg = wxBitmap( image );

        // Colorize by rotating green hue to red
        wxImage::HSVValue greenHSV = wxImage::RGBtoHSV(wxImage::RGBValue(0, 255, 0));
        wxImage::HSVValue redHSV = wxImage::RGBtoHSV(wxImage::RGBValue(255, 0, 0));
        image.RotateHue(redHSV.hue - greenHSV.hue);
        colorized_horse_jpeg = wxBitmap( image );
    }

    if ( !image.LoadFile( dir + wxT("cmyk.jpg")) )
    {
        wxLogError(wxT("Can't load CMYK JPG image"));
    }
    else
    {
        my_cmyk_jpeg = wxBitmap(image);
    }
#endif // wxUSE_LIBJPEG

#if wxUSE_GIF
    image.Destroy();

    if ( !image.LoadFile( dir + wxT("horse.gif" )) )
    {
        wxLogError(wxT("Can't load GIF image"));
    }
    else
    {
        my_horse_gif = wxBitmap( image );
    }
#endif

#if wxUSE_PCX
    image.Destroy();

    if ( !image.LoadFile( dir + wxT("horse.pcx"), wxBITMAP_TYPE_PCX ) )
    {
        wxLogError(wxT("Can't load PCX image"));
    }
    else
    {
        my_horse_pcx = wxBitmap( image );
    }
#endif

    image.Destroy();

    if ( !image.LoadFile( dir + wxT("horse.bmp"), wxBITMAP_TYPE_BMP ) )
    {
        wxLogError(wxT("Can't load BMP image"));
    }
    else
    {
        my_horse_bmp = wxBitmap( image );
    }

#if wxUSE_XPM
    image.Destroy();

    if ( !image.LoadFile( dir + wxT("horse.xpm"), wxBITMAP_TYPE_XPM ) )
    {
        wxLogError(wxT("Can't load XPM image"));
    }
    else
    {
        my_horse_xpm = wxBitmap( image );
    }

    if ( !image.SaveFile( dir + wxT("test.xpm"), wxBITMAP_TYPE_XPM ))
    {
        wxLogError(wxT("Can't save file"));
    }
#endif

#if wxUSE_PNM
    image.Destroy();

    if ( !image.LoadFile( dir + wxT("horse.pnm"), wxBITMAP_TYPE_PNM ) )
    {
        wxLogError(wxT("Can't load PNM image"));
    }
    else
    {
        my_horse_pnm = wxBitmap( image );
    }

    image.Destroy();

    if ( !image.LoadFile( dir + wxT("horse_ag.pnm"), wxBITMAP_TYPE_PNM ) )
    {
        wxLogError(wxT("Can't load PNM image"));
    }
    else
    {
        my_horse_asciigrey_pnm = wxBitmap( image );
    }

    image.Destroy();

    if ( !image.LoadFile( dir + wxT("horse_rg.pnm"), wxBITMAP_TYPE_PNM ) )
    {
        wxLogError(wxT("Can't load PNM image"));
    }
    else
    {
        my_horse_rawgrey_pnm = wxBitmap( image );
    }
#endif

#if wxUSE_LIBTIFF
    image.Destroy();

    if ( !image.LoadFile( dir + wxT("horse.tif"), wxBITMAP_TYPE_TIFF ) )
    {
        wxLogError(wxT("Can't load TIFF image"));
    }
    else
    {
        my_horse_tiff = wxBitmap( image );
    }
#endif

#if wxUSE_LIBTIFF
    image.Destroy();

    if ( !image.LoadFile( dir + wxT("horse.tga"), wxBITMAP_TYPE_TGA ) )
    {
        wxLogError(wxT("Can't load TGA image"));
    }
    else
    {
        my_horse_tga = wxBitmap( image );
    }
#endif

    CreateAntiAliasedBitmap();

    my_smile_xbm = wxBitmap( (const char*)smile_bits, smile_width,
                                smile_height, 1 );

    // demonstrates XPM automatically using the mask when saving
    if ( m_bmpSmileXpm.IsOk() )
        m_bmpSmileXpm.SaveFile(wxT("saved.xpm"), wxBITMAP_TYPE_XPM);

#if wxUSE_ICO_CUR
    image.Destroy();

    if ( !image.LoadFile( dir + wxT("horse.ico"), wxBITMAP_TYPE_ICO, 0 ) )
    {
        wxLogError(wxT("Can't load first ICO image"));
    }
    else
    {
        my_horse_ico32 = wxBitmap( image );
    }

    image.Destroy();

    if ( !image.LoadFile( dir + wxT("horse.ico"), wxBITMAP_TYPE_ICO, 1 ) )
    {
        wxLogError(wxT("Can't load second ICO image"));
    }
    else
    {
        my_horse_ico16 = wxBitmap( image );
    }

    image.Destroy();

    if ( !image.LoadFile( dir + wxT("horse.ico") ) )
    {
        wxLogError(wxT("Can't load best ICO image"));
    }
    else
    {
        my_horse_ico = wxBitmap( image );
    }

    image.Destroy();

    if ( !image.LoadFile( dir + wxT("horse.cur"), wxBITMAP_TYPE_CUR ) )
    {
        wxLogError(wxT("Can't load best ICO image"));
    }
    else
    {
        my_horse_cur = wxBitmap( image );
        xH = 30 + image.GetOptionInt(wxIMAGE_OPTION_CUR_HOTSPOT_X) ;
        yH = 2420 + image.GetOptionInt(wxIMAGE_OPTION_CUR_HOTSPOT_Y) ;
    }

    m_ani_images = wxImage::GetImageCount ( dir + wxT("horse3.ani"), wxBITMAP_TYPE_ANI );
    if (m_ani_images==0)
    {
        wxLogError(wxT("No ANI-format images found"));
    }
    else
    {
        my_horse_ani = new wxBitmap [m_ani_images];
    }

    int i;
    for (i=0; i < m_ani_images; i++)
    {
        image.Destroy();
        if (!image.LoadFile( dir + wxT("horse3.ani"), wxBITMAP_TYPE_ANI, i ))
        {
            wxString tmp = wxT("Can't load image number ");
            tmp << i ;
            wxLogError(tmp);
        }
        else
            my_horse_ani [i] = wxBitmap( image );
    }
#endif // wxUSE_ICO_CUR


    image.Destroy();

    // test image loading from stream
    wxFile file(dir + wxT("horse.bmp"));
    if ( file.IsOpened() )
    {
        wxFileOffset len = file.Length();
        size_t dataSize = (size_t)len;
        void *data = malloc(dataSize);
        if ( file.Read(data, dataSize) != len )
        {
            wxLogError(wxT("Reading bitmap file failed"));
        }
        else
        {
            wxMemoryInputStream mis(data, dataSize);
            if ( !image.LoadFile(mis) )
            {
                wxLogError(wxT("Can't load BMP image from stream"));
            }
            else
            {
                my_horse_bmp2 = wxBitmap( image );
            }
        }

        free(data);
    }

    // This macro loads PNG from either resources on the platforms that support
    // this (Windows and OS X) or from in-memory data (coming from cursor_png.c
    // included above in our case).
    my_png_from_res = wxBITMAP_PNG(cursor);

    // This one always loads PNG from memory but exists for consistency with
    // the above one and also because it frees you from the need to specify the
    // length explicitly, without it you'd have to do it and also spell the
    // array name in full, like this:
    //
    // my_png_from_mem = wxBitmap::NewFromPNGData(cursor_png, WXSIZEOF(cursor_png));
    my_png_from_mem = wxBITMAP_PNG_FROM_DATA(cursor);
}
Exemplo n.º 8
0
PicturesAssistPanel::PicturesAssistPanel(wxWindow* parent, wxWindowID id,const wxPoint& pos,const wxSize& size)
: mPaintMode(xlGridCanvasPictures::PAINT_PENCIL),
  mPaintColor(xlRED)
{
    paint_pencil = wxBITMAP_PNG_FROM_DATA(pencil);
    paint_pencil_selected = wxBITMAP_PNG_FROM_DATA(pencil_sel);
    paint_eraser = wxBITMAP_PNG_FROM_DATA(eraser);
    paint_eraser_selected = wxBITMAP_PNG_FROM_DATA(eraser_sel);
    paint_eyedropper = wxBITMAP_PNG_FROM_DATA(eyedropper);
    paint_eyedropper_selected = wxBITMAP_PNG_FROM_DATA(eyedropper_sel);
    paint_selectcopy = wxBITMAP_PNG_FROM_DATA(selectcopy);
    paint_selectcopy_selected = wxBITMAP_PNG_FROM_DATA(selectcopy_sel);

	//(*Initialize(PicturesAssistPanel)
	wxFlexGridSizer* FlexGridSizer2;
	wxFlexGridSizer* PaintToolsSizer;
	wxFlexGridSizer* PaintFuntionsSizer;
	wxFlexGridSizer* FlexGridSizer3;
	wxFlexGridSizer* ColorPickerSizer;

	Create(parent, id, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL|wxWANTS_CHARS, _T("id"));
	FlexGridSizer1 = new wxFlexGridSizer(1, 1, 0, 0);
	Panel_Sizer = new wxPanel(this, ID_PANEL1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL|wxWANTS_CHARS, _T("ID_PANEL1"));
	FlexGridSizer2 = new wxFlexGridSizer(0, 1, 0, 0);
	ScrolledWindowEffectAssist = new wxScrolledWindow(Panel_Sizer, ID_SCROLLED_EffectAssist, wxDefaultPosition, wxDefaultSize, wxWANTS_CHARS|wxVSCROLL|wxHSCROLL, _T("ID_SCROLLED_EffectAssist"));
	FlexGridSizer_Container = new wxFlexGridSizer(0, 2, 0, 0);
	FlexGridSizer_Container->AddGrowableCol(0);
	FlexGridSizer_Container->AddGrowableRow(0);
	Panel_RightSide = new wxPanel(ScrolledWindowEffectAssist, ID_PANEL_RightSide, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL, _T("ID_PANEL_RightSide"));
	FlexGridSizer_RightSide = new wxFlexGridSizer(0, 1, 0, 0);
	ColorPickerSizer = new wxFlexGridSizer(0, 1, 0, 0);
	FlexGridSizer_RightSide->Add(ColorPickerSizer, 1, wxALL|wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 5);
	PaintToolsSizer = new wxFlexGridSizer(0, 4, 0, 10);
	FlexGridSizer_RightSide->Add(PaintToolsSizer, 1, wxALL|wxEXPAND, 5);
	PaintFuntionsSizer = new wxFlexGridSizer(0, 1, 0, 0);
	FlexGridSizer3 = new wxFlexGridSizer(0, 6, 0, 0);
	Button_NewImage = new wxButton(Panel_RightSide, ID_BUTTON_NewImage, _("New\nImage"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_BUTTON_NewImage"));
	FlexGridSizer3->Add(Button_NewImage, 1, wxALL|wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 5);
	Button_LoadImage = new wxButton(Panel_RightSide, ID_BUTTON_LoadImage, _("Load\nImage"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_BUTTON_LoadImage"));
	FlexGridSizer3->Add(Button_LoadImage, 1, wxALL|wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 5);
	Button_SaveImage = new wxButton(Panel_RightSide, ID_BUTTON_SaveImage, _("Save\nImage"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_BUTTON_SaveImage"));
	FlexGridSizer3->Add(Button_SaveImage, 1, wxALL|wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 5);
	Button_SaveAs = new wxButton(Panel_RightSide, ID_BUTTON_SaveAs, _("Save As\nImage"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_BUTTON_SaveAs"));
	FlexGridSizer3->Add(Button_SaveAs, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
	Button_Resize = new wxButton(Panel_RightSide, ID_BUTTON1, _("Resize\nImage"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_BUTTON1"));
	FlexGridSizer3->Add(Button_Resize, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
	PaintFuntionsSizer->Add(FlexGridSizer3, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
	StaticText_CurrentImage = new wxStaticText(Panel_RightSide, ID_STATICTEXT_CurrentImage, _("Current Image:"), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT_CurrentImage"));
	PaintFuntionsSizer->Add(StaticText_CurrentImage, 1, wxALL|wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 5);
	StaticText_ImageSize = new wxStaticText(Panel_RightSide, ID_STATICTEXT_ImageSize, _("Image Size:"), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT_ImageSize"));
	PaintFuntionsSizer->Add(StaticText_ImageSize, 1, wxALL|wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 5);
	StaticText_ModelSize = new wxStaticText(Panel_RightSide, ID_STATICTEXT_ModelSize, _("Model Size:"), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT_ModelSize"));
	PaintFuntionsSizer->Add(StaticText_ModelSize, 1, wxALL|wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 5);
	FlexGridSizer_RightSide->Add(PaintFuntionsSizer, 1, wxALL|wxEXPAND, 5);
	Panel_RightSide->SetSizer(FlexGridSizer_RightSide);
	FlexGridSizer_RightSide->Fit(Panel_RightSide);
	FlexGridSizer_RightSide->SetSizeHints(Panel_RightSide);
	FlexGridSizer_Container->Add(Panel_RightSide, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
	ScrolledWindowEffectAssist->SetSizer(FlexGridSizer_Container);
	FlexGridSizer_Container->Fit(ScrolledWindowEffectAssist);
	FlexGridSizer_Container->SetSizeHints(ScrolledWindowEffectAssist);
	FlexGridSizer2->Add(ScrolledWindowEffectAssist, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
	Panel_Sizer->SetSizer(FlexGridSizer2);
	FlexGridSizer2->Fit(Panel_Sizer);
	FlexGridSizer2->SetSizeHints(Panel_Sizer);
	FlexGridSizer1->Add(Panel_Sizer, 1, wxALL|wxEXPAND, 5);
	SetSizer(FlexGridSizer1);
	FlexGridSizer1->Fit(this);
	FlexGridSizer1->SetSizeHints(this);

	Connect(ID_BUTTON_NewImage,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&PicturesAssistPanel::OnButton_NewImageClick);
	Connect(ID_BUTTON_LoadImage,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&PicturesAssistPanel::OnButton_LoadImageClick);
	Connect(ID_BUTTON_SaveImage,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&PicturesAssistPanel::OnButton_SaveImageClick);
	Connect(ID_BUTTON_SaveAs,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&PicturesAssistPanel::OnButton_SaveAsClick);
	Connect(ID_BUTTON1,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&PicturesAssistPanel::OnButton_ResizeClick);
	//*)

	//PanelEffectGrid = new xlGridCanvasEmpty(ScrolledWindowEffectAssist, ID_PANEL_EffectGrid, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL|wxFULL_REPAINT_ON_RESIZE, _T("ID_PANEL_EffectGrid"));
	//FlexGridSizer_Container->Insert(0, PanelEffectGrid, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);

    CreatePaintTools(Panel_RightSide, PaintToolsSizer);

    mColorPicker = new xlColorPickerFields(Panel_RightSide, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL, _T("ID_PANEL_ColorPicker"));
	ColorPickerSizer->Add(mColorPicker, 1, wxALL|wxALIGN_TOP|wxALIGN_CENTER_HORIZONTAL, 5);

	FlexGridSizer_RightSide->Fit(Panel_RightSide);
	FlexGridSizer_RightSide->SetSizeHints(Panel_RightSide);
	FlexGridSizer_Container->Fit(ScrolledWindowEffectAssist);
	FlexGridSizer_Container->SetSizeHints(ScrolledWindowEffectAssist);
	FlexGridSizer2->Fit(Panel_Sizer);
	FlexGridSizer2->SetSizeHints(Panel_Sizer);
	FlexGridSizer1->Fit(this);
	FlexGridSizer1->SetSizeHints(this);

    for (int i=wxEVT_SCROLLWIN_TOP; i<=wxEVT_SCROLLWIN_THUMBRELEASE; i++) {
        ScrolledWindowEffectAssist->Connect(wxID_ANY, i, wxScrollWinEventHandler(PicturesAssistPanel::OnWindowScrolled), NULL, this);
    }

}