35#include <wx/statline.h>
39#include "OCPNPlatform.h"
40#include "CanvasOptions.h"
41#include "DetailSlider.h"
42#include "GoToPositionDialog.h"
47#include "color_handler.h"
49#ifdef __OCPN__ANDROID__
50#include "androidUTIL.h"
61extern bool g_bShowMuiZoomButtons;
63double getValue(
int animationType,
double t);
67#define ID_SCALE_CANCEL 8301
68#define ID_SCALE_OK 8302
69#define ID_SCALECTRL 8303
77 SetScaleDialog(wxWindow* parent, wxWindowID
id = SYMBOL_GOTOPOS_IDNAME,
78 const wxString& caption = _(
"Set scale"),
79 const wxPoint& pos = wxDefaultPosition,
80 const wxSize& size = wxDefaultSize,
81 long style = wxDEFAULT_DIALOG_STYLE);
86 bool Create(wxWindow* parent, wxWindowID
id = wxID_ANY,
87 const wxString& caption = _(
"Set scale"),
88 const wxPoint& pos = wxDefaultPosition,
89 const wxSize& size = wxDefaultSize,
90 long style = wxDEFAULT_DIALOG_STYLE);
92 void SetColorScheme(ColorScheme cs);
96 void OnSetScaleCancelClick(wxCommandEvent& event);
97 void OnSetScaleOKClick(wxCommandEvent& event);
102 wxButton* m_CancelButton;
103 wxButton* m_OKButton;
107EVT_BUTTON(ID_GOTOPOS_CANCEL, SetScaleDialog::OnSetScaleCancelClick)
108EVT_BUTTON(ID_GOTOPOS_OK, SetScaleDialog::OnSetScaleOKClick)
118 const wxString& caption,
const wxPoint& pos,
119 const wxSize& size,
long style) {
121 wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxFRAME_FLOAT_ON_PARENT;
123 Create(parent,
id, caption, pos, size, wstyle);
126SetScaleDialog::~SetScaleDialog() {}
133 const wxString& caption,
const wxPoint& pos,
134 const wxSize& size,
long style) {
135 SetExtraStyle(GetExtraStyle() | wxWS_EX_BLOCK_EVENTS);
136 wxDialog::Create(parent,
id, caption, pos, size, style);
139 GetSizer()->SetSizeHints(
this);
152 wxBoxSizer* itemBoxSizer2 =
new wxBoxSizer(wxVERTICAL);
153 itemDialog1->SetSizer(itemBoxSizer2);
155 wxStaticBox* itemStaticBoxSizer4Static =
156 new wxStaticBox(itemDialog1, wxID_ANY, _(
"Chart Scale"));
158 wxStaticBoxSizer* itemStaticBoxSizer4 =
159 new wxStaticBoxSizer(itemStaticBoxSizer4Static, wxVERTICAL);
160 itemBoxSizer2->Add(itemStaticBoxSizer4, 0, wxEXPAND | wxALL, 5);
162 wxStaticText* itemStaticText5 =
new wxStaticText(
163 itemDialog1, wxID_STATIC, _T(
""), wxDefaultPosition, wxDefaultSize, 0);
164 itemStaticBoxSizer4->Add(itemStaticText5, 0,
165 wxALIGN_LEFT | wxLEFT | wxRIGHT | wxTOP, 5);
167 m_ScaleCtl =
new wxTextCtrl(itemDialog1, ID_SCALECTRL, _T(
""),
168 wxDefaultPosition, wxSize(180, -1), 0);
169 itemStaticBoxSizer4->Add(
170 m_ScaleCtl, 0, wxALIGN_LEFT | wxLEFT | wxRIGHT | wxBOTTOM | wxEXPAND, 5);
172 wxBoxSizer* itemBoxSizer16 =
new wxBoxSizer(wxHORIZONTAL);
173 itemBoxSizer2->Add(itemBoxSizer16, 0, wxALIGN_RIGHT | wxALL, 5);
175 m_CancelButton =
new wxButton(itemDialog1, ID_GOTOPOS_CANCEL, _(
"Cancel"),
176 wxDefaultPosition, wxDefaultSize, 0);
177 itemBoxSizer16->Add(m_CancelButton, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
179 m_OKButton =
new wxButton(itemDialog1, ID_GOTOPOS_OK, _(
"OK"),
180 wxDefaultPosition, wxDefaultSize, 0);
181 itemBoxSizer16->Add(m_OKButton, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
182 m_OKButton->SetDefault();
184 SetColorScheme((ColorScheme)0);
187void SetScaleDialog::SetColorScheme(ColorScheme cs) { DimeControl(
this); }
189void SetScaleDialog::OnSetScaleCancelClick(wxCommandEvent& event) {
194void SetScaleDialog::OnSetScaleOKClick(wxCommandEvent& event) {
195 SetReturnCode(wxID_OK);
206 DECLARE_EVENT_TABLE()
208 wxSize DoGetBestSize()
const;
212 MUIButton(wxWindow* parent, wxWindowID
id = wxID_ANY,
213 float scale_factor = 1.0,
214 const wxString& bitmapState0 = wxEmptyString,
215 const wxString& bitmapState1 = wxEmptyString,
216 const wxString& bitmapState2 = wxEmptyString,
217 const wxPoint& pos = wxDefaultPosition,
218 const wxSize& size = wxDefaultSize,
long style = wxNO_BORDER);
220 bool Create(wxWindow* parent, wxWindowID
id = wxID_ANY,
221 float scale_factor = 1.0,
222 const wxString& bitmapState0 = wxEmptyString,
223 const wxString& bitmapState1 = wxEmptyString,
224 const wxString& bitmapState2 = wxEmptyString,
225 const wxPoint& pos = wxDefaultPosition,
226 const wxSize& size = wxDefaultSize,
long style = wxNO_BORDER);
231 void CreateControls();
233 void SetState(
int state);
235 void SetColorScheme(ColorScheme cs);
236 void OnSize(wxSizeEvent& event);
237 void OnPaint(wxPaintEvent& event);
238 void OnLeftDown(wxMouseEvent& event);
239 void OnLeftUp(wxMouseEvent& event);
241 wxBitmap GetBitmapResource(
const wxString& name);
243 wxIcon GetIconResource(
const wxString& name);
249 wxString m_bitmapFileState0;
250 wxString m_bitmapFileState1;
251 wxString m_bitmapFileState2;
253 wxBitmap m_bitmapState0;
254 wxBitmap m_bitmapState1;
255 wxBitmap m_bitmapState2;
259 wxSize m_styleToolSize;
263IMPLEMENT_DYNAMIC_CLASS(
MUIButton, wxWindow)
267EVT_SIZE(MUIButton::OnSize)
268EVT_PAINT(MUIButton::OnPaint)
269EVT_LEFT_DOWN(MUIButton::OnLeftDown)
270EVT_LEFT_UP(MUIButton::OnLeftUp)
276MUIButton::MUIButton(wxWindow* parent, wxWindowID
id,
float scale_factor,
277 const wxString& bitmap,
const wxString& bitmapState1,
278 const wxString& bitmapState2,
const wxPoint& pos,
279 const wxSize& size,
long style) {
281 Create(parent,
id, scale_factor, bitmap, bitmapState1, bitmapState2, pos,
285bool MUIButton::Create(wxWindow* parent, wxWindowID
id,
float scale_factor,
286 const wxString& bitmap,
const wxString& bitmapState1,
287 const wxString& bitmapState2,
const wxPoint& pos,
288 const wxSize& size,
long style) {
289 wxWindow::Create(parent,
id, pos, size, style);
290 m_bitmapFileState0 = bitmap;
291 m_bitmapFileState1 = bitmapState1;
292 m_bitmapFileState2 = bitmapState2;
294 m_scaleFactor = scale_factor;
296 m_styleToolSize = g_StyleManager->GetCurrentStyle()->GetToolSize();
300 m_styleToolSize = wxSize(m_styleToolSize.x * 1.25, m_styleToolSize.y * 1.25);
306MUIButton::~MUIButton() {}
308void MUIButton::Init() {
310 m_cs = (ColorScheme)-1;
313void MUIButton::CreateControls() {
314 this->SetForegroundColour(wxColour(255, 255, 255));
316 wxColour backColor = GetGlobalColor(_T(
"GREY3"));
317 SetBackgroundColour(backColor);
319 this->SetFont(wxFont(8, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL,
320 wxFONTWEIGHT_BOLD,
false, wxT(
"Tahoma")));
323void MUIButton::SetColorScheme(ColorScheme cs) {
325 wxColour backColor = GetGlobalColor(_T(
"GREY3"));
326 SetBackgroundColour(backColor);
330 wxBitmap bmp = LoadSVG(m_bitmapFileState0, GetSize().x, GetSize().y);
331 m_bitmapState0 = style->SetBitmapBrightness(bmp, cs);
333 bmp = LoadSVG(m_bitmapFileState1, GetSize().x, GetSize().y);
335 m_bitmapState1 = style->SetBitmapBrightness(bmp, cs);
337 m_bitmapState1 = m_bitmapState0;
339 bmp = LoadSVG(m_bitmapFileState2, GetSize().x, GetSize().y);
341 m_bitmapState2 = style->SetBitmapBrightness(bmp, cs);
343 m_bitmapState2 = m_bitmapState0;
348 m_bitmap = m_bitmapState0;
352 m_bitmap = m_bitmapState1;
356 m_bitmap = m_bitmapState2;
366void MUIButton::SetState(
int state) {
370 m_bitmap = m_bitmapState0;
374 m_bitmap = m_bitmapState1;
378 m_bitmap = m_bitmapState2;
387void MUIButton::OnSize(wxSizeEvent& event) {
388 if (m_bitmap.IsOk()) {
389 if (event.GetSize() == m_bitmap.GetSize())
return;
392 if (!m_bitmapFileState0.IsEmpty())
394 LoadSVG(m_bitmapFileState0, event.GetSize().x, event.GetSize().y);
396 if (!m_bitmapFileState1.IsEmpty())
398 LoadSVG(m_bitmapFileState1, event.GetSize().x, event.GetSize().y);
399 if (!m_bitmapState1.IsOk() || m_bitmapFileState1.IsEmpty())
400 m_bitmapState1 = m_bitmapState0;
402 if (!m_bitmapFileState2.IsEmpty())
404 LoadSVG(m_bitmapFileState2, event.GetSize().x, event.GetSize().y);
405 if (!m_bitmapState2.IsOk() || m_bitmapFileState2.IsEmpty())
406 m_bitmapState2 = m_bitmapState0;
411 m_bitmap = m_bitmapState0;
415 m_bitmap = m_bitmapState1;
419 m_bitmap = m_bitmapState2;
424wxBitmap MUIButton::GetBitmapResource(
const wxString& name) {
430wxIcon MUIButton::GetIconResource(
const wxString& name) {
436wxSize MUIButton::DoGetBestSize()
const {
441 return wxSize(m_styleToolSize.x * m_scaleFactor,
442 m_styleToolSize.y * m_scaleFactor);
445void MUIButton::OnPaint(wxPaintEvent& event) {
448 if (m_bitmap.IsOk()) {
449 dc.DrawBitmap(m_bitmap, 0, 0,
true);
453 wxBufferedPaintDC dc(
this);
455 wxRect clientRect = GetClientRect();
456 wxRect gradientRect = clientRect;
457 gradientRect.SetHeight(gradientRect.GetHeight()/2 + ((GetCapture() ==
this) ? 1 : 0));
458 if(GetCapture() !=
this)
460 dc.GradientFillLinear(gradientRect,
461 m_GradientTopStartColour, m_GradientTopEndColour, wxSOUTH);
465 dc.SetPen(wxPen(m_PressedColourTop));
466 dc.SetBrush(wxBrush(m_PressedColourTop));
467 dc.DrawRectangle(gradientRect);
470 gradientRect.Offset(0, gradientRect.GetHeight());
472 if(GetCapture() !=
this)
474 dc.GradientFillLinear(gradientRect,
475 m_GradientBottomStartColour, m_GradientBottomEndColour, wxSOUTH);
479 dc.SetPen(wxPen(m_PressedColourBottom));
480 dc.SetBrush(wxBrush(m_PressedColourBottom));
481 dc.DrawRectangle(gradientRect);
483 dc.SetPen(wxPen(GetBackgroundColour()));
484 dc.SetBrush(*wxTRANSPARENT_BRUSH);
485 dc.DrawRectangle(0, 0, clientRect.GetWidth(), clientRect.GetHeight());
486 dc.SetFont(GetFont());
487 dc.SetTextForeground(GetForegroundColour());
488 if(GetCapture() ==
this)
490 clientRect.Offset(1, 1);
492 dc.DrawLabel(m_Label, clientRect, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL);
497void MUIButton::OnLeftDown(wxMouseEvent& event) {
event.Skip(); }
499void MUIButton::OnLeftUp(wxMouseEvent& event) {
500 if (GetClientRect().Contains(event.GetPosition())) {
501 wxCommandEvent evt(wxEVT_COMMAND_MENU_SELECTED, GetId());
502 GetParent()->GetEventHandler()->AddPendingEvent(evt);
508#define CANVAS_OPTIONS_ANIMATION_TIMER_1 800
509#define CANVAS_OPTIONS_TIMER 801
514BEGIN_EVENT_TABLE(
MUIBar, wxFrame)
515EVT_TIMER(CANVAS_OPTIONS_ANIMATION_TIMER_1,
516 MUIBar::onCanvasOptionsAnimationTimerEvent)
518EVT_SIZE(MUIBar::OnSize)
519EVT_MENU(-1, MUIBar::OnToolLeftClick)
520EVT_TIMER(CANVAS_OPTIONS_TIMER, MUIBar::CaptureCanvasOptionsBitmapChain)
527MUIBar::MUIBar(
ChartCanvas* parent,
int orientation,
float size_factor,
528 wxWindowID
id,
const wxPoint& pos,
const wxSize& size,
529 long style,
const wxString& name) {
530 m_parentCanvas = parent;
531 m_orientation = orientation;
536 long mstyle = wxNO_BORDER | wxFRAME_NO_TASKBAR | wxFRAME_SHAPED |
537 wxFRAME_FLOAT_ON_PARENT;
540 mstyle |= wxFRAME_TOOL_WINDOW;
543 m_scaleFactor = size_factor;
544 m_cs = (ColorScheme)-1;
546 wxFrame::Create(parent,
id, _T(
""), pos, size, mstyle, name);
553 if (m_canvasOptions) {
554 m_canvasOptions->Destroy();
558 m_scaleTextBox->Unbind(wxEVT_LEFT_DOWN, &MUIBar::OnScaleSelected,
this);
564 m_followButton = NULL;
567 m_canvasOptions = NULL;
568 m_canvasOptionsAnimationTimer.SetOwner(
this,
569 CANVAS_OPTIONS_ANIMATION_TIMER_1);
570 m_backcolorString = _T(
"GREY3");
571 m_scaleTextBox = NULL;
572 m_capture_size_y = 0;
576 CanvasOptionTimer.SetOwner(
this, CANVAS_OPTIONS_TIMER);
577 m_coAnimateByBitmaps =
false;
579#ifdef __OCPN__ANDROID__
584void MUIBar::SetColorScheme(ColorScheme cs) {
586 wxColour backColor = GetGlobalColor(m_backcolorString);
587 SetBackgroundColour(backColor);
589 if (m_zinButton) m_zinButton->SetColorScheme(cs);
590 if (m_zoutButton) m_zoutButton->SetColorScheme(cs);
591 if (m_followButton) m_followButton->SetColorScheme(cs);
592 if (m_menuButton) m_menuButton->SetColorScheme(cs);
594 if (m_scaleTextBox) {
595 wxColour textbackColor = GetGlobalColor(_T(
"GREY1"));
596 m_scaleTextBox->SetForegroundColour(textbackColor);
603void MUIBar::OnScaleSelected(wxMouseEvent& event) {
610 if (dlg.GetReturnCode() == wxID_OK) {
611 wxString newScale = dlg.m_ScaleCtl->GetValue();
612 if (newScale.Contains(
':')) newScale = newScale.AfterFirst(
':');
614 if (newScale.ToDouble(&dScale)) {
616 dScale = wxMin(dScale, 3e6);
617 dScale = wxMax(dScale, 1000);
618 double displayScaleNow = pcc->GetScaleValue();
619 double factor = displayScaleNow / dScale;
620 pcc->DoZoomCanvas(factor,
false);
624 displayScaleNow = pcc->GetScaleValue();
625 factor = displayScaleNow / dScale;
626 pcc->DoZoomCanvas(factor,
false);
631void MUIBar::SetCanvasENCAvailable(
bool avail) {
632 m_CanvasENCAvail = avail;
633 if (m_canvasOptions) m_canvasOptions->SetENCAvailable(avail);
636void MUIBar::CreateControls() {
639 wxColour backColor = GetGlobalColor(m_backcolorString);
640 SetBackgroundColour(backColor);
641 wxBoxSizer* topSizer;
643 wxString iconDir = g_Platform->GetSharedDataDir() + _T(
"uidata/MUI_flat/");
645 if (m_orientation == wxHORIZONTAL) {
646 topSizer =
new wxBoxSizer(wxVERTICAL);
649 wxBoxSizer* barSizer =
new wxBoxSizer(wxHORIZONTAL);
650 topSizer->Add(barSizer, 0, wxEXPAND);
654 if (g_bShowMuiZoomButtons) {
655 m_zinButton =
new MUIButton(
this, ID_ZOOMIN, m_scaleFactor,
656 iconDir + _T(
"MUI_zoom-in.svg"));
657 barSizer->Add(m_zinButton, 0, wxSHAPED);
659 m_zoutButton =
new MUIButton(
this, ID_ZOOMOUT, m_scaleFactor,
660 iconDir + _T(
"MUI_zoom-out.svg"));
661 barSizer->Add(m_zoutButton, 0, wxSHAPED);
663 barSizer->AddSpacer(2);
666#ifndef __OCPN__ANDROID__
668 m_scaleTextBox =
new wxStaticText(
this, wxID_ANY, _T(
"1:400000"));
669 wxColour textbackColor = GetGlobalColor(_T(
"GREY1"));
670 m_scaleTextBox->SetForegroundColour(textbackColor);
671 barSizer->Add(m_scaleTextBox, 0, wxALIGN_CENTER_VERTICAL);
672 m_scaleTextBox->Bind(wxEVT_LEFT_DOWN, &MUIBar::OnScaleSelected,
this);
674 barSizer->AddSpacer(5);
676 m_followButton =
new MUIButton(
this, ID_FOLLOW, m_scaleFactor,
677 iconDir + _T(
"MUI_follow.svg"),
678 iconDir + _T(
"MUI_follow_active.svg"),
679 iconDir + _T(
"MUI_follow_ahead.svg"));
680 barSizer->Add(m_followButton, 0, wxSHAPED);
682 barSizer->AddSpacer(2);
684 m_menuButton =
new MUIButton(
this, ID_MUI_MENU, m_scaleFactor,
685 iconDir + _T(
"MUI_menu.svg"));
686 barSizer->Add(m_menuButton, 0, wxSHAPED);
688 topSizer =
new wxBoxSizer(wxVERTICAL);
691 wxBoxSizer* barSizer =
new wxBoxSizer(wxVERTICAL);
692 topSizer->Add(barSizer, 0, wxEXPAND);
695 if (g_bShowMuiZoomButtons) {
696 m_zinButton =
new MUIButton(
this, ID_ZOOMIN, m_scaleFactor,
697 iconDir + _T(
"MUI_zoom-in.svg"));
698 barSizer->Add(m_zinButton, 1, wxSHAPED);
700 m_zoutButton =
new MUIButton(
this, ID_ZOOMOUT, m_scaleFactor,
701 iconDir + _T(
"MUI_zoom-out.svg"));
702 barSizer->Add(m_zoutButton, 1, wxSHAPED);
704 barSizer->AddSpacer(5);
707#ifndef __OCPN__ANDROID__
708 m_followButton =
new MUIButton(
this, ID_FOLLOW, m_scaleFactor,
709 iconDir + _T(
"MUI_follow.svg"),
710 iconDir + _T(
"MUI_follow_active.svg"),
711 iconDir + _T(
"MUI_follow_ahead.svg"));
712 barSizer->Add(m_followButton, 1, wxSHAPED);
714 barSizer->AddSpacer(5);
717 m_menuButton =
new MUIButton(
this, ID_MUI_MENU, m_scaleFactor,
718 iconDir + _T(
"MUI_menu.svg"));
719 barSizer->Add(m_menuButton, 1, wxALIGN_RIGHT | wxSHAPED);
726void MUIBar::SetBestPosition(
void) {
728 int x = (m_parent->GetClientSize().x - GetSize().x) / 2;
730 int bottomOffset = 0;
733 bottomOffset += pcc->GetPianoHeight();
735 int y = m_parent->GetClientSize().y - GetSize().y - bottomOffset;
736 SetSize(x, y, -1, -1, wxSIZE_USE_EXISTING);
740 int x = (m_parent->GetClientSize().x - (GetSize().x * 1.00));
748 int bottomOffset = 2;
753 int y = m_parent->GetClientSize().y - GetSize().y - bottomOffset;
755 wxPoint m_position = wxPoint(x, y);
756 wxPoint screenPos = pcc->ClientToScreen(m_position);
764 wxPoint pp = m_parent->GetPosition();
765 wxPoint ppg = m_parent->GetParent()->GetScreenPosition();
766 wxPoint screen_pos_fix = ppg + pp + m_position;
767 screenPos.x = screen_pos_fix.x;
772 if (m_canvasOptions) {
773 m_canvasOptions->Destroy();
781void MUIBar::OnSize(wxSizeEvent& event) {
785#if !defined(__WXMAC__) && !defined(__OCPN__ANDROID__)
787 wxBitmap m_MaskBmp = wxBitmap(GetSize().x, GetSize().y);
788 wxMemoryDC sdc(m_MaskBmp);
789 sdc.SetBackground(*wxWHITE_BRUSH);
791 sdc.SetBrush(*wxBLACK_BRUSH);
792 sdc.SetPen(*wxBLACK_PEN);
793 sdc.DrawRoundedRectangle(0, 0, m_MaskBmp.GetWidth(), m_MaskBmp.GetHeight(),
795 sdc.SelectObject(wxNullBitmap);
796 SetShape(wxRegion(m_MaskBmp, *wxWHITE, 0));
801void MUIBar::UpdateDynamicValues() {
802 if (!m_scaleTextBox)
return;
804 wxString scaleString;
805 int scale = m_parentCanvas->GetScaleValue();
807 scaleString.Printf(_T(
"1:%d"),
scale);
809 scaleString.Printf(_T(
"1:%4.1f MM"),
scale / 1e6);
811 if (m_scaleTextBox) m_scaleTextBox->SetLabel(scaleString);
814void MUIBar::SetFollowButtonState(
int state) {
815 if (m_followButton) m_followButton->SetState(state);
818void MUIBar::OnToolLeftClick(wxCommandEvent& event) {
822 switch (event.GetId()) {
825 wxCommandEvent evt(wxEVT_COMMAND_MENU_SELECTED, event.GetId());
826 GetParent()->GetEventHandler()->AddPendingEvent(evt);
828 if (g_focusCanvas) g_focusCanvas->TriggerDeferredFocus();
833 wxCommandEvent evt(wxEVT_COMMAND_MENU_SELECTED, event.GetId());
834 GetParent()->GetEventHandler()->AddPendingEvent(evt);
836 if (g_focusCanvas) g_focusCanvas->TriggerDeferredFocus();
841 if (!m_canvasOptions) {
846 wxPoint parentClientUpperRight =
847 m_parent->ClientToScreen(wxPoint(m_parent->GetSize().x, 0));
848 wxRect rmui = m_parentCanvas->GetMUIBarRect();
849 int size_y = rmui.y - (parentClientUpperRight.y + m_COTopOffset);
850 size_y -= GetCharHeight();
851 size_y = wxMax(size_y, 100);
853 m_canvasOptions->SetSize(wxSize(-1, size_y));
854 m_canvasOptionsFullSize = m_canvasOptions->GetSize();
855 m_canvasOptionsFullSize.x +=
856 m_canvasOptions->GetCharWidth();
860 m_currentCOPos = m_parent->ClientToScreen(
861 wxPoint(m_parent->GetSize().x, m_COTopOffset));
863 m_currentCOPos = wxPoint(m_parent->GetSize().x, 20);
865 m_canvasOptions->Move(m_currentCOPos);
866 m_canvasOptions->Hide();
869 m_canvasOptions->SetENCAvailable(m_CanvasENCAvail);
871 if (m_canvasOptions->IsShown())
876 if (m_coAnimateByBitmaps && m_capture_size_y) {
877 int overShoot_x = m_canvasOptions->GetSize().x * 2 / 10;
879 wxPoint(m_capturePoint.x - overShoot_x, m_capturePoint.y);
881 m_backingBitmap = wxBitmap(m_canvasOptionsFullSize.x + overShoot_x,
882 m_capture_size_y, -1);
884 mdcb.SelectObject(m_backingBitmap);
886 mdcb.Blit(0, 0, m_canvasOptionsFullSize.x + overShoot_x,
887 m_capture_size_y, &sdc, m_capturePoint.x - overShoot_x,
888 m_capturePoint.y, wxCOPY);
889 mdcb.SelectObject(wxNullBitmap);
903void MUIBar::CaptureCanvasOptionsBitmap() {
905 CanvasOptionTimer.Start(100, wxTIMER_ONE_SHOT);
908void MUIBar::CaptureCanvasOptionsBitmapChain(wxTimerEvent& event) {
909 if (m_coSequence == 0) {
910 if (!m_canvasOptions) m_canvasOptions =
new CanvasOptions(m_parent);
912 wxPoint parentClientUpperRight =
913 m_parent->ClientToScreen(wxPoint(m_parent->GetSize().x, 0));
914 wxRect rmui = m_parentCanvas->GetMUIBarRect();
915 int size_y = rmui.y - (parentClientUpperRight.y + m_COTopOffset);
916 size_y -= GetCharHeight();
917 size_y = wxMax(size_y, 100);
918 m_capture_size_y = size_y;
920 m_canvasOptions->SetSize(wxSize(-1, size_y));
923 m_parent->ClientToScreen(wxPoint(m_parent->GetSize().x, m_COTopOffset));
924 m_canvasOptions->Move(m_capturePoint);
925 m_canvasOptions->Show();
928 CanvasOptionTimer.Start(1, wxTIMER_ONE_SHOT);
931 else if (m_coSequence == 1) {
932 m_capturePoint = m_parent->ClientToScreen(wxPoint(
933 m_parent->GetSize().x - m_canvasOptionsFullSize.x, m_COTopOffset));
934 m_canvasOptions->Move(m_capturePoint);
937 CanvasOptionTimer.Start(1, wxTIMER_ONE_SHOT);
940 else if (m_coSequence == 2) {
942 wxBitmap(m_canvasOptions->GetSize().x, m_capture_size_y, -1);
943 wxMemoryDC mdc(m_animateBitmap);
947 mdc.Blit(0, 0, m_canvasOptions->GetSize().x, m_capture_size_y, &sdc,
948 m_capturePoint.x, m_capturePoint.y, wxCOPY);
949 mdc.SelectObject(wxNullBitmap);
956void MUIBar::OnEraseBackground(wxEraseEvent& event) {}
958void MUIBar::OnPaint(wxPaintEvent& event) {
962 GetClientSize(&width, &height);
972 wxColour backColor = GetGlobalColor(m_backcolorString);
974 dc.SetBrush(wxBrush(backColor ));
975 dc.SetPen(wxPen(backColor));
976 dc.DrawRoundedRectangle(0, 0, width - 10, height - 10, 8);
979void MUIBar::ResetCanvasOptions() {
980 delete m_canvasOptions;
981 m_canvasOptions = NULL;
984void MUIBar::PullCanvasOptions() {
986 int cox = m_parent->GetSize().x - m_canvasOptionsFullSize.x;
987 int coy = m_COTopOffset;
988 m_targetCOPos = m_parent->ClientToScreen(wxPoint(cox, coy));
991 m_canvasOptions->Move(m_targetCOPos);
992 m_canvasOptions->Show();
998 if (m_coAnimateByBitmaps && !m_animateBitmap.IsOk()) {
999 m_canvasOptions->Move(m_targetCOPos);
1000 m_canvasOptions->Show();
1001 CaptureCanvasOptionsBitmap();
1007 m_startCOPos = m_canvasOptions->GetPosition();
1010 m_currentCOPos = m_startCOPos;
1012 m_animationType = CO_ANIMATION_CUBIC_REVERSE;
1013 m_animateSteps = 10;
1014 m_animationTotalTime = 200;
1016 m_pushPull = CO_PULL;
1018 pcc->m_b_paint_enable =
false;
1022 m_canvasOptionsAnimationTimer.Start(10,
true);
1023 m_canvasOptions->Move(m_targetCOPos);
1024 m_canvasOptions->Hide();
1027void MUIBar::PushCanvasOptions() {
1029 m_canvasOptions->Hide();
1036 int cox = m_parent->GetSize().x;
1040 m_targetCOPos = m_parent->ClientToScreen(wxPoint(cox, coy));
1042 m_targetCOPos = wxPoint(cox, coy);
1045 m_startCOPos = m_canvasOptions->GetPosition();
1048 m_currentCOPos = m_startCOPos;
1051 m_animationType = CO_ANIMATION_LINEAR;
1053 m_animationTotalTime = 100;
1054 m_pushPull = CO_PUSH;
1059 m_canvasOptionsAnimationTimer.Start(10,
true);
1060 m_canvasOptions->Show();
1063void MUIBar::onCanvasOptionsAnimationTimerEvent(wxTimerEvent& event) {
1064 double progress = m_animateStep / (double)m_animateSteps;
1065 double valueX = getValue(m_animationType, progress);
1067 double dx = (m_targetCOPos.x - m_startCOPos.x) * valueX;
1069 wxPoint newPos = wxPoint(m_startCOPos.x + dx, m_currentCOPos.y);
1072 if (m_pushPull == CO_PULL)
1075 size_x = (m_targetCOPos.x - m_startCOPos.x) - abs(dx);
1077 if (!m_coAnimateByBitmaps) {
1078 m_canvasOptions->SetSize(newPos.x, newPos.y, size_x, wxDefaultCoord,
1079 wxSIZE_USE_EXISTING);
1081 m_canvasOptions->Show();
1083 m_canvasOptions->Hide();
1088 if (m_backingBitmap.IsOk()) {
1089 wxMemoryDC mdc_back(m_backingBitmap);
1090 sdc.Blit(m_backingPoint.x, m_backingPoint.y,
1091 m_backingBitmap.GetWidth() - size_x,
1092 m_backingBitmap.GetHeight(), &mdc_back, 0, 0, wxCOPY);
1096 wxMemoryDC mdc(m_animateBitmap);
1097 sdc.Blit(newPos.x, newPos.y, size_x, m_animateBitmap.GetHeight(), &mdc, 0,
1099 mdc.SelectObject(wxNullBitmap);
1102 m_currentCOPos = newPos;
1104 double dt = m_animationTotalTime / m_animateSteps;
1106 if (m_animateStep++ < m_animateSteps + 1) {
1107 m_canvasOptionsAnimationTimer.Start(dt,
true);
1109 m_currentCOPos = m_targetCOPos;
1110 m_canvasOptions->Show(m_pushPull == CO_PULL);
1114 pcc->m_b_paint_enable =
true;
1116 if (m_pushPull == CO_PUSH) {
1117 delete m_canvasOptions;
1118 m_canvasOptions = NULL;
1121 if (m_pushPull == CO_PUSH) pcc->TriggerDeferredFocus();
1123 pcc->TriggerDeferredFocus();
1133double bounceMaker(
double t,
double c,
double a) {
1134 if (t == 1.0)
return c;
1135 if (t < (4 / 11.0)) {
1136 return c * (7.5625 * t * t);
1137 }
else if (t < (8 / 11.0)) {
1139 return -a * (1. - (7.5625 * t * t + .75)) + c;
1140 }
else if (t < (10 / 11.0)) {
1142 return -a * (1. - (7.5625 * t * t + .9375)) + c;
1145 return -a * (1. - (7.5625 * t * t + .984375)) + c;
1149double getValue(
int animationType,
double t) {
1153 switch (animationType) {
1154 case CO_ANIMATION_LINEAR:
1158 case CO_ANIMATION_CUBIC:
1160 value = tp * tp * tp + 1;
1163 case CO_ANIMATION_CUBIC_REVERSE:
1165 value = tp * tp * tp + 1;
1167 case CO_ANIMATION_CUBIC_BOUNCE_IN:
1168 value = bounceMaker(t, 1, s);
1171 case CO_ANIMATION_CUBIC_BACK_IN:
1173 value = tp * tp * ((s + 1) * tp + s) + 1;
bool Create(wxWindow *parent, wxWindowID id=wxID_ANY, const wxString &caption=_("Set scale"), const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxDEFAULT_DIALOG_STYLE)
Creation.
wxTextCtrl * m_ScaleCtl
Should we show tooltips?
SetScaleDialog()
Constructors.