Better image panel for custom header option

This commit is contained in:
Charles J. Cliffe 2016-11-01 22:29:58 -04:00
parent 979e5b709c
commit f0d829b6b3
6 changed files with 91 additions and 11 deletions

View File

@ -66,6 +66,7 @@ IF(CUBICSDR_ENABLE_VIEW_SCOPE)
ENDIF() ENDIF()
ADD_DEFINITIONS( ADD_DEFINITIONS(
-DCUBICSDR_INSTALL_NAME="${CUBICSDR_INSTALL_NAME}"
-DCUBICSDR_VERSION="${CUBICSDR_VERSION}" -DCUBICSDR_VERSION="${CUBICSDR_VERSION}"
-DCUBICSDR_BUILD_TITLE="${CUBICSDR_BUILD_TITLE}" -DCUBICSDR_BUILD_TITLE="${CUBICSDR_BUILD_TITLE}"
) )
@ -342,6 +343,7 @@ SET (cubicsdr_sources
src/visual/SpectrumCanvas.cpp src/visual/SpectrumCanvas.cpp
src/visual/WaterfallCanvas.cpp src/visual/WaterfallCanvas.cpp
src/visual/GainCanvas.cpp src/visual/GainCanvas.cpp
src/visual/ImagePanel.cpp
src/process/VisualProcessor.cpp src/process/VisualProcessor.cpp
src/process/ScopeVisualProcessor.cpp src/process/ScopeVisualProcessor.cpp
src/process/SpectrumVisualProcessor.cpp src/process/SpectrumVisualProcessor.cpp
@ -442,6 +444,7 @@ SET (cubicsdr_headers
src/visual/SpectrumCanvas.h src/visual/SpectrumCanvas.h
src/visual/WaterfallCanvas.h src/visual/WaterfallCanvas.h
src/visual/GainCanvas.h src/visual/GainCanvas.h
src/visual/ImagePanel.h
src/process/VisualProcessor.h src/process/VisualProcessor.h
src/process/ScopeVisualProcessor.h src/process/ScopeVisualProcessor.h
src/process/SpectrumVisualProcessor.h src/process/SpectrumVisualProcessor.h
@ -627,6 +630,8 @@ IF (MSVC)
set_target_properties(CubicSDR PROPERTIES LINK_FLAGS_MINSIZEREL "/SUBSYSTEM:WINDOWS") set_target_properties(CubicSDR PROPERTIES LINK_FLAGS_MINSIZEREL "/SUBSYSTEM:WINDOWS")
set_target_properties(CubicSDR PROPERTIES COMPILE_DEFINITIONS_MINSIZEREL "_WINDOWS") set_target_properties(CubicSDR PROPERTIES COMPILE_DEFINITIONS_MINSIZEREL "_WINDOWS")
set(CMAKE_CREATE_WIN32_EXE "/SUBSYSTEM:WINDOWS /ENTRY:\"mainCRTStartup\"") set(CMAKE_CREATE_WIN32_EXE "/SUBSYSTEM:WINDOWS /ENTRY:\"mainCRTStartup\"")
set_target_properties (CubicSDR PROPERTIES OUTPUT_NAME "${CUBICSDR_INSTALL_NAME}")
ENDIF(MSVC) ENDIF(MSVC)
IF (APPLE) IF (APPLE)
@ -857,21 +862,21 @@ IF (WIN32 AND BUILD_INSTALLER)
set(CPACK_GENERATOR NSIS) set(CPACK_GENERATOR NSIS)
set(CPACK_PACKAGE_NAME "${CUBICSDR_INSTALL_NAME}") set(CPACK_PACKAGE_NAME "${CUBICSDR_INSTALL_NAME}")
set(CPACK_NSIS_DISPLAY_NAME "${CUBICSDR_INSTALL_TITLE}")
set(CPACK_PACKAGE_VENDOR "cubicsdr.com") set(CPACK_PACKAGE_VENDOR "cubicsdr.com")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "${CUBICSDR_INSTALL_TITLE}")
set(CPACK_PACKAGE_INSTALL_DIRECTORY "${CUBICSDR_INSTALL_NAME}") set(CPACK_PACKAGE_INSTALL_DIRECTORY "${CUBICSDR_INSTALL_NAME}")
SET(CPACK_NSIS_INSTALLED_ICON_NAME "CubicSDR.ico") SET(CPACK_NSIS_INSTALLED_ICON_NAME "CubicSDR.ico")
SET(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/LICENSE") SET(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/LICENSE")
set(CPACK_PACKAGE_ICON "${PROJECT_SOURCE_DIR}/icon\\\\NSIS_Header.bmp") set(CPACK_PACKAGE_ICON "${PROJECT_SOURCE_DIR}/icon\\\\NSIS_Header.bmp")
IF(EX_PLATFORM EQUAL 64) IF(EX_PLATFORM EQUAL 64)
SET(CPACK_NSIS_INSTALL_ROOT "$PROGRAMFILES64") SET(CPACK_NSIS_INSTALL_ROOT "$PROGRAMFILES64")
SET(CPACK_NSIS_PACKAGE_NAME "${CPACK_PACKAGE_INSTALL_DIRECTORY}") SET(CPACK_NSIS_PACKAGE_NAME "${CUBICSDR_INSTALL_NAME}")
SET(CPACK_PACKAGE_INSTALL_REGISTRY_KEY "${CPACK_PACKAGE_NAME} ${CPACK_PACKAGE_VERSION}") SET(CPACK_PACKAGE_INSTALL_REGISTRY_KEY "${CUBICSDR_INSTALL_NAME} ${CPACK_PACKAGE_VERSION}")
set(CMAKE_CL_64 TRUE) # This gets around a bug in the CPack installer name generation for MinGW 64-bit since 2.8 set(CMAKE_CL_64 TRUE) # This gets around a bug in the CPack installer name generation for MinGW 64-bit since 2.8
ELSE(EX_PLATFORM EQUAL 64) ELSE(EX_PLATFORM EQUAL 64)
SET(CPACK_NSIS_INSTALL_ROOT "$PROGRAMFILES") SET(CPACK_NSIS_INSTALL_ROOT "$PROGRAMFILES")
SET(CPACK_NSIS_PACKAGE_NAME "${CPACK_PACKAGE_INSTALL_DIRECTORY} (x86)") SET(CPACK_NSIS_PACKAGE_NAME "${CUBICSDR_INSTALL_NAME} (x86)")
SET(CPACK_PACKAGE_INSTALL_REGISTRY_KEY "${CPACK_PACKAGE_NAME} ${CPACK_PACKAGE_VERSION} (x86)") SET(CPACK_PACKAGE_INSTALL_REGISTRY_KEY "${CUBICSDR_INSTALL_NAME} ${CPACK_PACKAGE_VERSION} (x86)")
set(CMAKE_CL_64 FALSE) set(CMAKE_CL_64 FALSE)
ENDIF(EX_PLATFORM EQUAL 64) ENDIF(EX_PLATFORM EQUAL 64)

View File

@ -20,6 +20,7 @@
#include "DataTree.h" #include "DataTree.h"
#include "ColorTheme.h" #include "ColorTheme.h"
#include "DemodulatorMgr.h" #include "DemodulatorMgr.h"
#include "ImagePanel.h"
#include <thread> #include <thread>
@ -74,17 +75,21 @@ AppFrame::AppFrame() :
wxPanel *demodPanel = new wxPanel(mainSplitter, wxID_ANY); wxPanel *demodPanel = new wxPanel(mainSplitter, wxID_ANY);
#ifdef CUBICSDR_HEADER_IMAGE #ifdef CUBICSDR_HEADER_IMAGE
//get the dir path of the executable
wxFileName exePath = wxFileName(wxStandardPaths::Get().GetExecutablePath()); wxFileName exePath = wxFileName(wxStandardPaths::Get().GetExecutablePath());
std::string headerPath = exePath.GetPath().ToStdString(); std::string headerPath = exePath.GetPath().ToStdString();
headerPath += filePathSeparator + std::string("" CUBICSDR_HEADER_IMAGE); headerPath += filePathSeparator + std::string("" CUBICSDR_HEADER_IMAGE);
wxInitAllImageHandlers(); wxInitAllImageHandlers();
wxStaticBitmap *headerImgStatic = new wxStaticBitmap(demodPanel, wxID_ANY, wxBitmap( headerPath, wxBITMAP_TYPE_ANY ));
ImagePanel *imgPanel = new ImagePanel(demodPanel, headerPath, wxBITMAP_TYPE_ANY);
std::string headerBgColor = "" CUBICSDR_HEADER_BG; std::string headerBgColor = "" CUBICSDR_HEADER_BG;
if (headerBgColor != "") { if (headerBgColor != "") {
demodPanel->SetBackgroundColour(wxColour(headerBgColor)); imgPanel->SetBackgroundColour(wxColour(headerBgColor));
} }
demodTray->Add(headerImgStatic, 0, wxALIGN_CENTER_VERTICAL | wxALL, 0);
imgPanel->SetBestFittingSize(wxSize(200, 0));
demodTray->Add(imgPanel, 0, wxEXPAND | wxALL, 0);
demodTray->AddSpacer(1); demodTray->AddSpacer(1);
#endif #endif
@ -1291,6 +1296,7 @@ void AppFrame::OnNewWindow(wxCommandEvent& WXUNUSED(event)) {
new AppFrame(); new AppFrame();
} }
void AppFrame::OnThread(wxCommandEvent& event) { void AppFrame::OnThread(wxCommandEvent& event) {
event.Skip(); event.Skip();
} }

View File

@ -4,6 +4,8 @@
#include <wx/panel.h> #include <wx/panel.h>
#include <wx/splitter.h> #include <wx/splitter.h>
#include <wx/sizer.h> #include <wx/sizer.h>
#include <wx/bitmap.h>
#include <wx/statbmp.h>
#include "PrimaryGLContext.h" #include "PrimaryGLContext.h"
@ -74,6 +76,7 @@ class AppFrame: public wxFrame {
public: public:
AppFrame(); AppFrame();
~AppFrame(); ~AppFrame();
void OnThread(wxCommandEvent& event); void OnThread(wxCommandEvent& event);
void OnEventInput(wxThreadEvent& event); void OnEventInput(wxThreadEvent& event);
void initDeviceParams(SDRDeviceInfo *devInfo); void initDeviceParams(SDRDeviceInfo *devInfo);
@ -172,7 +175,7 @@ private:
wxMenuItem *showTipMenuItem; wxMenuItem *showTipMenuItem;
bool lowPerfMode; bool lowPerfMode;
#ifdef USE_HAMLIB #ifdef USE_HAMLIB
void enableRig(); void enableRig();
void disableRig(); void disableRig();

View File

@ -5,7 +5,7 @@
#include "CubicSDR.h" #include "CubicSDR.h"
SDRDevicesDialog::SDRDevicesDialog( wxWindow* parent ): devFrame( parent ) { SDRDevicesDialog::SDRDevicesDialog( wxWindow* parent ): devFrame( parent, wxID_ANY, wxT(CUBICSDR_INSTALL_NAME " :: SDR Devices")) {
refresh = true; refresh = true;
failed = false; failed = false;
m_refreshButton->Disable(); m_refreshButton->Disable();

50
src/visual/ImagePanel.cpp Normal file
View File

@ -0,0 +1,50 @@
#include "ImagePanel.h"
BEGIN_EVENT_TABLE(ImagePanel, wxPanel)
EVT_PAINT(ImagePanel::paintEvent)
END_EVENT_TABLE()
ImagePanel::ImagePanel(wxPanel * parent, wxString file, wxBitmapType format) :
wxPanel(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxFULL_REPAINT_ON_RESIZE) {
image.LoadFile(file, format);
}
void ImagePanel::paintEvent(wxPaintEvent & evt) {
wxPaintDC dc(this);
render(dc);
}
void ImagePanel::paintNow() {
wxClientDC dc(this);
render(dc);
}
void ImagePanel::render(wxDC& dc) {
double imagew = image.GetWidth();
double imageh = image.GetHeight();
wxSize destSize = dc.GetSize();
double destw = destSize.GetWidth();
double desth = destSize.GetHeight();
double sf = 1.0, wf, hf;
wf = destw / imagew;
hf = desth / imageh;
sf = (wf < hf)?wf:hf;
double resulth = imageh * sf;
double resultw = imagew * sf;
dc.SetUserScale(sf, sf);
dc.DrawBitmap( image, (destw/2 - resultw/2)/sf, (desth/2 - resulth/2)/sf, false );
}

16
src/visual/ImagePanel.h Normal file
View File

@ -0,0 +1,16 @@
#include <wx/wx.h>
#include <wx/sizer.h>
class ImagePanel : public wxPanel {
wxBitmap image;
public:
ImagePanel(wxPanel* parent, wxString file, wxBitmapType format);
void paintEvent(wxPaintEvent & evt);
void paintNow();
void render(wxDC& dc);
DECLARE_EVENT_TABLE()
};