Molecular Modeling Software
リビジョン | 3ce19c39aec78f9dfd9d4b555974619bd9647c15 (tree) |
---|---|
日時 | 2022-09-17 23:59:08 |
作者 | Toshi Nagata <alchemist.2005@nift...> |
コミッター | Toshi Nagata |
Win: high resolution display is implemented
@@ -39,7 +39,7 @@ ifeq ($(TARGET_PLATFORM),MSW) | ||
39 | 39 | endif |
40 | 40 | |
41 | 41 | WXLIB_LIST = core,base,gl,adv |
42 | -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 | |
42 | +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 | |
43 | 43 | LIBS = MolLib.a Ruby_bind.a |
44 | 44 | RUBY_EXTLIB = scanf.rb |
45 | 45 |
@@ -1,2 +1,3 @@ | ||
1 | 1 | molbyicon ICON "../bitmaps/molby_icon.ico" |
2 | +#define wxUSE_DPI_AWARE_MANIFEST 2 | |
2 | 3 | #include "wx/msw/wx.rc" |
@@ -1,2 +1,3 @@ | ||
1 | 1 | molbyicon ICON "../bitmaps/molby_icon.ico" |
2 | +#define wxUSE_DPI_AWARE_MANIFEST 2 | |
2 | 3 | #include "wx/msw/wx.rc" |
@@ -112,6 +112,8 @@ | ||
112 | 112 | E420BE22188574F600A2B983 /* ProgressFrame.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E420BE1D188574F600A2B983 /* ProgressFrame.cpp */; }; |
113 | 113 | E420BE23188574F600A2B983 /* RubyDialogFrame.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E420BE1F188574F600A2B983 /* RubyDialogFrame.cpp */; }; |
114 | 114 | E420BE24188574F600A2B983 /* wxKillAddition.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E420BE21188574F600A2B983 /* wxKillAddition.cpp */; }; |
115 | + E4589CEF28D5FD6400F55785 /* MyToggleButton.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E4589CEE28D5FD6400F55785 /* MyToggleButton.cpp */; }; | |
116 | + E4589CF028D5FD6400F55785 /* MyToggleButton.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E4589CEE28D5FD6400F55785 /* MyToggleButton.cpp */; }; | |
115 | 117 | E4653CB118A0CC7D0022377B /* textctrl_addition.mm in Sources */ = {isa = PBXBuildFile; fileRef = E4653CB018A0CC7D0022377B /* textctrl_addition.mm */; }; |
116 | 118 | E4ACACE718C6D32300F08B67 /* ortep3 in Resources */ = {isa = PBXBuildFile; fileRef = E4ACACE418C6D32300F08B67 /* ortep3 */; }; |
117 | 119 | E4D379A219C87C2200636D28 /* modalwindow.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E4D379A119C87C2200636D28 /* modalwindow.cpp */; }; |
@@ -230,6 +232,8 @@ | ||
230 | 232 | E420BE1F188574F600A2B983 /* RubyDialogFrame.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RubyDialogFrame.cpp; sourceTree = "<group>"; }; |
231 | 233 | E420BE20188574F600A2B983 /* RubyDialogFrame.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RubyDialogFrame.h; sourceTree = "<group>"; }; |
232 | 234 | E420BE21188574F600A2B983 /* wxKillAddition.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = wxKillAddition.cpp; sourceTree = "<group>"; }; |
235 | + E4589CED28D5FD6400F55785 /* MyToggleButton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MyToggleButton.h; sourceTree = "<group>"; }; | |
236 | + E4589CEE28D5FD6400F55785 /* MyToggleButton.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MyToggleButton.cpp; sourceTree = "<group>"; }; | |
233 | 237 | E45B94611A170B9A008E95EB /* docview.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = docview.cpp; sourceTree = "<group>"; }; |
234 | 238 | E460B2DC2739716500CD9407 /* Version */ = {isa = PBXFileReference; lastKnownFileType = text; name = Version; path = ../Version; sourceTree = "<group>"; }; |
235 | 239 | E4653CB018A0CC7D0022377B /* textctrl_addition.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = textctrl_addition.mm; sourceTree = "<group>"; }; |
@@ -541,6 +545,8 @@ | ||
541 | 545 | E420BE05188574AD00A2B983 /* MyDocument.h */, |
542 | 546 | E420BE06188574AD00A2B983 /* MyGLCanvas.cpp */, |
543 | 547 | E420BE07188574AD00A2B983 /* MyGLCanvas.h */, |
548 | + E4589CEE28D5FD6400F55785 /* MyToggleButton.cpp */, | |
549 | + E4589CED28D5FD6400F55785 /* MyToggleButton.h */, | |
544 | 550 | E420BE08188574AD00A2B983 /* MyIPCSupport.cpp */, |
545 | 551 | E420BE09188574AD00A2B983 /* MyIPCSupport.h */, |
546 | 552 | E420BE0A188574AD00A2B983 /* MyListCtrl_orig.cpp */, |
@@ -881,6 +887,7 @@ | ||
881 | 887 | E4FC77BD183E4F3F0064FB2E /* ruby_types.c in Sources */, |
882 | 888 | E4FC77BE183E4F3F0064FB2E /* Trackball.c in Sources */, |
883 | 889 | E4FC77BF183E4F3F0064FB2E /* Types.c in Sources */, |
890 | + E4589CEF28D5FD6400F55785 /* MyToggleButton.cpp in Sources */, | |
884 | 891 | E4FC7CA6183F94D30064FB2E /* buildInfo.c in Sources */, |
885 | 892 | E420BDEF1885746700A2B983 /* ConsoleFrame.cpp in Sources */, |
886 | 893 | E420BDF11885746700A2B983 /* GlobalParameterFilesFrame.cpp in Sources */, |
@@ -937,6 +944,7 @@ | ||
937 | 944 | E4059FB728C46A6E0052B36B /* ConsoleFrame.cpp in Sources */, |
938 | 945 | E403568628D0B7B0008E2C46 /* MyListCtrl.cpp in Sources */, |
939 | 946 | E4059FB828C46A6E0052B36B /* filedlg.mm in Sources */, |
947 | + E4589CF028D5FD6400F55785 /* MyToggleButton.cpp in Sources */, | |
940 | 948 | E4059FB928C46A6E0052B36B /* GlobalParameterFilesFrame.cpp in Sources */, |
941 | 949 | E4059FBA28C46A6E0052B36B /* GlobalParameterFrame.cpp in Sources */, |
942 | 950 | E4059FBC28C46A6E0052B36B /* MoleculeView.cpp in Sources */, |
@@ -142,7 +142,7 @@ ConsoleFrame::CreateConsoleFrame(wxFrame *parent) | ||
142 | 142 | ConsoleFrame *frame = new ConsoleFrame(parent, _T("Molby Console"), origin, wxDefaultSize, wxDEFAULT_FRAME_STYLE | wxNO_FULL_REPAINT_ON_RESIZE); |
143 | 143 | |
144 | 144 | frame->OnCreate(); |
145 | - frame->SetClientSize(size); | |
145 | + frame->SetClientSize(FromFrameDIP(frame, size)); | |
146 | 146 | |
147 | 147 | return frame; |
148 | 148 | } |
@@ -67,9 +67,9 @@ GlobalParameterFilesFrame::OnCreate() | ||
67 | 67 | wxBoxSizer *sizer0; |
68 | 68 | sizer0 = new wxBoxSizer(wxVERTICAL); |
69 | 69 | listctrl = new MyListCtrl(); |
70 | - listctrl->Create(this, wxID_ANY, wxDefaultPosition, size); | |
71 | - listctrl->InsertColumn(0, _T("name"), wxLIST_FORMAT_LEFT, 80); | |
72 | - listctrl->InsertColumn(1, _T("directory"), wxLIST_FORMAT_LEFT, 240); | |
70 | + listctrl->Create(this, wxID_ANY, wxDefaultPosition, FromFrameDIP(this, size)); | |
71 | + listctrl->InsertColumn(0, _T("name"), wxLIST_FORMAT_LEFT, FromFrameDIP(this, 80)); | |
72 | + listctrl->InsertColumn(1, _T("directory"), wxLIST_FORMAT_LEFT, FromFrameDIP(this, 240)); | |
73 | 73 | sizer0->Add(listctrl, 1, wxLEFT | wxRIGHT | wxEXPAND, 0); |
74 | 74 | { |
75 | 75 | wxBoxSizer *sizer1; |
@@ -100,7 +100,7 @@ GlobalParameterFilesFrame::CreateGlobalParameterFilesFrame(wxWindow *parent) | ||
100 | 100 | wxSize size(700, 240); |
101 | 101 | #endif |
102 | 102 | |
103 | - GlobalParameterFilesFrame *frame = new GlobalParameterFilesFrame(parent, _T("Load/Unload Global Parameters"), origin, size, wxDEFAULT_FRAME_STYLE | wxNO_FULL_REPAINT_ON_RESIZE); | |
103 | + GlobalParameterFilesFrame *frame = new GlobalParameterFilesFrame(parent, _T("Load/Unload Global Parameters"), FromFrameDIP(parent, origin), FromFrameDIP(parent, size), wxDEFAULT_FRAME_STYLE | wxNO_FULL_REPAINT_ON_RESIZE); | |
104 | 104 | |
105 | 105 | frame->OnCreate(); |
106 | 106 | return frame; |
@@ -67,7 +67,7 @@ GlobalParameterFrame::CreateGlobalParameterFrame(wxWindow *parent) | ||
67 | 67 | wxPoint origin(26, 40); |
68 | 68 | wxSize size(774, 300); |
69 | 69 | #endif |
70 | - GlobalParameterFrame *frame = new GlobalParameterFrame(parent, _T("Global Parameters"), origin, size, wxDEFAULT_FRAME_STYLE | wxNO_FULL_REPAINT_ON_RESIZE); | |
70 | + GlobalParameterFrame *frame = new GlobalParameterFrame(parent, _T("Global Parameters"), FromFrameDIP(parent, origin), FromFrameDIP(parent, size), wxDEFAULT_FRAME_STYLE | wxNO_FULL_REPAINT_ON_RESIZE); | |
71 | 71 | |
72 | 72 | frame->OnCreate(); |
73 | 73 | return frame; |
@@ -119,10 +119,11 @@ MoleculeView::OnCreate(wxDocument *doc, long WXUNUSED(flags) ) | ||
119 | 119 | |
120 | 120 | // Make a document frame |
121 | 121 | frame = new wxDocChildFrame(doc, this, GetMainFrame(), wxID_ANY, _T("New Molby Document"), |
122 | - wxPoint(10, 24), wxSize(680, 400), | |
122 | + wxDefaultPosition, wxDefaultSize, | |
123 | 123 | wxDEFAULT_FRAME_STYLE | |
124 | 124 | wxNO_FULL_REPAINT_ON_RESIZE); |
125 | - | |
125 | + frame->SetPosition(FromFrameDIP(frame, wxPoint(10, 24))); | |
126 | + frame->SetClientSize(FromFrameDIP(frame, wxSize(680, 400))); | |
126 | 127 | canvas = NULL; |
127 | 128 | mview = NULL; |
128 | 129 | listmenu = NULL; |
@@ -202,16 +203,16 @@ MoleculeView::OnCreate(wxDocument *doc, long WXUNUSED(flags) ) | ||
202 | 203 | myID_SelectButton, myID_BondButton, myID_EraseButton |
203 | 204 | }; |
204 | 205 | for (i = 0; i < 6; i++) { |
205 | - tbuttons[i] = new wxToggleButton(panel1, ids[i], labels[i], wxDefaultPosition, wxSize(40, 32), wxTOGGLEBUTTON_STYLE); | |
206 | + tbuttons[i] = new MyToggleButton(panel1, ids[i], labels[i], wxDefaultPosition, FromFrameDIP(frame, wxSize(40, 32)), wxTOGGLEBUTTON_STYLE); | |
206 | 207 | if (ctrlFont) |
207 | 208 | tbuttons[i]->SetFont(*ctrlFont); |
208 | - sizer2->Add(tbuttons[i], 0, wxALL | wxEXPAND, 3); | |
209 | + sizer2->Add(tbuttons[i], 0, wxALL | wxEXPAND, FromFrameDIP(frame, 3)); | |
209 | 210 | } |
210 | 211 | tbuttons[0]->SetValue(true); |
211 | 212 | } |
212 | 213 | { // Information text |
213 | - infotext = new wxStaticText(panel1, -1, wxT(""), wxDefaultPosition, wxSize(80, 32), wxST_NO_AUTORESIZE | wxBORDER_SUNKEN); | |
214 | - infotext->SetMinSize(wxSize(80, 32)); | |
214 | + infotext = new wxStaticText(panel1, -1, wxT(""), wxDefaultPosition, FromFrameDIP(frame, wxSize(80, 32)), wxST_NO_AUTORESIZE | wxBORDER_SUNKEN); | |
215 | + infotext->SetMinSize(FromFrameDIP(frame, wxSize(80, 32))); | |
215 | 216 | #if defined(__WXMSW__) |
216 | 217 | infotext->SetFont(*wxSMALL_FONT); |
217 | 218 | #else |
@@ -221,7 +222,7 @@ MoleculeView::OnCreate(wxDocument *doc, long WXUNUSED(flags) ) | ||
221 | 222 | sizer2->Add(infotext, 1, wxALL | wxEXPAND, 3); // Can expand horizontally |
222 | 223 | } |
223 | 224 | { // Custom progress indicator |
224 | - progress = new MyProgressIndicator(panel1, myID_StopProgressButton, wxDefaultPosition, wxSize(12, 24)); | |
225 | + progress = new MyProgressIndicator(panel1, myID_StopProgressButton, wxDefaultPosition, FromFrameDIP(frame, wxSize(12, 24))); | |
225 | 226 | sizer2->Add(progress, 0, wxALL | wxEXPAND, 3); |
226 | 227 | } |
227 | 228 | sizer1->Add(sizer2, 0, wxALL | wxEXPAND, 0); |
@@ -247,7 +248,7 @@ MoleculeView::OnCreate(wxDocument *doc, long WXUNUSED(flags) ) | ||
247 | 248 | { // Vertical sizer containing [Canvas, [button, mySlider]] |
248 | 249 | wxBoxSizer *sizer32 = new wxBoxSizer(wxVERTICAL); |
249 | 250 | { |
250 | - canvas = new MyGLCanvas(this, panel1, wxDefaultPosition, wxSize(100, 100)); | |
251 | + canvas = new MyGLCanvas(this, panel1, wxDefaultPosition, FromFrameDIP(frame, wxSize(100, 100))); | |
251 | 252 | sizer32->Add(canvas, 1, wxALL | wxEXPAND, 0); |
252 | 253 | |
253 | 254 | // Let the MyGLCanvas pass the keyboard event to this |
@@ -258,10 +259,10 @@ MoleculeView::OnCreate(wxDocument *doc, long WXUNUSED(flags) ) | ||
258 | 259 | { |
259 | 260 | #include "../bitmaps/rotate_y.xpm" |
260 | 261 | wxBitmap bmp2(rotate_y_xpm); |
261 | - wxBitmapButton *button2 = new wxBitmapButton(panel1, -1, bmp2, wxDefaultPosition, wxSize(21, 21), wxTOGGLEBUTTON_STYLE); | |
262 | + wxBitmapButton *button2 = new wxBitmapButton(panel1, -1, bmp2, wxDefaultPosition, FromFrameDIP(frame, wxSize(21, 21)), wxTOGGLEBUTTON_STYLE); | |
262 | 263 | sizer321->Add(button2, 0, 0, 0); |
263 | 264 | button2->Disable(); |
264 | - MySlider *slider2 = new MySlider(panel1, myID_RotateYSlider, wxHORIZONTAL, wxDefaultPosition, wxSize(21, 21)); | |
265 | + MySlider *slider2 = new MySlider(panel1, myID_RotateYSlider, wxHORIZONTAL, wxDefaultPosition, FromFrameDIP(frame, wxSize(21, 21))); | |
265 | 266 | sizer321->Add(slider2, 1, wxEXPAND); |
266 | 267 | } |
267 | 268 | sizer32->Add(sizer321, 0, wxEXPAND); |
@@ -274,11 +275,11 @@ MoleculeView::OnCreate(wxDocument *doc, long WXUNUSED(flags) ) | ||
274 | 275 | { // "Rotate bond" button and mySlider |
275 | 276 | #include "../bitmaps/rotate_x.xpm" |
276 | 277 | wxBitmap bmp3(rotate_x_xpm); |
277 | - wxBitmapButton *button3 = new wxBitmapButton(panel1, -1, bmp3, wxDefaultPosition, wxSize(21, 21), wxTOGGLEBUTTON_STYLE); | |
278 | + wxBitmapButton *button3 = new wxBitmapButton(panel1, -1, bmp3, wxDefaultPosition, FromFrameDIP(frame, wxSize(21, 21)), wxTOGGLEBUTTON_STYLE); | |
278 | 279 | button3->Disable(); |
279 | 280 | sizer33->Add(button3, 0, 0, 0); |
280 | 281 | |
281 | - MySlider *slider3 = new MySlider(panel1, myID_RotateXSlider, wxVERTICAL, wxDefaultPosition, wxSize(21, 21)); | |
282 | + MySlider *slider3 = new MySlider(panel1, myID_RotateXSlider, wxVERTICAL, wxDefaultPosition, FromFrameDIP(frame, wxSize(21, 21))); | |
282 | 283 | sizer33->Add(slider3, 1, wxEXPAND); |
283 | 284 | } |
284 | 285 | sizer3->Add(sizer33, 0, wxALL | wxEXPAND, 0); |
@@ -290,27 +291,27 @@ MoleculeView::OnCreate(wxDocument *doc, long WXUNUSED(flags) ) | ||
290 | 291 | { // Horizontal sizer containing frame controls |
291 | 292 | |
292 | 293 | const int height = 18; |
293 | - frameControlPanel = new wxPanel(panel1, myID_FrameControlPanel, wxDefaultPosition, wxSize(200, height)); | |
294 | + frameControlPanel = new wxPanel(panel1, myID_FrameControlPanel, wxDefaultPosition, FromFrameDIP(frame, wxSize(200, height))); | |
294 | 295 | wxBoxSizer *sizer4 = new wxBoxSizer(wxHORIZONTAL); |
295 | 296 | { |
296 | - frameSlider = new wxSlider(frameControlPanel, myID_FrameSlider, 0, 0, 1, wxDefaultPosition, wxSize(40, height - 2)); | |
297 | + frameSlider = new wxSlider(frameControlPanel, myID_FrameSlider, 0, 0, 1, wxDefaultPosition, FromFrameDIP(frame, wxSize(40, height - 2))); | |
297 | 298 | frameSlider->Enable(false); |
298 | 299 | sizer4->Add(frameSlider, 1, wxALL | wxEXPAND, 1); |
299 | 300 | |
300 | 301 | #include "../bitmaps/jump_to_start.xpm" |
301 | 302 | wxBitmap bmp41(jump_to_start_xpm); |
302 | - wxBitmapButton *button41 = new wxBitmapButton(frameControlPanel, myID_JumpToStartButton, bmp41, wxDefaultPosition, wxSize(16, height), wxTOGGLEBUTTON_STYLE); | |
303 | + wxBitmapButton *button41 = new wxBitmapButton(frameControlPanel, myID_JumpToStartButton, bmp41, wxDefaultPosition, FromFrameDIP(frame, wxSize(16, height)), wxTOGGLEBUTTON_STYLE); | |
303 | 304 | sizer4->Add(button41, 0, wxEXPAND); |
304 | 305 | ConnectMouseDownEvents(button41, MoleculeView::OnFrameButtonAction, this); |
305 | 306 | |
306 | 307 | #include "../bitmaps/play_backward.xpm" |
307 | 308 | wxBitmap bmp42(play_backward_xpm); |
308 | - wxBitmapButton *button42 = new wxBitmapButton(frameControlPanel, myID_PlayBackwardButton, bmp42, wxDefaultPosition, wxSize(16, height), wxTOGGLEBUTTON_STYLE); | |
309 | + wxBitmapButton *button42 = new wxBitmapButton(frameControlPanel, myID_PlayBackwardButton, bmp42, wxDefaultPosition, FromFrameDIP(frame, wxSize(16, height)), wxTOGGLEBUTTON_STYLE); | |
309 | 310 | sizer4->Add(button42, 0, wxEXPAND); |
310 | 311 | ConnectMouseDownEvents(button42, MoleculeView::OnFrameButtonAction, this); |
311 | 312 | |
312 | 313 | { |
313 | - frameText = new wxTextCtrl(frameControlPanel, myID_FrameText, wxT(""), wxDefaultPosition, wxSize(40, height)); | |
314 | + frameText = new wxTextCtrl(frameControlPanel, myID_FrameText, wxT(""), wxDefaultPosition, FromFrameDIP(frame, wxSize(40, height))); | |
314 | 315 | if (ctrlFont) { |
315 | 316 | wxTextAttr attr(*wxBLACK, wxNullColour, *ctrlFont); |
316 | 317 | frameText->SetDefaultStyle(attr); |
@@ -321,17 +322,17 @@ MoleculeView::OnCreate(wxDocument *doc, long WXUNUSED(flags) ) | ||
321 | 322 | |
322 | 323 | #include "../bitmaps/play_forward.xpm" |
323 | 324 | wxBitmap bmp43(play_forward_xpm); |
324 | - wxBitmapButton *button43 = new wxBitmapButton(frameControlPanel, myID_PlayForwardButton, bmp43, wxDefaultPosition, wxSize(16, height), wxTOGGLEBUTTON_STYLE); | |
325 | + wxBitmapButton *button43 = new wxBitmapButton(frameControlPanel, myID_PlayForwardButton, bmp43, wxDefaultPosition, FromFrameDIP(frame, wxSize(16, height)), wxTOGGLEBUTTON_STYLE); | |
325 | 326 | sizer4->Add(button43, 0, wxEXPAND); |
326 | 327 | ConnectMouseDownEvents(button43, MoleculeView::OnFrameButtonAction, this); |
327 | 328 | |
328 | 329 | #include "../bitmaps/jump_to_end.xpm" |
329 | 330 | wxBitmap bmp44(jump_to_end_xpm); |
330 | - wxBitmapButton *button44 = new wxBitmapButton(frameControlPanel, myID_JumpToEndButton, bmp44, wxDefaultPosition, wxSize(16, height), wxTOGGLEBUTTON_STYLE); | |
331 | + wxBitmapButton *button44 = new wxBitmapButton(frameControlPanel, myID_JumpToEndButton, bmp44, wxDefaultPosition, FromFrameDIP(frame, wxSize(16, height)), wxTOGGLEBUTTON_STYLE); | |
331 | 332 | sizer4->Add(button44, 0, wxEXPAND); |
332 | 333 | ConnectMouseDownEvents(button44, MoleculeView::OnFrameButtonAction, this); |
333 | 334 | |
334 | - wxPanel *spacer = new wxPanel(frameControlPanel, -1, wxDefaultPosition, wxSize(21, height)); | |
335 | + wxPanel *spacer = new wxPanel(frameControlPanel, -1, wxDefaultPosition, FromFrameDIP(frame, wxSize(21, height))); | |
335 | 336 | sizer4->Add(spacer, 0, wxEXPAND); |
336 | 337 | } |
337 | 338 | frameControlPanel->SetSizer(sizer4); |
@@ -349,7 +350,7 @@ MoleculeView::OnCreate(wxDocument *doc, long WXUNUSED(flags) ) | ||
349 | 350 | frame->SetSizer(mainsizer); |
350 | 351 | |
351 | 352 | mainsizer->Layout(); |
352 | - splitter->SetSashPosition(240, true); | |
353 | + splitter->SetSashPosition(FromFrameDIP(frame, 240), true); | |
353 | 354 | |
354 | 355 | // Initialize table view |
355 | 356 | MainView_createColumnsForTableAtIndex(mview, 0); |
@@ -1457,7 +1458,7 @@ MainViewCallback_addTableColumn(MainView *mview, const char *name, int width, in | ||
1457 | 1458 | return 0; |
1458 | 1459 | idx = listctrl->GetColumnCount(); |
1459 | 1460 | listctrl->InsertColumn(idx, nstr, wxLIST_FORMAT_LEFT); |
1460 | - listctrl->SetColumnWidth(idx, width * 10); | |
1461 | + listctrl->SetColumnWidth(idx, FromFrameDIP(listctrl, width * 10)); | |
1461 | 1462 | return idx; |
1462 | 1463 | } |
1463 | 1464 |
@@ -22,11 +22,11 @@ | ||
22 | 22 | |
23 | 23 | #include "../MolLib/MolLib.h" |
24 | 24 | #include "MyListCtrl.h" |
25 | +#include "MyToggleButton.h" | |
25 | 26 | |
26 | 27 | class MyDocument; |
27 | 28 | class MyGLCanvas; |
28 | 29 | class wxMenu; |
29 | -class wxToggleButton; | |
30 | 30 | class wxStaticText; |
31 | 31 | class wxChoice; |
32 | 32 | class MyProgressIndicator; |
@@ -41,7 +41,7 @@ public: | ||
41 | 41 | MyListCtrl *listctrl; |
42 | 42 | wxMenu *file_history_menu; |
43 | 43 | wxMenu *edit_menu; |
44 | - wxToggleButton *tbuttons[6]; | |
44 | + MyToggleButton *tbuttons[6]; | |
45 | 45 | wxStaticText *infotext; |
46 | 46 | MyProgressIndicator *progress; |
47 | 47 | wxPanel *frameControlPanel; |
@@ -55,7 +55,7 @@ public: | ||
55 | 55 | |
56 | 56 | MyDocument *MolDocument() { return (MyDocument *)m_viewDocument; } |
57 | 57 | MyListCtrl *GetListCtrl() { return listctrl; } |
58 | - wxToggleButton *GetToggleButtonAtIndex(int i) { return (i >= 0 && i < 6 ? tbuttons[i] : NULL); } | |
58 | + MyToggleButton *GetToggleButtonAtIndex(int i) { return (i >= 0 && i < 6 ? tbuttons[i] : NULL); } | |
59 | 59 | |
60 | 60 | bool OnCreate(wxDocument *doc, long flags); |
61 | 61 | void OnDraw(wxDC *dc); |
@@ -353,8 +353,9 @@ bool MyApp::OnInit(void) | ||
353 | 353 | |
354 | 354 | // Create the main frame window |
355 | 355 | frame = new MyFrame((wxDocManager *) m_docManager, (wxFrame *) NULL, |
356 | - _T("Molby"), wxPoint(0, 0), wxSize(800, 600), | |
356 | + _T("Molby"), wxDefaultPosition, wxDefaultSize, | |
357 | 357 | wxDEFAULT_FRAME_STYLE | wxNO_FULL_REPAINT_ON_RESIZE); |
358 | + frame->SetClientSize(FromFrameDIP(frame, wxSize(800, 600))); | |
358 | 359 | |
359 | 360 | // Give it an icon (this is ignored in MDI mode: uses resources) |
360 | 361 | #ifdef __WXMSW__ |
@@ -1824,13 +1825,13 @@ AboutDialog::AboutDialog(): | ||
1824 | 1825 | free(s2); |
1825 | 1826 | free(s3); |
1826 | 1827 | #if defined(__WXMSW__) |
1827 | - wxFont *textFont0 = new wxFont(12, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD); | |
1828 | - wxFont *textFont1 = new wxFont(10, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL); | |
1829 | - wxFont *textFont2 = new wxFont(9, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL); | |
1828 | + wxFont *textFont0 = new wxFont(FromFrameDIP(this, 12), wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD); | |
1829 | + wxFont *textFont1 = new wxFont(FromFrameDIP(this, 10), wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL); | |
1830 | + wxFont *textFont2 = new wxFont(FromFrameDIP(this, 9), wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL); | |
1830 | 1831 | #else |
1831 | - wxFont *textFont0 = new wxFont(14, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD); | |
1832 | - wxFont *textFont1 = new wxFont(12, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL); | |
1833 | - wxFont *textFont2 = new wxFont(11, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL); | |
1832 | + wxFont *textFont0 = new wxFont(FromFrameDIP(this, 14), wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD); | |
1833 | + wxFont *textFont1 = new wxFont(FromFrameDIP(this, 12), wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL); | |
1834 | + wxFont *textFont2 = new wxFont(FromFrameDIP(this, 11), wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL); | |
1834 | 1835 | #endif |
1835 | 1836 | wxBoxSizer *vsizer1 = new wxBoxSizer(wxVERTICAL); |
1836 | 1837 | wxBoxSizer *vsizer2 = new wxBoxSizer(wxVERTICAL); |
@@ -1842,17 +1843,17 @@ AboutDialog::AboutDialog(): | ||
1842 | 1843 | wxStaticText *stext2 = new wxStaticText(this, -1, str2); |
1843 | 1844 | stext2->SetFont(*textFont1); |
1844 | 1845 | wxStaticBitmap *staticBitmap = new wxStaticBitmap(this, -1, *molbyBitmap); |
1845 | - vsizer2->Add(stext1, 0, wxALL | wxEXPAND, 2); | |
1846 | - vsizer2->Add(stext2, 0, wxALL | wxEXPAND, 2); | |
1847 | - hsizer1->AddSpacer(20); | |
1848 | - hsizer1->Add(staticBitmap, 0, 0, 10); | |
1849 | - hsizer1->AddSpacer(20); | |
1850 | - hsizer1->Add(vsizer2, 0, wxALL | wxEXPAND, 5); | |
1846 | + vsizer2->Add(stext1, 0, wxALL | wxEXPAND, FromFrameDIP(this, 2)); | |
1847 | + vsizer2->Add(stext2, 0, wxALL | wxEXPAND, FromFrameDIP(this, 2)); | |
1848 | + hsizer1->AddSpacer(FromFrameDIP(this, 20)); | |
1849 | + hsizer1->Add(staticBitmap, 0, 0, FromFrameDIP(this, 10)); | |
1850 | + hsizer1->AddSpacer(FromFrameDIP(this, 20)); | |
1851 | + hsizer1->Add(vsizer2, 0, wxALL | wxEXPAND, FromFrameDIP(this, 5)); | |
1851 | 1852 | wxStaticText *stext3 = new wxStaticText(this, -1, str3); |
1852 | 1853 | stext3->SetFont(*textFont2); |
1853 | - vsizer1->Add(hsizer1, 0, wxALL | wxEXPAND, 5); | |
1854 | - vsizer1->Add(stext3, 0, wxALL | wxEXPAND, 5); | |
1855 | - vsizer1->Add(this->CreateButtonSizer(wxOK), 0, wxALL | wxEXPAND, 10); | |
1854 | + vsizer1->Add(hsizer1, 0, wxALL | wxEXPAND, FromFrameDIP(this, 5)); | |
1855 | + vsizer1->Add(stext3, 0, wxALL | wxEXPAND, FromFrameDIP(this, 5)); | |
1856 | + vsizer1->Add(this->CreateButtonSizer(wxOK), 0, wxALL | wxEXPAND, FromFrameDIP(this, 10)); | |
1856 | 1857 | vsizer1->Layout(); |
1857 | 1858 | this->SetSizerAndFit(vsizer1); |
1858 | 1859 | this->Centre(); |
@@ -2166,12 +2167,12 @@ MyAppCallback_getTextWithPrompt(const char *prompt, char *buf, int bufsize) | ||
2166 | 2167 | { // Vertical sizer containing [prompt, textbox, buttons] |
2167 | 2168 | wxBoxSizer *sizer1; |
2168 | 2169 | sizer1 = new wxBoxSizer(wxVERTICAL); |
2169 | - stext = new wxStaticText(dialog, -1, pstr, wxDefaultPosition, wxSize(200, 22)); | |
2170 | - sizer1->Add(stext, 0, wxEXPAND | wxALL, 6); | |
2171 | - tctrl = new wxTextCtrl(dialog, -1, defstr, wxDefaultPosition, wxSize(200, 22)); | |
2172 | - sizer1->Add(tctrl, 0, wxEXPAND | wxALL, 6); | |
2170 | + stext = new wxStaticText(dialog, -1, pstr, wxDefaultPosition, FromFrameDIP(dialog, wxSize(200, 22))); | |
2171 | + sizer1->Add(stext, 0, wxEXPAND | wxALL, FromFrameDIP(dialog, 6)); | |
2172 | + tctrl = new wxTextCtrl(dialog, -1, defstr, wxDefaultPosition, FromFrameDIP(dialog, wxSize(200, 22))); | |
2173 | + sizer1->Add(tctrl, 0, wxEXPAND | wxALL, FromFrameDIP(dialog, 6)); | |
2173 | 2174 | wxSizer *bsizer = dialog->CreateButtonSizer(wxOK | wxCANCEL); |
2174 | - sizer1->Add(bsizer, 0, wxEXPAND | wxALL, 6); | |
2175 | + sizer1->Add(bsizer, 0, wxEXPAND | wxALL, FromFrameDIP(dialog, 6)); | |
2175 | 2176 | sizer1->Layout(); |
2176 | 2177 | dialog->SetSizerAndFit(sizer1); |
2177 | 2178 | dialog->Centre(wxBOTH); |
@@ -56,6 +56,17 @@ class MyDocument; | ||
56 | 56 | #define wxTOGGLEBUTTON_STYLE 0 |
57 | 57 | #endif |
58 | 58 | |
59 | +#if wxCHECK_VERSION(3,1,0) | |
60 | +#define FromFrameDIP(frame, x) frame->FromDIP(x) | |
61 | +#define ToFrameDIP(frame, x) frame->ToDIP(x) | |
62 | +#else | |
63 | +#define FromFrameDIP(frame, x) (x) | |
64 | +#define ToFrameDIP(frame, x) (x) | |
65 | +#endif | |
66 | + | |
67 | +#define FromDCDIP FromFrameDIP | |
68 | +#define ToDCDIP ToFrameDIP | |
69 | + | |
59 | 70 | enum { |
60 | 71 | myMenuID_MyFirstMenuItem = 12000, |
61 | 72 | myMenuID_Import = 12001, |
@@ -24,6 +24,12 @@ | ||
24 | 24 | #include "wx/menu.h" |
25 | 25 | #include "wx/sizer.h" |
26 | 26 | |
27 | +#if wxCHECK_VERSION(3,1,0) | |
28 | +#define FromFrameDIP(frame, x) frame->FromDIP(x) | |
29 | +#else | |
30 | +#define FromFrameDIP(frame, x) (x) | |
31 | +#endif | |
32 | + | |
27 | 33 | const wxEventType MyListCtrlEvent = wxNewEventType(); |
28 | 34 | |
29 | 35 | IMPLEMENT_DYNAMIC_CLASS(MyListCtrl, wxWindow) |
@@ -76,12 +82,6 @@ MyListCtrl::Create(wxWindow* parent, wxWindowID wid, const wxPoint& pos, const w | ||
76 | 82 | header = new wxWindow(this, 1001, wxPoint(0, 0), wxSize(size.x, 16)); |
77 | 83 | scroll = new wxScrolledWindow(this, 1002, wxPoint(0, 16), wxSize(size.x, (size.y <= 16 ? -1 : size.y - 16))); |
78 | 84 | |
79 | - // Set sizer | |
80 | - wxBoxSizer *vsizer = new wxBoxSizer(wxVERTICAL); | |
81 | - vsizer->Add(header, wxSizerFlags(0).Expand().Border(wxALL, 0)); | |
82 | - vsizer->Add(scroll, wxSizerFlags(1).Expand().Border(wxALL, 0)); | |
83 | - this->SetSizer(vsizer); | |
84 | - | |
85 | 85 | // Connect events |
86 | 86 | header->Bind(wxEVT_PAINT, &MyListCtrl::OnPaintHeader, this); |
87 | 87 | scroll->Bind(wxEVT_PAINT, &MyListCtrl::OnPaint, this); |
@@ -110,7 +110,14 @@ MyListCtrl::Create(wxWindow* parent, wxWindowID wid, const wxPoint& pos, const w | ||
110 | 110 | rowHeight = h + 2; |
111 | 111 | dc.GetTextExtent(_T("M"), &w, &h, &descent, &leading, &headerFont); |
112 | 112 | headerHeight = h + 2; |
113 | + header->SetSize(wxSize(size.x, headerHeight)); | |
113 | 114 | } |
115 | + | |
116 | + // Set sizer | |
117 | + wxBoxSizer *vsizer = new wxBoxSizer(wxVERTICAL); | |
118 | + vsizer->Add(header, wxSizerFlags(0).Expand().Border(wxALL, 0)); | |
119 | + vsizer->Add(scroll, wxSizerFlags(1).Expand().Border(wxALL, 0)); | |
120 | + this->SetSizer(vsizer); | |
114 | 121 | |
115 | 122 | selectionChangeNotificationRequired = false; |
116 | 123 | selectionChangeNotificationEnabled = true; |
@@ -179,7 +186,7 @@ MyListCtrl::RefreshTable(bool refreshWindow) | ||
179 | 186 | } |
180 | 187 | // rowHeight = dataSource->GetRowHeight(this); |
181 | 188 | // "+4" is for drawing marker during cell dragging |
182 | - pageHeight = rowHeight * nrows + 4; | |
189 | + pageHeight = rowHeight * nrows + FromFrameDIP(this, 4); | |
183 | 190 | // Set the subwindow infos |
184 | 191 | sz.y = headerHeight; |
185 | 192 | header->SetMinSize(sz); |
@@ -237,6 +244,7 @@ MyListCtrl::OnPaint(wxPaintEvent &event) | ||
237 | 244 | wxTextAttr attr; |
238 | 245 | wxString str; |
239 | 246 | int x, y; |
247 | + int mg = FromFrameDIP(this, 2); | |
240 | 248 | row = floor(oy / rowHeight); |
241 | 249 | for (j = row; j < nrows; j++) { |
242 | 250 | float fg0[4], bg0[4]; |
@@ -321,8 +329,8 @@ MyListCtrl::OnPaint(wxPaintEvent &event) | ||
321 | 329 | if (i == ncols - 1) { |
322 | 330 | dc.DrawLine(x + colWidths[i], y, x + colWidths[i], y + rowHeight - 1); |
323 | 331 | } |
324 | - dc.SetClippingRegion(x + 2, y, colWidths[i] - 4, rowHeight - 1); | |
325 | - dc.DrawText(str, x + 2, y); | |
332 | + dc.SetClippingRegion(x + mg, y, colWidths[i] - mg * 2, rowHeight - 1); | |
333 | + dc.DrawText(str, x + mg, y); | |
326 | 334 | dc.DestroyClippingRegion(); |
327 | 335 | x += colWidths[i]; |
328 | 336 | if (x > ox + sz.x) |
@@ -351,6 +359,7 @@ MyListCtrl::OnPaintHeader(wxPaintEvent &event) | ||
351 | 359 | int x, x1; |
352 | 360 | int i; |
353 | 361 | wxTextAttr attr; |
362 | + int mg = FromFrameDIP(this, 2); | |
354 | 363 | scroll->CalcUnscrolledPosition(0, 0, &ox, &oy); |
355 | 364 | x = -ox; |
356 | 365 | for (i = 0; i < ncols; i++) { |
@@ -358,8 +367,8 @@ MyListCtrl::OnPaintHeader(wxPaintEvent &event) | ||
358 | 367 | if (x1 > 0) { |
359 | 368 | wxString str = colNames[i]; |
360 | 369 | dc.DrawLine(x + colWidths[i], 0, x + colWidths[i], sz.y - 1); |
361 | - dc.SetClippingRegion(x + 2, 0, colWidths[i] - 4, sz.y); | |
362 | - dc.DrawText(str, x + 2, 0); | |
370 | + dc.SetClippingRegion(x + mg, 0, colWidths[i] - mg * 2, sz.y); | |
371 | + dc.DrawText(str, x + mg, 0); | |
363 | 372 | dc.DestroyClippingRegion(); |
364 | 373 | } |
365 | 374 | x = x1; |
@@ -0,0 +1,78 @@ | ||
1 | +/* | |
2 | + * MyToggleButton | |
3 | + * Molby | |
4 | + * | |
5 | + * Created by Toshi Nagata on 2022/09/17. | |
6 | + * Copyright 2022 Toshi Nagata. All rights reserved. | |
7 | + * | |
8 | + This program is free software; you can redistribute it and/or modify | |
9 | + it under the terms of the GNU General Public License as published by | |
10 | + the Free Software Foundation version 2 of the License. | |
11 | + | |
12 | + This program is distributed in the hope that it will be useful, | |
13 | + but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | + GNU General Public License for more details. | |
16 | + */ | |
17 | + | |
18 | +#include "MyToggleButton.h" | |
19 | +#include "wx/dcclient.h" | |
20 | + | |
21 | +IMPLEMENT_DYNAMIC_CLASS(MyToggleButton, wxToggleButton) | |
22 | + | |
23 | +BEGIN_EVENT_TABLE(MyToggleButton, wxToggleButton) | |
24 | +EVT_PAINT(MyToggleButton::OnPaint) | |
25 | +EVT_LEFT_DOWN(MyToggleButton::OnLeftDown) | |
26 | +EVT_LEFT_UP(MyToggleButton::OnLeftUp) | |
27 | +END_EVENT_TABLE() | |
28 | + | |
29 | +void | |
30 | +MyToggleButton::OnPaint(wxPaintEvent &event) | |
31 | +{ | |
32 | + wxPaintDC dc(this); | |
33 | + wxSize size = GetSize(); | |
34 | + dc.SetPen(*wxGREY_PEN); | |
35 | + const wxBrush *brush; | |
36 | + if (IsPressed()) | |
37 | + brush = wxTheBrushList->FindOrCreateBrush(wxColour(128, 128, 128)); | |
38 | + else if (GetValue()) | |
39 | + brush = wxTheBrushList->FindOrCreateBrush(wxColour(180, 180, 180)); | |
40 | + else | |
41 | + brush = wxTheBrushList->FindOrCreateBrush(wxColour(240, 240, 240)); | |
42 | + dc.SetBrush(*brush); | |
43 | + dc.DrawRectangle(0, 0, size.x, size.y); | |
44 | + wxString label = GetLabel(); | |
45 | + int w, h, descent; | |
46 | + int x, y; | |
47 | + dc.GetTextExtent(label, &w, &h, &descent); | |
48 | + x = (size.x - w) / 2; | |
49 | + y = (size.y - h) / 2; | |
50 | + dc.SetPen(*wxBLACK_PEN); | |
51 | + dc.DrawText(label, x, y); | |
52 | +} | |
53 | + | |
54 | +void | |
55 | +MyToggleButton::OnLeftDown(wxMouseEvent &event) | |
56 | +{ | |
57 | + CaptureMouse(); | |
58 | + SetPressed(true); | |
59 | + Refresh(); | |
60 | +} | |
61 | + | |
62 | +void | |
63 | +MyToggleButton::OnLeftUp(wxMouseEvent &event) | |
64 | +{ | |
65 | + ReleaseMouse(); | |
66 | + SetPressed(false); | |
67 | + int x = event.GetX(); | |
68 | + int y = event.GetY(); | |
69 | + wxSize sz = GetSize(); | |
70 | + if (x > 0 && x < sz.x && y > 0 && y < sz.y) { | |
71 | + SetValue(!GetValue()); | |
72 | + wxCommandEvent cmdevt(wxEVT_TOGGLEBUTTON, GetId()); | |
73 | + cmdevt.SetInt(GetValue()); | |
74 | + cmdevt.SetEventObject(this); | |
75 | + ProcessCommand(cmdevt); | |
76 | + Refresh(); | |
77 | + } | |
78 | +} |
@@ -0,0 +1,50 @@ | ||
1 | +/* | |
2 | + * MyToggleButton.h | |
3 | + * Molby | |
4 | + * | |
5 | + * Created by Toshi Nagata on 2022/09/17. | |
6 | + * Copyright 2022 Toshi Nagata. All rights reserved. | |
7 | + * | |
8 | + This program is free software; you can redistribute it and/or modify | |
9 | + it under the terms of the GNU General Public License as published by | |
10 | + the Free Software Foundation version 2 of the License. | |
11 | + | |
12 | + This program is distributed in the hope that it will be useful, | |
13 | + but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | + GNU General Public License for more details. | |
16 | + */ | |
17 | + | |
18 | +#ifndef __MyToggleButton_h__ | |
19 | +#define __MyToggleButton_h__ | |
20 | + | |
21 | +#include "wx/tglbtn.h" | |
22 | + | |
23 | +class MyToggleButton: public wxToggleButton | |
24 | +{ | |
25 | +public: | |
26 | + MyToggleButton() {} | |
27 | + 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) | |
28 | + : wxToggleButton(parent, id, label, pos, size, style, val, name) { | |
29 | + m_isPressed = m_value = false; | |
30 | + } | |
31 | + | |
32 | + void OnPaint(wxPaintEvent &event); | |
33 | + void OnLeftDown(wxMouseEvent &event); | |
34 | + void OnLeftUp(wxMouseEvent &event); | |
35 | + void SetValue(bool val) { m_value = val; Refresh(); } | |
36 | + bool GetValue() { return m_value; } | |
37 | + void SetPressed(bool flag) { m_isPressed = flag; Refresh(); } | |
38 | + bool IsPressed() { return m_isPressed; } | |
39 | + | |
40 | +private: | |
41 | + bool m_isPressed; | |
42 | + bool m_value; | |
43 | + bool m_isEnabled; | |
44 | + DECLARE_DYNAMIC_CLASS(MyToggleButton) | |
45 | + DECLARE_EVENT_TABLE() | |
46 | +}; | |
47 | + | |
48 | + | |
49 | +#endif /* __MyToggleButton_h__ */ | |
50 | + |
@@ -83,7 +83,7 @@ RubyDialogFrame::RubyDialogFrame(wxWindow* parent, wxWindowID wid, const wxStrin | ||
83 | 83 | buttonSizer = NULL; // Will be created later |
84 | 84 | myTimer = NULL; // Will be created when necessary |
85 | 85 | boxSizer = new wxBoxSizer(wxVERTICAL); |
86 | - boxSizer->Add(contentSizer, 1, wxALL | wxEXPAND, 14); | |
86 | + boxSizer->Add(contentSizer, 1, wxALL | wxEXPAND, FromFrameDIP(this, 14)); | |
87 | 87 | this->SetSizer(boxSizer); |
88 | 88 | boxSizer->Layout(); |
89 | 89 | } |
@@ -196,7 +196,7 @@ RubyDialogFrame::CreateStandardButtons(const char *oktitle, const char *cancelti | ||
196 | 196 | if (sizer == NULL) |
197 | 197 | return; /* Cannot create */ |
198 | 198 | if (buttonSizer == NULL) { |
199 | - boxSizer->Add(sizer, 0, wxBOTTOM | wxLEFT | wxRIGHT | wxEXPAND, 14); | |
199 | + boxSizer->Add(sizer, 0, wxBOTTOM | wxLEFT | wxRIGHT | wxEXPAND, FromFrameDIP(this, 14)); | |
200 | 200 | buttonSizer = sizer; |
201 | 201 | } else { |
202 | 202 | boxSizer->Replace(buttonSizer, sizer); |
@@ -872,7 +872,8 @@ wxRectFromRDRect(RDRect rframe) | ||
872 | 872 | RDSize |
873 | 873 | RubyDialogCallback_windowMinSize(RubyDialog *dref) |
874 | 874 | { |
875 | - wxSize minSize = ((RubyDialogFrame *)dref)->GetMinSize(); | |
875 | + RubyDialogFrame *dframe = (RubyDialogFrame *)dref; | |
876 | + wxSize minSize = ToFrameDIP(dframe, dframe->GetMinSize()); | |
876 | 877 | RDSize rminSize; |
877 | 878 | rminSize.width = minSize.GetWidth(); |
878 | 879 | rminSize.height = minSize.GetHeight(); |
@@ -882,16 +883,18 @@ RubyDialogCallback_windowMinSize(RubyDialog *dref) | ||
882 | 883 | void |
883 | 884 | RubyDialogCallback_setWindowMinSize(RubyDialog *dref, RDSize size) |
884 | 885 | { |
886 | + RubyDialogFrame *dframe = (RubyDialogFrame *)dref; | |
885 | 887 | wxSize minSize; |
886 | 888 | minSize.x = (int)size.width; |
887 | 889 | minSize.y = (int)size.height; |
888 | - ((RubyDialogFrame *)dref)->SetMinSize(minSize); | |
890 | + dframe->SetMinSize(FromFrameDIP(dframe, minSize)); | |
889 | 891 | } |
890 | 892 | |
891 | 893 | RDSize |
892 | 894 | RubyDialogCallback_windowSize(RubyDialog *dref) |
893 | 895 | { |
894 | - wxSize minSize = ((RubyDialogFrame *)dref)->GetSize(); | |
896 | + RubyDialogFrame *dframe = (RubyDialogFrame *)dref; | |
897 | + wxSize minSize = ToFrameDIP(dframe, dframe->GetSize()); | |
895 | 898 | RDSize rminSize; |
896 | 899 | rminSize.width = minSize.GetWidth(); |
897 | 900 | rminSize.height = minSize.GetHeight(); |
@@ -900,9 +903,10 @@ RubyDialogCallback_windowSize(RubyDialog *dref) | ||
900 | 903 | void |
901 | 904 | RubyDialogCallback_setWindowSize(RubyDialog *dref, RDSize size) |
902 | 905 | { |
906 | + RubyDialogFrame *dframe = (RubyDialogFrame *)dref; | |
903 | 907 | wxSize wsize((int)size.width, (int)size.height); |
904 | - ((RubyDialogFrame *)dref)->SetSize(wsize); | |
905 | - ((RubyDialogFrame *)dref)->CentreOnScreen(); | |
908 | + dframe->SetSize(FromFrameDIP(dframe, wsize)); | |
909 | + dframe->CentreOnScreen(); | |
906 | 910 | } |
907 | 911 | |
908 | 912 | void |
@@ -969,10 +973,10 @@ RubyDialogCallback_createItem(RubyDialog *dref, const char *type, const char *ti | ||
969 | 973 | rect.SetPosition(wxDefaultPosition); |
970 | 974 | rect.SetSize(wxDefaultSize); |
971 | 975 | } else { |
972 | - rect.SetX(rect.x + offset.x); | |
973 | - rect.SetY(rect.y + offset.y); | |
974 | - rect.SetWidth(rect.width + offset.width); | |
975 | - rect.SetHeight(rect.height + offset.height); | |
976 | + rect.SetX(FromFrameDIP(parent, rect.x + offset.x)); | |
977 | + rect.SetY(FromFrameDIP(parent, rect.y + offset.y)); | |
978 | + rect.SetWidth(FromFrameDIP(parent, rect.width + offset.width)); | |
979 | + rect.SetHeight(FromFrameDIP(parent, rect.height + offset.height)); | |
976 | 980 | } |
977 | 981 | |
978 | 982 | if (strcmp(type, "text") == 0) { |
@@ -1055,14 +1059,14 @@ RubyDialogCallback_createItem(RubyDialog *dref, const char *type, const char *ti | ||
1055 | 1059 | if (title[0] != 0 || strcmp(type, "textfield") == 0) { |
1056 | 1060 | /* Resize the frame rect as necessary */ |
1057 | 1061 | RDSize minSize = RubyDialogCallback_sizeOfString((RDItem *)control, title); |
1058 | - wxSize size = control->GetSize(); | |
1062 | + wxSize size = ToFrameDIP(parent, control->GetSize()); | |
1059 | 1063 | if (size.GetHeight() < minSize.height) |
1060 | 1064 | size.SetHeight(minSize.height); |
1061 | 1065 | if (size.GetWidth() < minSize.width) |
1062 | 1066 | size.SetWidth(minSize.width); |
1063 | 1067 | size.SetWidth(size.GetWidth() + offset.width); |
1064 | 1068 | size.SetHeight(size.GetHeight() + offset.height); |
1065 | - control->SetSize(size); | |
1069 | + control->SetSize(FromFrameDIP(parent, size)); | |
1066 | 1070 | } |
1067 | 1071 | |
1068 | 1072 | if (wxDynamicCast(control, wxTextCtrl) != NULL) { |
@@ -1094,10 +1098,11 @@ RubyDialogCallback_indexOfItem(RubyDialog *dref, RDItem *item) | ||
1094 | 1098 | void |
1095 | 1099 | RubyDialogCallback_moveItemUnderView(RDItem *item, RDItem *superView, RDPoint origin) |
1096 | 1100 | { |
1101 | + wxWindow *sv = (wxWindow *)superView; | |
1097 | 1102 | if (item == NULL || superView == NULL || item == superView) |
1098 | 1103 | return; |
1099 | - if (((wxWindow *)item)->Reparent((wxWindow *)superView)) { | |
1100 | - ((wxWindow *)item)->Move(origin.x, origin.y); | |
1104 | + if (((wxWindow *)item)->Reparent(sv)) { | |
1105 | + ((wxWindow *)item)->Move(FromFrameDIP(sv, origin.x), FromFrameDIP(sv, origin.y)); | |
1101 | 1106 | } |
1102 | 1107 | } |
1103 | 1108 |
@@ -1110,29 +1115,39 @@ RubyDialogCallback_superview(RDItem *item) | ||
1110 | 1115 | RDRect |
1111 | 1116 | RubyDialogCallback_frameOfItem(RDItem *item) |
1112 | 1117 | { |
1113 | - wxRect rect = ((wxWindow *)item)->GetRect(); | |
1118 | + wxWindow *wp = (wxWindow *)item; | |
1119 | + wxRect rect = wp->GetRect(); | |
1114 | 1120 | if (gRubyDialogIsFlipped) { |
1115 | - wxWindow *parent = ((wxWindow *)item)->GetParent(); | |
1121 | + wxWindow *parent = wp->GetParent(); | |
1116 | 1122 | if (parent != NULL) { |
1117 | 1123 | wxRect superRect = parent->GetRect(); |
1118 | 1124 | rect.SetY(superRect.GetHeight() - rect.GetHeight() - rect.GetY()); |
1119 | 1125 | } |
1120 | 1126 | } |
1127 | + rect.x = ToFrameDIP(wp, rect.x); | |
1128 | + rect.y = ToFrameDIP(wp, rect.y); | |
1129 | + rect.width = ToFrameDIP(wp, rect.width); | |
1130 | + rect.height = ToFrameDIP(wp, rect.height); | |
1121 | 1131 | return RDRectFromwxRect(rect); |
1122 | 1132 | } |
1123 | 1133 | |
1124 | 1134 | void |
1125 | 1135 | RubyDialogCallback_setFrameOfItem(RDItem *item, RDRect rect) |
1126 | 1136 | { |
1137 | + wxWindow *wp = (wxWindow *)item; | |
1127 | 1138 | wxRect wrect = wxRectFromRDRect(rect); |
1128 | 1139 | if (gRubyDialogIsFlipped) { |
1129 | - wxWindow *parent = ((wxWindow *)item)->GetParent(); | |
1140 | + wxWindow *parent = wp->GetParent(); | |
1130 | 1141 | if (parent != NULL) { |
1131 | 1142 | wxRect srect = parent->GetRect(); |
1132 | 1143 | wrect.SetY(srect.GetHeight() - wrect.GetHeight() - wrect.GetY()); |
1133 | 1144 | } |
1134 | 1145 | } |
1135 | - ((wxWindow *)item)->SetSize(wrect); | |
1146 | + wrect.x = FromFrameDIP(wp, wrect.x); | |
1147 | + wrect.y = FromFrameDIP(wp, wrect.y); | |
1148 | + wrect.width = FromFrameDIP(wp, wrect.width); | |
1149 | + wrect.height = FromFrameDIP(wp, wrect.height); | |
1150 | + wp->SetSize(wrect); | |
1136 | 1151 | } |
1137 | 1152 | |
1138 | 1153 | void |
@@ -1303,14 +1318,14 @@ RubyDialogCallback_setFontForItem(RDItem *item, int size, int family, int style, | ||
1303 | 1318 | } |
1304 | 1319 | if (textctrl != NULL) { |
1305 | 1320 | wxTextAttr newAttr; |
1306 | - wxFont newFont(size, family, style, weight); | |
1321 | + wxFont newFont(FromFrameDIP(textctrl, size), family, style, weight); | |
1307 | 1322 | newAttr.SetFont(newFont); |
1308 | 1323 | textctrl->SetDefaultStyle(newAttr); |
1309 | 1324 | #if __WXMAC__ |
1310 | 1325 | textctrl->SetFont(newFont); |
1311 | 1326 | #endif |
1312 | 1327 | } else { |
1313 | - ctrl->SetFont(wxFont(size, family, style, weight)); | |
1328 | + ctrl->SetFont(wxFont(FromFrameDIP(ctrl, size), family, style, weight)); | |
1314 | 1329 | wxString label = ctrl->GetLabel(); |
1315 | 1330 | ctrl->SetLabel(_("")); |
1316 | 1331 | ctrl->SetLabel(label); /* Update the control size */ |
@@ -1326,7 +1341,7 @@ RubyDialogCallback_getFontForItem(RDItem *item, int *size, int *family, int *sty | ||
1326 | 1341 | wxTextAttr attr = ctrl->GetDefaultStyle(); |
1327 | 1342 | wxFont font = attr.GetFont(); |
1328 | 1343 | if (size != NULL) |
1329 | - *size = font.GetPointSize(); | |
1344 | + *size = ToFrameDIP(ctrl, font.GetPointSize()); | |
1330 | 1345 | if (family != NULL) { |
1331 | 1346 | n = font.GetFamily(); |
1332 | 1347 | *family = (n == wxFONTFAMILY_DEFAULT ? 1 : |
@@ -1498,6 +1513,8 @@ RubyDialogCallback_sizeOfString(RDItem *item, const char *s) | ||
1498 | 1513 | break; |
1499 | 1514 | s1 = s2 + 1; |
1500 | 1515 | } |
1516 | + size.width = ToFrameDIP(((wxWindow *)item), size.width); | |
1517 | + size.height = ToFrameDIP(((wxWindow *)item), size.height); | |
1501 | 1518 | return size; |
1502 | 1519 | } |
1503 | 1520 |
@@ -1508,8 +1525,8 @@ RubyDialogCallback_resizeToBest(RDItem *item) | ||
1508 | 1525 | RDSize rsize; |
1509 | 1526 | size = ((wxWindow *)item)->GetBestSize(); |
1510 | 1527 | ((wxWindow *)item)->SetSize(size); |
1511 | - rsize.width = size.GetWidth(); | |
1512 | - rsize.height = size.GetHeight(); | |
1528 | + rsize.width = ToFrameDIP(((wxWindow *)item), size.GetWidth()); | |
1529 | + rsize.height = ToFrameDIP(((wxWindow *)item), size.GetHeight()); | |
1513 | 1530 | return rsize; |
1514 | 1531 | } |
1515 | 1532 |
@@ -1686,7 +1703,7 @@ RubyDialogCallback_drawEllipse(RDDeviceContext *dc, float x, float y, float r1, | ||
1686 | 1703 | wxDC *dcp = (wxDC *)dc; |
1687 | 1704 | if (dcp == NULL) |
1688 | 1705 | return; |
1689 | - dcp->DrawEllipse(x - r1, y - r2, r1 * 2, r2 * 2); | |
1706 | + dcp->DrawEllipse(FromDCDIP(dcp, x - r1), FromDCDIP(dcp, y - r2), FromDCDIP(dcp, r1 * 2), FromDCDIP(dcp, r2 * 2)); | |
1690 | 1707 | } |
1691 | 1708 | |
1692 | 1709 | void |
@@ -1698,8 +1715,8 @@ RubyDialogCallback_drawLine(RDDeviceContext *dc, int ncoords, float *coords) | ||
1698 | 1715 | wxPoint *pts = new wxPoint[ncoords]; |
1699 | 1716 | int i; |
1700 | 1717 | for (i = 0; i < ncoords; i++) { |
1701 | - pts[i].x = (int)coords[i * 2]; | |
1702 | - pts[i].y = (int)coords[i * 2 + 1]; | |
1718 | + pts[i].x = FromDCDIP(dcp, (int)coords[i * 2]); | |
1719 | + pts[i].y = FromDCDIP(dcp, (int)coords[i * 2 + 1]); | |
1703 | 1720 | } |
1704 | 1721 | dcp->DrawLines(ncoords, pts); |
1705 | 1722 | delete [] pts; |
@@ -1712,9 +1729,9 @@ RubyDialogCallback_drawRectangle(RDDeviceContext *dc, float x, float y, float wi | ||
1712 | 1729 | if (dcp == NULL) |
1713 | 1730 | return; |
1714 | 1731 | if (round > 0.0) |
1715 | - dcp->DrawRoundedRectangle((int)x, (int)y, (int)width, (int)height, (int)round); | |
1732 | + dcp->DrawRoundedRectangle(FromDCDIP(dcp, x), FromDCDIP(dcp, y), FromDCDIP(dcp, width), FromDCDIP(dcp, height), FromDCDIP(dcp, round)); | |
1716 | 1733 | else |
1717 | - dcp->DrawRectangle((int)x, (int)y, (int)width, (int)height); | |
1734 | + dcp->DrawRectangle(FromDCDIP(dcp, x), FromDCDIP(dcp, y), FromDCDIP(dcp, width), FromDCDIP(dcp, height)); | |
1718 | 1735 | } |
1719 | 1736 | |
1720 | 1737 | void |
@@ -1724,7 +1741,7 @@ RubyDialogCallback_drawText(RDDeviceContext *dc, const char *s, float x, float y | ||
1724 | 1741 | if (dcp == NULL) |
1725 | 1742 | return; |
1726 | 1743 | wxString str(s, WX_DEFAULT_CONV); |
1727 | - dcp->DrawText(str, (int)x, (int)y); | |
1744 | + dcp->DrawText(str, FromDCDIP(dcp, x), FromDCDIP(dcp, y)); | |
1728 | 1745 | } |
1729 | 1746 | |
1730 | 1747 | void |
@@ -1737,7 +1754,7 @@ RubyDialogCallback_setFont(RDDeviceContext *dc, void **args) | ||
1737 | 1754 | wxFont font = dcp->GetFont(); |
1738 | 1755 | for (i = 0; args[i] != NULL; i += 2) { |
1739 | 1756 | if (strcmp((const char *)args[i], "size") == 0) { |
1740 | - float size = *((float *)(args[i + 1])); | |
1757 | + float size = FromDCDIP(dcp, *((float *)(args[i + 1]))); | |
1741 | 1758 | font.SetPointSize((int)size); |
1742 | 1759 | } else if (strcmp((const char *)args[i], "style") == 0) { |
1743 | 1760 | long style = (intptr_t)(args[i + 1]); |
@@ -1790,7 +1807,7 @@ RubyDialogCallback_setPen(RDDeviceContext *dc, void **args) | ||
1790 | 1807 | wxColour col((int)(fp[0] * 255.0), (int)(fp[1] * 255.0), (int)(fp[2] * 255.0), (int)(fp[3] * 255.0)); |
1791 | 1808 | pen.SetColour(col); |
1792 | 1809 | } else if (strcmp((const char *)args[i], "width") == 0) { |
1793 | - float width = *((float *)(args[i + 1])); | |
1810 | + float width = FromDCDIP(dcp, *((float *)(args[i + 1]))); | |
1794 | 1811 | pen.SetWidth((int)width); |
1795 | 1812 | } else if (strcmp((const char *)args[i], "style") == 0) { |
1796 | 1813 | long style = (intptr_t)(args[i + 1]); |