From: Toshi Nagata Date: Sat, 17 Sep 2022 14:59:08 +0000 (+0900) Subject: Win: high resolution display is implemented X-Git-Tag: v1.1.0~11 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=3ce19c39aec78f9dfd9d4b555974619bd9647c15;p=molby%2FMolby.git Win: high resolution display is implemented --- diff --git a/Makefile b/Makefile index a969785..ea7ffe5 100755 --- a/Makefile +++ b/Makefile @@ -39,7 +39,7 @@ ifeq ($(TARGET_PLATFORM),MSW) endif WXLIB_LIST = core,base,gl,adv -OBJECTS = ConsoleFrame.o GlobalParameterFrame.o GlobalParameterFilesFrame.o MoleculeView.o MyApp.o MyCommand.o MyDocument.o MyGLCanvas.o MySlider.o MyClipboardData.o ProgressFrame.o MyListCtrl.o MyDocManager.o wxKillAddition.o RubyDialogFrame.o MyIPCSupport.o MyVersion.o MyThread.o MyProgressIndicator.o modalwindow.o MyTextCtrl.o docview.o +OBJECTS = ConsoleFrame.o GlobalParameterFrame.o GlobalParameterFilesFrame.o MoleculeView.o MyApp.o MyCommand.o MyDocument.o MyGLCanvas.o MySlider.o MyClipboardData.o ProgressFrame.o MyListCtrl.o MyDocManager.o wxKillAddition.o RubyDialogFrame.o MyIPCSupport.o MyVersion.o MyThread.o MyProgressIndicator.o MyToggleButton.o modalwindow.o MyTextCtrl.o docview.o LIBS = MolLib.a Ruby_bind.a RUBY_EXTLIB = scanf.rb diff --git a/build-win/molby.rc b/build-win/molby.rc index 61d8583..bf25bbd 100644 --- a/build-win/molby.rc +++ b/build-win/molby.rc @@ -1,2 +1,3 @@ molbyicon ICON "../bitmaps/molby_icon.ico" +#define wxUSE_DPI_AWARE_MANIFEST 2 #include "wx/msw/wx.rc" diff --git a/build-win32/molby.rc b/build-win32/molby.rc index 61d8583..bf25bbd 100644 --- a/build-win32/molby.rc +++ b/build-win32/molby.rc @@ -1,2 +1,3 @@ molbyicon ICON "../bitmaps/molby_icon.ico" +#define wxUSE_DPI_AWARE_MANIFEST 2 #include "wx/msw/wx.rc" diff --git a/build-xcode/Molby.xcodeproj/project.pbxproj b/build-xcode/Molby.xcodeproj/project.pbxproj index 410c66d..cc90139 100644 --- a/build-xcode/Molby.xcodeproj/project.pbxproj +++ b/build-xcode/Molby.xcodeproj/project.pbxproj @@ -112,6 +112,8 @@ E420BE22188574F600A2B983 /* ProgressFrame.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E420BE1D188574F600A2B983 /* ProgressFrame.cpp */; }; E420BE23188574F600A2B983 /* RubyDialogFrame.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E420BE1F188574F600A2B983 /* RubyDialogFrame.cpp */; }; E420BE24188574F600A2B983 /* wxKillAddition.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E420BE21188574F600A2B983 /* wxKillAddition.cpp */; }; + E4589CEF28D5FD6400F55785 /* MyToggleButton.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E4589CEE28D5FD6400F55785 /* MyToggleButton.cpp */; }; + E4589CF028D5FD6400F55785 /* MyToggleButton.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E4589CEE28D5FD6400F55785 /* MyToggleButton.cpp */; }; E4653CB118A0CC7D0022377B /* textctrl_addition.mm in Sources */ = {isa = PBXBuildFile; fileRef = E4653CB018A0CC7D0022377B /* textctrl_addition.mm */; }; E4ACACE718C6D32300F08B67 /* ortep3 in Resources */ = {isa = PBXBuildFile; fileRef = E4ACACE418C6D32300F08B67 /* ortep3 */; }; E4D379A219C87C2200636D28 /* modalwindow.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E4D379A119C87C2200636D28 /* modalwindow.cpp */; }; @@ -230,6 +232,8 @@ E420BE1F188574F600A2B983 /* RubyDialogFrame.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RubyDialogFrame.cpp; sourceTree = ""; }; E420BE20188574F600A2B983 /* RubyDialogFrame.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RubyDialogFrame.h; sourceTree = ""; }; E420BE21188574F600A2B983 /* wxKillAddition.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = wxKillAddition.cpp; sourceTree = ""; }; + E4589CED28D5FD6400F55785 /* MyToggleButton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MyToggleButton.h; sourceTree = ""; }; + E4589CEE28D5FD6400F55785 /* MyToggleButton.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MyToggleButton.cpp; sourceTree = ""; }; E45B94611A170B9A008E95EB /* docview.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = docview.cpp; sourceTree = ""; }; E460B2DC2739716500CD9407 /* Version */ = {isa = PBXFileReference; lastKnownFileType = text; name = Version; path = ../Version; sourceTree = ""; }; E4653CB018A0CC7D0022377B /* textctrl_addition.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = textctrl_addition.mm; sourceTree = ""; }; @@ -541,6 +545,8 @@ E420BE05188574AD00A2B983 /* MyDocument.h */, E420BE06188574AD00A2B983 /* MyGLCanvas.cpp */, E420BE07188574AD00A2B983 /* MyGLCanvas.h */, + E4589CEE28D5FD6400F55785 /* MyToggleButton.cpp */, + E4589CED28D5FD6400F55785 /* MyToggleButton.h */, E420BE08188574AD00A2B983 /* MyIPCSupport.cpp */, E420BE09188574AD00A2B983 /* MyIPCSupport.h */, E420BE0A188574AD00A2B983 /* MyListCtrl_orig.cpp */, @@ -881,6 +887,7 @@ E4FC77BD183E4F3F0064FB2E /* ruby_types.c in Sources */, E4FC77BE183E4F3F0064FB2E /* Trackball.c in Sources */, E4FC77BF183E4F3F0064FB2E /* Types.c in Sources */, + E4589CEF28D5FD6400F55785 /* MyToggleButton.cpp in Sources */, E4FC7CA6183F94D30064FB2E /* buildInfo.c in Sources */, E420BDEF1885746700A2B983 /* ConsoleFrame.cpp in Sources */, E420BDF11885746700A2B983 /* GlobalParameterFilesFrame.cpp in Sources */, @@ -937,6 +944,7 @@ E4059FB728C46A6E0052B36B /* ConsoleFrame.cpp in Sources */, E403568628D0B7B0008E2C46 /* MyListCtrl.cpp in Sources */, E4059FB828C46A6E0052B36B /* filedlg.mm in Sources */, + E4589CF028D5FD6400F55785 /* MyToggleButton.cpp in Sources */, E4059FB928C46A6E0052B36B /* GlobalParameterFilesFrame.cpp in Sources */, E4059FBA28C46A6E0052B36B /* GlobalParameterFrame.cpp in Sources */, E4059FBC28C46A6E0052B36B /* MoleculeView.cpp in Sources */, diff --git a/wxSources/ConsoleFrame.cpp b/wxSources/ConsoleFrame.cpp index ad6ae32..d2d3d0b 100755 --- a/wxSources/ConsoleFrame.cpp +++ b/wxSources/ConsoleFrame.cpp @@ -142,7 +142,7 @@ ConsoleFrame::CreateConsoleFrame(wxFrame *parent) ConsoleFrame *frame = new ConsoleFrame(parent, _T("Molby Console"), origin, wxDefaultSize, wxDEFAULT_FRAME_STYLE | wxNO_FULL_REPAINT_ON_RESIZE); frame->OnCreate(); - frame->SetClientSize(size); + frame->SetClientSize(FromFrameDIP(frame, size)); return frame; } diff --git a/wxSources/GlobalParameterFilesFrame.cpp b/wxSources/GlobalParameterFilesFrame.cpp index 08a1f38..8fd1822 100644 --- a/wxSources/GlobalParameterFilesFrame.cpp +++ b/wxSources/GlobalParameterFilesFrame.cpp @@ -67,9 +67,9 @@ GlobalParameterFilesFrame::OnCreate() wxBoxSizer *sizer0; sizer0 = new wxBoxSizer(wxVERTICAL); listctrl = new MyListCtrl(); - listctrl->Create(this, wxID_ANY, wxDefaultPosition, size); - listctrl->InsertColumn(0, _T("name"), wxLIST_FORMAT_LEFT, 80); - listctrl->InsertColumn(1, _T("directory"), wxLIST_FORMAT_LEFT, 240); + listctrl->Create(this, wxID_ANY, wxDefaultPosition, FromFrameDIP(this, size)); + listctrl->InsertColumn(0, _T("name"), wxLIST_FORMAT_LEFT, FromFrameDIP(this, 80)); + listctrl->InsertColumn(1, _T("directory"), wxLIST_FORMAT_LEFT, FromFrameDIP(this, 240)); sizer0->Add(listctrl, 1, wxLEFT | wxRIGHT | wxEXPAND, 0); { wxBoxSizer *sizer1; @@ -100,7 +100,7 @@ GlobalParameterFilesFrame::CreateGlobalParameterFilesFrame(wxWindow *parent) wxSize size(700, 240); #endif - GlobalParameterFilesFrame *frame = new GlobalParameterFilesFrame(parent, _T("Load/Unload Global Parameters"), origin, size, wxDEFAULT_FRAME_STYLE | wxNO_FULL_REPAINT_ON_RESIZE); + GlobalParameterFilesFrame *frame = new GlobalParameterFilesFrame(parent, _T("Load/Unload Global Parameters"), FromFrameDIP(parent, origin), FromFrameDIP(parent, size), wxDEFAULT_FRAME_STYLE | wxNO_FULL_REPAINT_ON_RESIZE); frame->OnCreate(); return frame; diff --git a/wxSources/GlobalParameterFrame.cpp b/wxSources/GlobalParameterFrame.cpp index 8bc088a..b08c1e9 100755 --- a/wxSources/GlobalParameterFrame.cpp +++ b/wxSources/GlobalParameterFrame.cpp @@ -67,7 +67,7 @@ GlobalParameterFrame::CreateGlobalParameterFrame(wxWindow *parent) wxPoint origin(26, 40); wxSize size(774, 300); #endif - GlobalParameterFrame *frame = new GlobalParameterFrame(parent, _T("Global Parameters"), origin, size, wxDEFAULT_FRAME_STYLE | wxNO_FULL_REPAINT_ON_RESIZE); + GlobalParameterFrame *frame = new GlobalParameterFrame(parent, _T("Global Parameters"), FromFrameDIP(parent, origin), FromFrameDIP(parent, size), wxDEFAULT_FRAME_STYLE | wxNO_FULL_REPAINT_ON_RESIZE); frame->OnCreate(); return frame; diff --git a/wxSources/MoleculeView.cpp b/wxSources/MoleculeView.cpp index 4049f5f..d7faffb 100755 --- a/wxSources/MoleculeView.cpp +++ b/wxSources/MoleculeView.cpp @@ -119,10 +119,11 @@ MoleculeView::OnCreate(wxDocument *doc, long WXUNUSED(flags) ) // Make a document frame frame = new wxDocChildFrame(doc, this, GetMainFrame(), wxID_ANY, _T("New Molby Document"), - wxPoint(10, 24), wxSize(680, 400), + wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_STYLE | wxNO_FULL_REPAINT_ON_RESIZE); - + frame->SetPosition(FromFrameDIP(frame, wxPoint(10, 24))); + frame->SetClientSize(FromFrameDIP(frame, wxSize(680, 400))); canvas = NULL; mview = NULL; listmenu = NULL; @@ -202,16 +203,16 @@ MoleculeView::OnCreate(wxDocument *doc, long WXUNUSED(flags) ) myID_SelectButton, myID_BondButton, myID_EraseButton }; for (i = 0; i < 6; i++) { - tbuttons[i] = new wxToggleButton(panel1, ids[i], labels[i], wxDefaultPosition, wxSize(40, 32), wxTOGGLEBUTTON_STYLE); + tbuttons[i] = new MyToggleButton(panel1, ids[i], labels[i], wxDefaultPosition, FromFrameDIP(frame, wxSize(40, 32)), wxTOGGLEBUTTON_STYLE); if (ctrlFont) tbuttons[i]->SetFont(*ctrlFont); - sizer2->Add(tbuttons[i], 0, wxALL | wxEXPAND, 3); + sizer2->Add(tbuttons[i], 0, wxALL | wxEXPAND, FromFrameDIP(frame, 3)); } tbuttons[0]->SetValue(true); } { // Information text - infotext = new wxStaticText(panel1, -1, wxT(""), wxDefaultPosition, wxSize(80, 32), wxST_NO_AUTORESIZE | wxBORDER_SUNKEN); - infotext->SetMinSize(wxSize(80, 32)); + infotext = new wxStaticText(panel1, -1, wxT(""), wxDefaultPosition, FromFrameDIP(frame, wxSize(80, 32)), wxST_NO_AUTORESIZE | wxBORDER_SUNKEN); + infotext->SetMinSize(FromFrameDIP(frame, wxSize(80, 32))); #if defined(__WXMSW__) infotext->SetFont(*wxSMALL_FONT); #else @@ -221,7 +222,7 @@ MoleculeView::OnCreate(wxDocument *doc, long WXUNUSED(flags) ) sizer2->Add(infotext, 1, wxALL | wxEXPAND, 3); // Can expand horizontally } { // Custom progress indicator - progress = new MyProgressIndicator(panel1, myID_StopProgressButton, wxDefaultPosition, wxSize(12, 24)); + progress = new MyProgressIndicator(panel1, myID_StopProgressButton, wxDefaultPosition, FromFrameDIP(frame, wxSize(12, 24))); sizer2->Add(progress, 0, wxALL | wxEXPAND, 3); } sizer1->Add(sizer2, 0, wxALL | wxEXPAND, 0); @@ -247,7 +248,7 @@ MoleculeView::OnCreate(wxDocument *doc, long WXUNUSED(flags) ) { // Vertical sizer containing [Canvas, [button, mySlider]] wxBoxSizer *sizer32 = new wxBoxSizer(wxVERTICAL); { - canvas = new MyGLCanvas(this, panel1, wxDefaultPosition, wxSize(100, 100)); + canvas = new MyGLCanvas(this, panel1, wxDefaultPosition, FromFrameDIP(frame, wxSize(100, 100))); sizer32->Add(canvas, 1, wxALL | wxEXPAND, 0); // Let the MyGLCanvas pass the keyboard event to this @@ -258,10 +259,10 @@ MoleculeView::OnCreate(wxDocument *doc, long WXUNUSED(flags) ) { #include "../bitmaps/rotate_y.xpm" wxBitmap bmp2(rotate_y_xpm); - wxBitmapButton *button2 = new wxBitmapButton(panel1, -1, bmp2, wxDefaultPosition, wxSize(21, 21), wxTOGGLEBUTTON_STYLE); + wxBitmapButton *button2 = new wxBitmapButton(panel1, -1, bmp2, wxDefaultPosition, FromFrameDIP(frame, wxSize(21, 21)), wxTOGGLEBUTTON_STYLE); sizer321->Add(button2, 0, 0, 0); button2->Disable(); - MySlider *slider2 = new MySlider(panel1, myID_RotateYSlider, wxHORIZONTAL, wxDefaultPosition, wxSize(21, 21)); + MySlider *slider2 = new MySlider(panel1, myID_RotateYSlider, wxHORIZONTAL, wxDefaultPosition, FromFrameDIP(frame, wxSize(21, 21))); sizer321->Add(slider2, 1, wxEXPAND); } sizer32->Add(sizer321, 0, wxEXPAND); @@ -274,11 +275,11 @@ MoleculeView::OnCreate(wxDocument *doc, long WXUNUSED(flags) ) { // "Rotate bond" button and mySlider #include "../bitmaps/rotate_x.xpm" wxBitmap bmp3(rotate_x_xpm); - wxBitmapButton *button3 = new wxBitmapButton(panel1, -1, bmp3, wxDefaultPosition, wxSize(21, 21), wxTOGGLEBUTTON_STYLE); + wxBitmapButton *button3 = new wxBitmapButton(panel1, -1, bmp3, wxDefaultPosition, FromFrameDIP(frame, wxSize(21, 21)), wxTOGGLEBUTTON_STYLE); button3->Disable(); sizer33->Add(button3, 0, 0, 0); - MySlider *slider3 = new MySlider(panel1, myID_RotateXSlider, wxVERTICAL, wxDefaultPosition, wxSize(21, 21)); + MySlider *slider3 = new MySlider(panel1, myID_RotateXSlider, wxVERTICAL, wxDefaultPosition, FromFrameDIP(frame, wxSize(21, 21))); sizer33->Add(slider3, 1, wxEXPAND); } sizer3->Add(sizer33, 0, wxALL | wxEXPAND, 0); @@ -290,27 +291,27 @@ MoleculeView::OnCreate(wxDocument *doc, long WXUNUSED(flags) ) { // Horizontal sizer containing frame controls const int height = 18; - frameControlPanel = new wxPanel(panel1, myID_FrameControlPanel, wxDefaultPosition, wxSize(200, height)); + frameControlPanel = new wxPanel(panel1, myID_FrameControlPanel, wxDefaultPosition, FromFrameDIP(frame, wxSize(200, height))); wxBoxSizer *sizer4 = new wxBoxSizer(wxHORIZONTAL); { - frameSlider = new wxSlider(frameControlPanel, myID_FrameSlider, 0, 0, 1, wxDefaultPosition, wxSize(40, height - 2)); + frameSlider = new wxSlider(frameControlPanel, myID_FrameSlider, 0, 0, 1, wxDefaultPosition, FromFrameDIP(frame, wxSize(40, height - 2))); frameSlider->Enable(false); sizer4->Add(frameSlider, 1, wxALL | wxEXPAND, 1); #include "../bitmaps/jump_to_start.xpm" wxBitmap bmp41(jump_to_start_xpm); - wxBitmapButton *button41 = new wxBitmapButton(frameControlPanel, myID_JumpToStartButton, bmp41, wxDefaultPosition, wxSize(16, height), wxTOGGLEBUTTON_STYLE); + wxBitmapButton *button41 = new wxBitmapButton(frameControlPanel, myID_JumpToStartButton, bmp41, wxDefaultPosition, FromFrameDIP(frame, wxSize(16, height)), wxTOGGLEBUTTON_STYLE); sizer4->Add(button41, 0, wxEXPAND); ConnectMouseDownEvents(button41, MoleculeView::OnFrameButtonAction, this); #include "../bitmaps/play_backward.xpm" wxBitmap bmp42(play_backward_xpm); - wxBitmapButton *button42 = new wxBitmapButton(frameControlPanel, myID_PlayBackwardButton, bmp42, wxDefaultPosition, wxSize(16, height), wxTOGGLEBUTTON_STYLE); + wxBitmapButton *button42 = new wxBitmapButton(frameControlPanel, myID_PlayBackwardButton, bmp42, wxDefaultPosition, FromFrameDIP(frame, wxSize(16, height)), wxTOGGLEBUTTON_STYLE); sizer4->Add(button42, 0, wxEXPAND); ConnectMouseDownEvents(button42, MoleculeView::OnFrameButtonAction, this); { - frameText = new wxTextCtrl(frameControlPanel, myID_FrameText, wxT(""), wxDefaultPosition, wxSize(40, height)); + frameText = new wxTextCtrl(frameControlPanel, myID_FrameText, wxT(""), wxDefaultPosition, FromFrameDIP(frame, wxSize(40, height))); if (ctrlFont) { wxTextAttr attr(*wxBLACK, wxNullColour, *ctrlFont); frameText->SetDefaultStyle(attr); @@ -321,17 +322,17 @@ MoleculeView::OnCreate(wxDocument *doc, long WXUNUSED(flags) ) #include "../bitmaps/play_forward.xpm" wxBitmap bmp43(play_forward_xpm); - wxBitmapButton *button43 = new wxBitmapButton(frameControlPanel, myID_PlayForwardButton, bmp43, wxDefaultPosition, wxSize(16, height), wxTOGGLEBUTTON_STYLE); + wxBitmapButton *button43 = new wxBitmapButton(frameControlPanel, myID_PlayForwardButton, bmp43, wxDefaultPosition, FromFrameDIP(frame, wxSize(16, height)), wxTOGGLEBUTTON_STYLE); sizer4->Add(button43, 0, wxEXPAND); ConnectMouseDownEvents(button43, MoleculeView::OnFrameButtonAction, this); #include "../bitmaps/jump_to_end.xpm" wxBitmap bmp44(jump_to_end_xpm); - wxBitmapButton *button44 = new wxBitmapButton(frameControlPanel, myID_JumpToEndButton, bmp44, wxDefaultPosition, wxSize(16, height), wxTOGGLEBUTTON_STYLE); + wxBitmapButton *button44 = new wxBitmapButton(frameControlPanel, myID_JumpToEndButton, bmp44, wxDefaultPosition, FromFrameDIP(frame, wxSize(16, height)), wxTOGGLEBUTTON_STYLE); sizer4->Add(button44, 0, wxEXPAND); ConnectMouseDownEvents(button44, MoleculeView::OnFrameButtonAction, this); - wxPanel *spacer = new wxPanel(frameControlPanel, -1, wxDefaultPosition, wxSize(21, height)); + wxPanel *spacer = new wxPanel(frameControlPanel, -1, wxDefaultPosition, FromFrameDIP(frame, wxSize(21, height))); sizer4->Add(spacer, 0, wxEXPAND); } frameControlPanel->SetSizer(sizer4); @@ -349,7 +350,7 @@ MoleculeView::OnCreate(wxDocument *doc, long WXUNUSED(flags) ) frame->SetSizer(mainsizer); mainsizer->Layout(); - splitter->SetSashPosition(240, true); + splitter->SetSashPosition(FromFrameDIP(frame, 240), true); // Initialize table view MainView_createColumnsForTableAtIndex(mview, 0); @@ -1457,7 +1458,7 @@ MainViewCallback_addTableColumn(MainView *mview, const char *name, int width, in return 0; idx = listctrl->GetColumnCount(); listctrl->InsertColumn(idx, nstr, wxLIST_FORMAT_LEFT); - listctrl->SetColumnWidth(idx, width * 10); + listctrl->SetColumnWidth(idx, FromFrameDIP(listctrl, width * 10)); return idx; } diff --git a/wxSources/MoleculeView.h b/wxSources/MoleculeView.h index 0e4c369..b035215 100755 --- a/wxSources/MoleculeView.h +++ b/wxSources/MoleculeView.h @@ -22,11 +22,11 @@ #include "../MolLib/MolLib.h" #include "MyListCtrl.h" +#include "MyToggleButton.h" class MyDocument; class MyGLCanvas; class wxMenu; -class wxToggleButton; class wxStaticText; class wxChoice; class MyProgressIndicator; @@ -41,7 +41,7 @@ public: MyListCtrl *listctrl; wxMenu *file_history_menu; wxMenu *edit_menu; - wxToggleButton *tbuttons[6]; + MyToggleButton *tbuttons[6]; wxStaticText *infotext; MyProgressIndicator *progress; wxPanel *frameControlPanel; @@ -55,7 +55,7 @@ public: MyDocument *MolDocument() { return (MyDocument *)m_viewDocument; } MyListCtrl *GetListCtrl() { return listctrl; } - wxToggleButton *GetToggleButtonAtIndex(int i) { return (i >= 0 && i < 6 ? tbuttons[i] : NULL); } + MyToggleButton *GetToggleButtonAtIndex(int i) { return (i >= 0 && i < 6 ? tbuttons[i] : NULL); } bool OnCreate(wxDocument *doc, long flags); void OnDraw(wxDC *dc); diff --git a/wxSources/MyApp.cpp b/wxSources/MyApp.cpp index 4d49593..27d3c48 100755 --- a/wxSources/MyApp.cpp +++ b/wxSources/MyApp.cpp @@ -353,8 +353,9 @@ bool MyApp::OnInit(void) // Create the main frame window frame = new MyFrame((wxDocManager *) m_docManager, (wxFrame *) NULL, - _T("Molby"), wxPoint(0, 0), wxSize(800, 600), + _T("Molby"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_STYLE | wxNO_FULL_REPAINT_ON_RESIZE); + frame->SetClientSize(FromFrameDIP(frame, wxSize(800, 600))); // Give it an icon (this is ignored in MDI mode: uses resources) #ifdef __WXMSW__ @@ -1824,13 +1825,13 @@ AboutDialog::AboutDialog(): free(s2); free(s3); #if defined(__WXMSW__) - wxFont *textFont0 = new wxFont(12, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD); - wxFont *textFont1 = new wxFont(10, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL); - wxFont *textFont2 = new wxFont(9, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL); + wxFont *textFont0 = new wxFont(FromFrameDIP(this, 12), wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD); + wxFont *textFont1 = new wxFont(FromFrameDIP(this, 10), wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL); + wxFont *textFont2 = new wxFont(FromFrameDIP(this, 9), wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL); #else - wxFont *textFont0 = new wxFont(14, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD); - wxFont *textFont1 = new wxFont(12, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL); - wxFont *textFont2 = new wxFont(11, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL); + wxFont *textFont0 = new wxFont(FromFrameDIP(this, 14), wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD); + wxFont *textFont1 = new wxFont(FromFrameDIP(this, 12), wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL); + wxFont *textFont2 = new wxFont(FromFrameDIP(this, 11), wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL); #endif wxBoxSizer *vsizer1 = new wxBoxSizer(wxVERTICAL); wxBoxSizer *vsizer2 = new wxBoxSizer(wxVERTICAL); @@ -1842,17 +1843,17 @@ AboutDialog::AboutDialog(): wxStaticText *stext2 = new wxStaticText(this, -1, str2); stext2->SetFont(*textFont1); wxStaticBitmap *staticBitmap = new wxStaticBitmap(this, -1, *molbyBitmap); - vsizer2->Add(stext1, 0, wxALL | wxEXPAND, 2); - vsizer2->Add(stext2, 0, wxALL | wxEXPAND, 2); - hsizer1->AddSpacer(20); - hsizer1->Add(staticBitmap, 0, 0, 10); - hsizer1->AddSpacer(20); - hsizer1->Add(vsizer2, 0, wxALL | wxEXPAND, 5); + vsizer2->Add(stext1, 0, wxALL | wxEXPAND, FromFrameDIP(this, 2)); + vsizer2->Add(stext2, 0, wxALL | wxEXPAND, FromFrameDIP(this, 2)); + hsizer1->AddSpacer(FromFrameDIP(this, 20)); + hsizer1->Add(staticBitmap, 0, 0, FromFrameDIP(this, 10)); + hsizer1->AddSpacer(FromFrameDIP(this, 20)); + hsizer1->Add(vsizer2, 0, wxALL | wxEXPAND, FromFrameDIP(this, 5)); wxStaticText *stext3 = new wxStaticText(this, -1, str3); stext3->SetFont(*textFont2); - vsizer1->Add(hsizer1, 0, wxALL | wxEXPAND, 5); - vsizer1->Add(stext3, 0, wxALL | wxEXPAND, 5); - vsizer1->Add(this->CreateButtonSizer(wxOK), 0, wxALL | wxEXPAND, 10); + vsizer1->Add(hsizer1, 0, wxALL | wxEXPAND, FromFrameDIP(this, 5)); + vsizer1->Add(stext3, 0, wxALL | wxEXPAND, FromFrameDIP(this, 5)); + vsizer1->Add(this->CreateButtonSizer(wxOK), 0, wxALL | wxEXPAND, FromFrameDIP(this, 10)); vsizer1->Layout(); this->SetSizerAndFit(vsizer1); this->Centre(); @@ -2166,12 +2167,12 @@ MyAppCallback_getTextWithPrompt(const char *prompt, char *buf, int bufsize) { // Vertical sizer containing [prompt, textbox, buttons] wxBoxSizer *sizer1; sizer1 = new wxBoxSizer(wxVERTICAL); - stext = new wxStaticText(dialog, -1, pstr, wxDefaultPosition, wxSize(200, 22)); - sizer1->Add(stext, 0, wxEXPAND | wxALL, 6); - tctrl = new wxTextCtrl(dialog, -1, defstr, wxDefaultPosition, wxSize(200, 22)); - sizer1->Add(tctrl, 0, wxEXPAND | wxALL, 6); + stext = new wxStaticText(dialog, -1, pstr, wxDefaultPosition, FromFrameDIP(dialog, wxSize(200, 22))); + sizer1->Add(stext, 0, wxEXPAND | wxALL, FromFrameDIP(dialog, 6)); + tctrl = new wxTextCtrl(dialog, -1, defstr, wxDefaultPosition, FromFrameDIP(dialog, wxSize(200, 22))); + sizer1->Add(tctrl, 0, wxEXPAND | wxALL, FromFrameDIP(dialog, 6)); wxSizer *bsizer = dialog->CreateButtonSizer(wxOK | wxCANCEL); - sizer1->Add(bsizer, 0, wxEXPAND | wxALL, 6); + sizer1->Add(bsizer, 0, wxEXPAND | wxALL, FromFrameDIP(dialog, 6)); sizer1->Layout(); dialog->SetSizerAndFit(sizer1); dialog->Centre(wxBOTH); diff --git a/wxSources/MyApp.h b/wxSources/MyApp.h index 4548a8f..54be592 100755 --- a/wxSources/MyApp.h +++ b/wxSources/MyApp.h @@ -56,6 +56,17 @@ class MyDocument; #define wxTOGGLEBUTTON_STYLE 0 #endif +#if wxCHECK_VERSION(3,1,0) +#define FromFrameDIP(frame, x) frame->FromDIP(x) +#define ToFrameDIP(frame, x) frame->ToDIP(x) +#else +#define FromFrameDIP(frame, x) (x) +#define ToFrameDIP(frame, x) (x) +#endif + +#define FromDCDIP FromFrameDIP +#define ToDCDIP ToFrameDIP + enum { myMenuID_MyFirstMenuItem = 12000, myMenuID_Import = 12001, diff --git a/wxSources/MyListCtrl.cpp b/wxSources/MyListCtrl.cpp index e2d8959..6112306 100644 --- a/wxSources/MyListCtrl.cpp +++ b/wxSources/MyListCtrl.cpp @@ -24,6 +24,12 @@ #include "wx/menu.h" #include "wx/sizer.h" +#if wxCHECK_VERSION(3,1,0) +#define FromFrameDIP(frame, x) frame->FromDIP(x) +#else +#define FromFrameDIP(frame, x) (x) +#endif + const wxEventType MyListCtrlEvent = wxNewEventType(); IMPLEMENT_DYNAMIC_CLASS(MyListCtrl, wxWindow) @@ -76,12 +82,6 @@ MyListCtrl::Create(wxWindow* parent, wxWindowID wid, const wxPoint& pos, const w header = new wxWindow(this, 1001, wxPoint(0, 0), wxSize(size.x, 16)); scroll = new wxScrolledWindow(this, 1002, wxPoint(0, 16), wxSize(size.x, (size.y <= 16 ? -1 : size.y - 16))); - // Set sizer - wxBoxSizer *vsizer = new wxBoxSizer(wxVERTICAL); - vsizer->Add(header, wxSizerFlags(0).Expand().Border(wxALL, 0)); - vsizer->Add(scroll, wxSizerFlags(1).Expand().Border(wxALL, 0)); - this->SetSizer(vsizer); - // Connect events header->Bind(wxEVT_PAINT, &MyListCtrl::OnPaintHeader, this); scroll->Bind(wxEVT_PAINT, &MyListCtrl::OnPaint, this); @@ -110,7 +110,14 @@ MyListCtrl::Create(wxWindow* parent, wxWindowID wid, const wxPoint& pos, const w rowHeight = h + 2; dc.GetTextExtent(_T("M"), &w, &h, &descent, &leading, &headerFont); headerHeight = h + 2; + header->SetSize(wxSize(size.x, headerHeight)); } + + // Set sizer + wxBoxSizer *vsizer = new wxBoxSizer(wxVERTICAL); + vsizer->Add(header, wxSizerFlags(0).Expand().Border(wxALL, 0)); + vsizer->Add(scroll, wxSizerFlags(1).Expand().Border(wxALL, 0)); + this->SetSizer(vsizer); selectionChangeNotificationRequired = false; selectionChangeNotificationEnabled = true; @@ -179,7 +186,7 @@ MyListCtrl::RefreshTable(bool refreshWindow) } // rowHeight = dataSource->GetRowHeight(this); // "+4" is for drawing marker during cell dragging - pageHeight = rowHeight * nrows + 4; + pageHeight = rowHeight * nrows + FromFrameDIP(this, 4); // Set the subwindow infos sz.y = headerHeight; header->SetMinSize(sz); @@ -237,6 +244,7 @@ MyListCtrl::OnPaint(wxPaintEvent &event) wxTextAttr attr; wxString str; int x, y; + int mg = FromFrameDIP(this, 2); row = floor(oy / rowHeight); for (j = row; j < nrows; j++) { float fg0[4], bg0[4]; @@ -321,8 +329,8 @@ MyListCtrl::OnPaint(wxPaintEvent &event) if (i == ncols - 1) { dc.DrawLine(x + colWidths[i], y, x + colWidths[i], y + rowHeight - 1); } - dc.SetClippingRegion(x + 2, y, colWidths[i] - 4, rowHeight - 1); - dc.DrawText(str, x + 2, y); + dc.SetClippingRegion(x + mg, y, colWidths[i] - mg * 2, rowHeight - 1); + dc.DrawText(str, x + mg, y); dc.DestroyClippingRegion(); x += colWidths[i]; if (x > ox + sz.x) @@ -351,6 +359,7 @@ MyListCtrl::OnPaintHeader(wxPaintEvent &event) int x, x1; int i; wxTextAttr attr; + int mg = FromFrameDIP(this, 2); scroll->CalcUnscrolledPosition(0, 0, &ox, &oy); x = -ox; for (i = 0; i < ncols; i++) { @@ -358,8 +367,8 @@ MyListCtrl::OnPaintHeader(wxPaintEvent &event) if (x1 > 0) { wxString str = colNames[i]; dc.DrawLine(x + colWidths[i], 0, x + colWidths[i], sz.y - 1); - dc.SetClippingRegion(x + 2, 0, colWidths[i] - 4, sz.y); - dc.DrawText(str, x + 2, 0); + dc.SetClippingRegion(x + mg, 0, colWidths[i] - mg * 2, sz.y); + dc.DrawText(str, x + mg, 0); dc.DestroyClippingRegion(); } x = x1; diff --git a/wxSources/MyToggleButton.cpp b/wxSources/MyToggleButton.cpp new file mode 100755 index 0000000..bfa215e --- /dev/null +++ b/wxSources/MyToggleButton.cpp @@ -0,0 +1,78 @@ +/* + * MyToggleButton + * Molby + * + * Created by Toshi Nagata on 2022/09/17. + * Copyright 2022 Toshi Nagata. All rights reserved. + * + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + */ + +#include "MyToggleButton.h" +#include "wx/dcclient.h" + +IMPLEMENT_DYNAMIC_CLASS(MyToggleButton, wxToggleButton) + +BEGIN_EVENT_TABLE(MyToggleButton, wxToggleButton) +EVT_PAINT(MyToggleButton::OnPaint) +EVT_LEFT_DOWN(MyToggleButton::OnLeftDown) +EVT_LEFT_UP(MyToggleButton::OnLeftUp) +END_EVENT_TABLE() + +void +MyToggleButton::OnPaint(wxPaintEvent &event) +{ + wxPaintDC dc(this); + wxSize size = GetSize(); + dc.SetPen(*wxGREY_PEN); + const wxBrush *brush; + if (IsPressed()) + brush = wxTheBrushList->FindOrCreateBrush(wxColour(128, 128, 128)); + else if (GetValue()) + brush = wxTheBrushList->FindOrCreateBrush(wxColour(180, 180, 180)); + else + brush = wxTheBrushList->FindOrCreateBrush(wxColour(240, 240, 240)); + dc.SetBrush(*brush); + dc.DrawRectangle(0, 0, size.x, size.y); + wxString label = GetLabel(); + int w, h, descent; + int x, y; + dc.GetTextExtent(label, &w, &h, &descent); + x = (size.x - w) / 2; + y = (size.y - h) / 2; + dc.SetPen(*wxBLACK_PEN); + dc.DrawText(label, x, y); +} + +void +MyToggleButton::OnLeftDown(wxMouseEvent &event) +{ + CaptureMouse(); + SetPressed(true); + Refresh(); +} + +void +MyToggleButton::OnLeftUp(wxMouseEvent &event) +{ + ReleaseMouse(); + SetPressed(false); + int x = event.GetX(); + int y = event.GetY(); + wxSize sz = GetSize(); + if (x > 0 && x < sz.x && y > 0 && y < sz.y) { + SetValue(!GetValue()); + wxCommandEvent cmdevt(wxEVT_TOGGLEBUTTON, GetId()); + cmdevt.SetInt(GetValue()); + cmdevt.SetEventObject(this); + ProcessCommand(cmdevt); + Refresh(); + } +} diff --git a/wxSources/MyToggleButton.h b/wxSources/MyToggleButton.h new file mode 100755 index 0000000..bb4907f --- /dev/null +++ b/wxSources/MyToggleButton.h @@ -0,0 +1,50 @@ +/* + * MyToggleButton.h + * Molby + * + * Created by Toshi Nagata on 2022/09/17. + * Copyright 2022 Toshi Nagata. All rights reserved. + * + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + */ + +#ifndef __MyToggleButton_h__ +#define __MyToggleButton_h__ + +#include "wx/tglbtn.h" + +class MyToggleButton: public wxToggleButton +{ +public: + MyToggleButton() {} + MyToggleButton (wxWindow *parent, wxWindowID id, const wxString &label, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=0, const wxValidator &val=wxDefaultValidator, const wxString &name=wxCheckBoxNameStr) + : wxToggleButton(parent, id, label, pos, size, style, val, name) { + m_isPressed = m_value = false; + } + + void OnPaint(wxPaintEvent &event); + void OnLeftDown(wxMouseEvent &event); + void OnLeftUp(wxMouseEvent &event); + void SetValue(bool val) { m_value = val; Refresh(); } + bool GetValue() { return m_value; } + void SetPressed(bool flag) { m_isPressed = flag; Refresh(); } + bool IsPressed() { return m_isPressed; } + +private: + bool m_isPressed; + bool m_value; + bool m_isEnabled; + DECLARE_DYNAMIC_CLASS(MyToggleButton) + DECLARE_EVENT_TABLE() +}; + + +#endif /* __MyToggleButton_h__ */ + diff --git a/wxSources/RubyDialogFrame.cpp b/wxSources/RubyDialogFrame.cpp index 1b60777..77637d6 100644 --- a/wxSources/RubyDialogFrame.cpp +++ b/wxSources/RubyDialogFrame.cpp @@ -83,7 +83,7 @@ RubyDialogFrame::RubyDialogFrame(wxWindow* parent, wxWindowID wid, const wxStrin buttonSizer = NULL; // Will be created later myTimer = NULL; // Will be created when necessary boxSizer = new wxBoxSizer(wxVERTICAL); - boxSizer->Add(contentSizer, 1, wxALL | wxEXPAND, 14); + boxSizer->Add(contentSizer, 1, wxALL | wxEXPAND, FromFrameDIP(this, 14)); this->SetSizer(boxSizer); boxSizer->Layout(); } @@ -196,7 +196,7 @@ RubyDialogFrame::CreateStandardButtons(const char *oktitle, const char *cancelti if (sizer == NULL) return; /* Cannot create */ if (buttonSizer == NULL) { - boxSizer->Add(sizer, 0, wxBOTTOM | wxLEFT | wxRIGHT | wxEXPAND, 14); + boxSizer->Add(sizer, 0, wxBOTTOM | wxLEFT | wxRIGHT | wxEXPAND, FromFrameDIP(this, 14)); buttonSizer = sizer; } else { boxSizer->Replace(buttonSizer, sizer); @@ -872,7 +872,8 @@ wxRectFromRDRect(RDRect rframe) RDSize RubyDialogCallback_windowMinSize(RubyDialog *dref) { - wxSize minSize = ((RubyDialogFrame *)dref)->GetMinSize(); + RubyDialogFrame *dframe = (RubyDialogFrame *)dref; + wxSize minSize = ToFrameDIP(dframe, dframe->GetMinSize()); RDSize rminSize; rminSize.width = minSize.GetWidth(); rminSize.height = minSize.GetHeight(); @@ -882,16 +883,18 @@ RubyDialogCallback_windowMinSize(RubyDialog *dref) void RubyDialogCallback_setWindowMinSize(RubyDialog *dref, RDSize size) { + RubyDialogFrame *dframe = (RubyDialogFrame *)dref; wxSize minSize; minSize.x = (int)size.width; minSize.y = (int)size.height; - ((RubyDialogFrame *)dref)->SetMinSize(minSize); + dframe->SetMinSize(FromFrameDIP(dframe, minSize)); } RDSize RubyDialogCallback_windowSize(RubyDialog *dref) { - wxSize minSize = ((RubyDialogFrame *)dref)->GetSize(); + RubyDialogFrame *dframe = (RubyDialogFrame *)dref; + wxSize minSize = ToFrameDIP(dframe, dframe->GetSize()); RDSize rminSize; rminSize.width = minSize.GetWidth(); rminSize.height = minSize.GetHeight(); @@ -900,9 +903,10 @@ RubyDialogCallback_windowSize(RubyDialog *dref) void RubyDialogCallback_setWindowSize(RubyDialog *dref, RDSize size) { + RubyDialogFrame *dframe = (RubyDialogFrame *)dref; wxSize wsize((int)size.width, (int)size.height); - ((RubyDialogFrame *)dref)->SetSize(wsize); - ((RubyDialogFrame *)dref)->CentreOnScreen(); + dframe->SetSize(FromFrameDIP(dframe, wsize)); + dframe->CentreOnScreen(); } void @@ -969,10 +973,10 @@ RubyDialogCallback_createItem(RubyDialog *dref, const char *type, const char *ti rect.SetPosition(wxDefaultPosition); rect.SetSize(wxDefaultSize); } else { - rect.SetX(rect.x + offset.x); - rect.SetY(rect.y + offset.y); - rect.SetWidth(rect.width + offset.width); - rect.SetHeight(rect.height + offset.height); + rect.SetX(FromFrameDIP(parent, rect.x + offset.x)); + rect.SetY(FromFrameDIP(parent, rect.y + offset.y)); + rect.SetWidth(FromFrameDIP(parent, rect.width + offset.width)); + rect.SetHeight(FromFrameDIP(parent, rect.height + offset.height)); } if (strcmp(type, "text") == 0) { @@ -1055,14 +1059,14 @@ RubyDialogCallback_createItem(RubyDialog *dref, const char *type, const char *ti if (title[0] != 0 || strcmp(type, "textfield") == 0) { /* Resize the frame rect as necessary */ RDSize minSize = RubyDialogCallback_sizeOfString((RDItem *)control, title); - wxSize size = control->GetSize(); + wxSize size = ToFrameDIP(parent, control->GetSize()); if (size.GetHeight() < minSize.height) size.SetHeight(minSize.height); if (size.GetWidth() < minSize.width) size.SetWidth(minSize.width); size.SetWidth(size.GetWidth() + offset.width); size.SetHeight(size.GetHeight() + offset.height); - control->SetSize(size); + control->SetSize(FromFrameDIP(parent, size)); } if (wxDynamicCast(control, wxTextCtrl) != NULL) { @@ -1094,10 +1098,11 @@ RubyDialogCallback_indexOfItem(RubyDialog *dref, RDItem *item) void RubyDialogCallback_moveItemUnderView(RDItem *item, RDItem *superView, RDPoint origin) { + wxWindow *sv = (wxWindow *)superView; if (item == NULL || superView == NULL || item == superView) return; - if (((wxWindow *)item)->Reparent((wxWindow *)superView)) { - ((wxWindow *)item)->Move(origin.x, origin.y); + if (((wxWindow *)item)->Reparent(sv)) { + ((wxWindow *)item)->Move(FromFrameDIP(sv, origin.x), FromFrameDIP(sv, origin.y)); } } @@ -1110,29 +1115,39 @@ RubyDialogCallback_superview(RDItem *item) RDRect RubyDialogCallback_frameOfItem(RDItem *item) { - wxRect rect = ((wxWindow *)item)->GetRect(); + wxWindow *wp = (wxWindow *)item; + wxRect rect = wp->GetRect(); if (gRubyDialogIsFlipped) { - wxWindow *parent = ((wxWindow *)item)->GetParent(); + wxWindow *parent = wp->GetParent(); if (parent != NULL) { wxRect superRect = parent->GetRect(); rect.SetY(superRect.GetHeight() - rect.GetHeight() - rect.GetY()); } } + rect.x = ToFrameDIP(wp, rect.x); + rect.y = ToFrameDIP(wp, rect.y); + rect.width = ToFrameDIP(wp, rect.width); + rect.height = ToFrameDIP(wp, rect.height); return RDRectFromwxRect(rect); } void RubyDialogCallback_setFrameOfItem(RDItem *item, RDRect rect) { + wxWindow *wp = (wxWindow *)item; wxRect wrect = wxRectFromRDRect(rect); if (gRubyDialogIsFlipped) { - wxWindow *parent = ((wxWindow *)item)->GetParent(); + wxWindow *parent = wp->GetParent(); if (parent != NULL) { wxRect srect = parent->GetRect(); wrect.SetY(srect.GetHeight() - wrect.GetHeight() - wrect.GetY()); } } - ((wxWindow *)item)->SetSize(wrect); + wrect.x = FromFrameDIP(wp, wrect.x); + wrect.y = FromFrameDIP(wp, wrect.y); + wrect.width = FromFrameDIP(wp, wrect.width); + wrect.height = FromFrameDIP(wp, wrect.height); + wp->SetSize(wrect); } void @@ -1303,14 +1318,14 @@ RubyDialogCallback_setFontForItem(RDItem *item, int size, int family, int style, } if (textctrl != NULL) { wxTextAttr newAttr; - wxFont newFont(size, family, style, weight); + wxFont newFont(FromFrameDIP(textctrl, size), family, style, weight); newAttr.SetFont(newFont); textctrl->SetDefaultStyle(newAttr); #if __WXMAC__ textctrl->SetFont(newFont); #endif } else { - ctrl->SetFont(wxFont(size, family, style, weight)); + ctrl->SetFont(wxFont(FromFrameDIP(ctrl, size), family, style, weight)); wxString label = ctrl->GetLabel(); ctrl->SetLabel(_("")); ctrl->SetLabel(label); /* Update the control size */ @@ -1326,7 +1341,7 @@ RubyDialogCallback_getFontForItem(RDItem *item, int *size, int *family, int *sty wxTextAttr attr = ctrl->GetDefaultStyle(); wxFont font = attr.GetFont(); if (size != NULL) - *size = font.GetPointSize(); + *size = ToFrameDIP(ctrl, font.GetPointSize()); if (family != NULL) { n = font.GetFamily(); *family = (n == wxFONTFAMILY_DEFAULT ? 1 : @@ -1498,6 +1513,8 @@ RubyDialogCallback_sizeOfString(RDItem *item, const char *s) break; s1 = s2 + 1; } + size.width = ToFrameDIP(((wxWindow *)item), size.width); + size.height = ToFrameDIP(((wxWindow *)item), size.height); return size; } @@ -1508,8 +1525,8 @@ RubyDialogCallback_resizeToBest(RDItem *item) RDSize rsize; size = ((wxWindow *)item)->GetBestSize(); ((wxWindow *)item)->SetSize(size); - rsize.width = size.GetWidth(); - rsize.height = size.GetHeight(); + rsize.width = ToFrameDIP(((wxWindow *)item), size.GetWidth()); + rsize.height = ToFrameDIP(((wxWindow *)item), size.GetHeight()); return rsize; } @@ -1686,7 +1703,7 @@ RubyDialogCallback_drawEllipse(RDDeviceContext *dc, float x, float y, float r1, wxDC *dcp = (wxDC *)dc; if (dcp == NULL) return; - dcp->DrawEllipse(x - r1, y - r2, r1 * 2, r2 * 2); + dcp->DrawEllipse(FromDCDIP(dcp, x - r1), FromDCDIP(dcp, y - r2), FromDCDIP(dcp, r1 * 2), FromDCDIP(dcp, r2 * 2)); } void @@ -1698,8 +1715,8 @@ RubyDialogCallback_drawLine(RDDeviceContext *dc, int ncoords, float *coords) wxPoint *pts = new wxPoint[ncoords]; int i; for (i = 0; i < ncoords; i++) { - pts[i].x = (int)coords[i * 2]; - pts[i].y = (int)coords[i * 2 + 1]; + pts[i].x = FromDCDIP(dcp, (int)coords[i * 2]); + pts[i].y = FromDCDIP(dcp, (int)coords[i * 2 + 1]); } dcp->DrawLines(ncoords, pts); delete [] pts; @@ -1712,9 +1729,9 @@ RubyDialogCallback_drawRectangle(RDDeviceContext *dc, float x, float y, float wi if (dcp == NULL) return; if (round > 0.0) - dcp->DrawRoundedRectangle((int)x, (int)y, (int)width, (int)height, (int)round); + dcp->DrawRoundedRectangle(FromDCDIP(dcp, x), FromDCDIP(dcp, y), FromDCDIP(dcp, width), FromDCDIP(dcp, height), FromDCDIP(dcp, round)); else - dcp->DrawRectangle((int)x, (int)y, (int)width, (int)height); + dcp->DrawRectangle(FromDCDIP(dcp, x), FromDCDIP(dcp, y), FromDCDIP(dcp, width), FromDCDIP(dcp, height)); } void @@ -1724,7 +1741,7 @@ RubyDialogCallback_drawText(RDDeviceContext *dc, const char *s, float x, float y if (dcp == NULL) return; wxString str(s, WX_DEFAULT_CONV); - dcp->DrawText(str, (int)x, (int)y); + dcp->DrawText(str, FromDCDIP(dcp, x), FromDCDIP(dcp, y)); } void @@ -1737,7 +1754,7 @@ RubyDialogCallback_setFont(RDDeviceContext *dc, void **args) wxFont font = dcp->GetFont(); for (i = 0; args[i] != NULL; i += 2) { if (strcmp((const char *)args[i], "size") == 0) { - float size = *((float *)(args[i + 1])); + float size = FromDCDIP(dcp, *((float *)(args[i + 1]))); font.SetPointSize((int)size); } else if (strcmp((const char *)args[i], "style") == 0) { long style = (intptr_t)(args[i + 1]); @@ -1790,7 +1807,7 @@ RubyDialogCallback_setPen(RDDeviceContext *dc, void **args) wxColour col((int)(fp[0] * 255.0), (int)(fp[1] * 255.0), (int)(fp[2] * 255.0), (int)(fp[3] * 255.0)); pen.SetColour(col); } else if (strcmp((const char *)args[i], "width") == 0) { - float width = *((float *)(args[i + 1])); + float width = FromDCDIP(dcp, *((float *)(args[i + 1]))); pen.SetWidth((int)width); } else if (strcmp((const char *)args[i], "style") == 0) { long style = (intptr_t)(args[i + 1]);