Mercurial > dwindows
comparison dw.hpp @ 2923:969cc3b8bec2
C++: Include the old style function support even when lambdas are available.
This allows old style applications to compile unmodified on lambda supported
compilers. Also include the original extremely simple test program in
dwtestoo.cpp so non-lambda compilers will see something besides a build
failure. Add a message to the old sample to upgrade to a lambda supported
compiler to see the full sample application.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Thu, 29 Dec 2022 21:56:58 +0000 |
parents | 0919c2b82109 |
children | 248e32f744f0 |
comparison
equal
deleted
inserted
replaced
2922:0919c2b82109 | 2923:969cc3b8bec2 |
---|---|
133 { | 133 { |
134 private: | 134 private: |
135 bool ClickedConnected; | 135 bool ClickedConnected; |
136 #ifdef DW_LAMBDA | 136 #ifdef DW_LAMBDA |
137 std::function<int()> _ConnectClicked; | 137 std::function<int()> _ConnectClicked; |
138 #else | 138 #endif |
139 int (*_ConnectClicked)(); | 139 int (*_ConnectClickedOld)(Clickable *); |
140 #endif | |
141 static int _OnClicked(HWND window, void *data) { | 140 static int _OnClicked(HWND window, void *data) { |
142 if(reinterpret_cast<Clickable *>(data)->_ConnectClicked) | 141 Clickable *classptr = reinterpret_cast<Clickable *>(data); |
143 return reinterpret_cast<Clickable *>(data)->_ConnectClicked(); | 142 #ifdef DW_LAMBDA |
144 return reinterpret_cast<Clickable *>(data)->OnClicked(); } | 143 if(classptr->_ConnectClicked) |
144 return classptr->_ConnectClicked(); | |
145 #endif | |
146 if(classptr->_ConnectClickedOld) | |
147 return classptr->_ConnectClickedOld(classptr); | |
148 return classptr->OnClicked(); } | |
145 protected: | 149 protected: |
146 void Setup() { | 150 void Setup() { |
151 #ifdef DW_LAMBDA | |
147 _ConnectClicked = 0; | 152 _ConnectClicked = 0; |
153 #endif | |
154 _ConnectClickedOld = 0; | |
148 if(IsOverridden(Clickable::OnClicked, this)) { | 155 if(IsOverridden(Clickable::OnClicked, this)) { |
149 dw_signal_connect(hwnd, DW_SIGNAL_CLICKED, DW_SIGNAL_FUNC(_OnClicked), this); | 156 dw_signal_connect(hwnd, DW_SIGNAL_CLICKED, DW_SIGNAL_FUNC(_OnClicked), this); |
150 ClickedConnected = true; | 157 ClickedConnected = true; |
151 } | 158 } |
152 else { | 159 else { |
161 return FALSE; | 168 return FALSE; |
162 } | 169 } |
163 public: | 170 public: |
164 #ifdef DW_LAMBDA | 171 #ifdef DW_LAMBDA |
165 void ConnectClicked(std::function<int()> userfunc) | 172 void ConnectClicked(std::function<int()> userfunc) |
166 #else | |
167 void ConnectClicked(int (*userfunc)()) | |
168 #endif | |
169 { | 173 { |
170 _ConnectClicked = userfunc; | 174 _ConnectClicked = userfunc; |
175 if(!ClickedConnected) { | |
176 dw_signal_connect(hwnd, DW_SIGNAL_CLICKED, DW_SIGNAL_FUNC(_OnClicked), this); | |
177 ClickedConnected = true; | |
178 } | |
179 } | |
180 #endif | |
181 void ConnectClicked(int (*userfunc)(Clickable *)) | |
182 { | |
183 _ConnectClickedOld = userfunc; | |
171 if(!ClickedConnected) { | 184 if(!ClickedConnected) { |
172 dw_signal_connect(hwnd, DW_SIGNAL_CLICKED, DW_SIGNAL_FUNC(_OnClicked), this); | 185 dw_signal_connect(hwnd, DW_SIGNAL_CLICKED, DW_SIGNAL_FUNC(_OnClicked), this); |
173 ClickedConnected = true; | 186 ClickedConnected = true; |
174 } | 187 } |
175 } | 188 } |
262 private: | 275 private: |
263 bool DeleteConnected, ConfigureConnected; | 276 bool DeleteConnected, ConfigureConnected; |
264 #ifdef DW_LAMBDA | 277 #ifdef DW_LAMBDA |
265 std::function<int()> _ConnectDelete; | 278 std::function<int()> _ConnectDelete; |
266 std::function<int(int, int)> _ConnectConfigure; | 279 std::function<int(int, int)> _ConnectConfigure; |
267 #else | 280 #endif |
268 int (*_ConnectDelete)(); | 281 int (*_ConnectDeleteOld)(Window *); |
269 int (*_ConnectConfigure)(int width, int height); | 282 int (*_ConnectConfigureOld)(Window *, int width, int height); |
270 #endif | |
271 void Setup() { | 283 void Setup() { |
284 #ifdef DW_LAMBDA | |
272 _ConnectDelete = 0; | 285 _ConnectDelete = 0; |
273 _ConnectConfigure = 0; | 286 _ConnectConfigure = 0; |
287 #endif | |
288 _ConnectDeleteOld = 0; | |
289 _ConnectConfigureOld = 0; | |
274 menu = DW_NULL; | 290 menu = DW_NULL; |
275 if(IsOverridden(Window::OnDelete, this)) { | 291 if(IsOverridden(Window::OnDelete, this)) { |
276 dw_signal_connect(hwnd, DW_SIGNAL_DELETE, DW_SIGNAL_FUNC(_OnDelete), this); | 292 dw_signal_connect(hwnd, DW_SIGNAL_DELETE, DW_SIGNAL_FUNC(_OnDelete), this); |
277 DeleteConnected = true; | 293 DeleteConnected = true; |
278 } else { | 294 } else { |
283 ConfigureConnected = true; | 299 ConfigureConnected = true; |
284 } else { | 300 } else { |
285 ConfigureConnected = false; | 301 ConfigureConnected = false; |
286 } | 302 } |
287 } | 303 } |
288 static int _OnDelete(HWND window, void *data) { | 304 static int _OnDelete(HWND window, void *data) { |
289 if(reinterpret_cast<Window *>(data)->_ConnectDelete) | 305 Window *classptr = reinterpret_cast<Window *>(data); |
290 return reinterpret_cast<Window *>(data)->_ConnectDelete(); | 306 #ifdef DW_LAMBDA |
291 return reinterpret_cast<Window *>(data)->OnDelete(); } | 307 if(classptr->_ConnectDelete) |
308 return classptr->_ConnectDelete(); | |
309 #endif | |
310 if(classptr->_ConnectDeleteOld) | |
311 return classptr->_ConnectDeleteOld(classptr); | |
312 return classptr->OnDelete(); } | |
292 static int _OnConfigure(HWND window, int width, int height, void *data) { | 313 static int _OnConfigure(HWND window, int width, int height, void *data) { |
293 if(reinterpret_cast<Window *>(data)->_ConnectConfigure) | 314 Window *classptr = reinterpret_cast<Window *>(data); |
294 return reinterpret_cast<Window *>(data)->_ConnectConfigure(width, height); | 315 #ifdef DW_LAMBDA |
295 return reinterpret_cast<Window *>(data)->OnConfigure(width, height); } | 316 if(classptr->_ConnectConfigure) |
317 return classptr->_ConnectConfigure(width, height); | |
318 #endif | |
319 if(classptr->_ConnectConfigureOld) | |
320 return classptr->_ConnectConfigureOld(classptr, width, height); | |
321 return classptr->OnConfigure(width, height); } | |
296 MenuBar *menu; | 322 MenuBar *menu; |
297 public: | 323 public: |
298 // Constructors | 324 // Constructors |
299 Window(HWND owner, const char *title, unsigned long style) { SetHWND(dw_window_new(owner, title, style)); Setup(); } | 325 Window(HWND owner, const char *title, unsigned long style) { SetHWND(dw_window_new(owner, title, style)); Setup(); } |
300 Window(const char *title, unsigned long style) { SetHWND(dw_window_new(HWND_DESKTOP, title, style)); Setup(); } | 326 Window(const char *title, unsigned long style) { SetHWND(dw_window_new(HWND_DESKTOP, title, style)); Setup(); } |
336 delete menu; | 362 delete menu; |
337 } | 363 } |
338 } | 364 } |
339 #ifdef DW_LAMBDA | 365 #ifdef DW_LAMBDA |
340 void ConnectDelete(std::function<int()> userfunc) | 366 void ConnectDelete(std::function<int()> userfunc) |
341 #else | |
342 void ConnectDelete(int (*userfunc)()) | |
343 #endif | |
344 { | 367 { |
345 _ConnectDelete = userfunc; | 368 _ConnectDelete = userfunc; |
346 if(!DeleteConnected) { | 369 if(!DeleteConnected) { |
347 dw_signal_connect(hwnd, DW_SIGNAL_DELETE, DW_SIGNAL_FUNC(_OnDelete), this); | 370 dw_signal_connect(hwnd, DW_SIGNAL_DELETE, DW_SIGNAL_FUNC(_OnDelete), this); |
348 DeleteConnected = true; | 371 DeleteConnected = true; |
349 } else { | 372 } else { |
350 DeleteConnected = false; | 373 DeleteConnected = false; |
351 } | 374 } |
352 } | 375 } |
376 #endif | |
377 void ConnectDelete(int (*userfunc)(Window *)) | |
378 { | |
379 _ConnectDeleteOld = userfunc; | |
380 if(!DeleteConnected) { | |
381 dw_signal_connect(hwnd, DW_SIGNAL_DELETE, DW_SIGNAL_FUNC(_OnDelete), this); | |
382 DeleteConnected = true; | |
383 } else { | |
384 DeleteConnected = false; | |
385 } | |
386 } | |
353 #ifdef DW_LAMBDA | 387 #ifdef DW_LAMBDA |
354 void ConnectConfigure(std::function<int(int, int)> userfunc) | 388 void ConnectConfigure(std::function<int(int, int)> userfunc) |
355 #else | |
356 void ConnectConfigure(int (*userfunc)(int, int)) | |
357 #endif | |
358 { | 389 { |
359 _ConnectConfigure = userfunc; | 390 _ConnectConfigure = userfunc; |
391 if(!ConfigureConnected) { | |
392 dw_signal_connect(hwnd, DW_SIGNAL_CONFIGURE, DW_SIGNAL_FUNC(_OnConfigure), this); | |
393 ConfigureConnected = true; | |
394 } else { | |
395 ConfigureConnected = false; | |
396 } | |
397 } | |
398 #endif | |
399 void ConnectConfigure(int (*userfunc)(Window *, int, int)) | |
400 { | |
401 _ConnectConfigureOld = userfunc; | |
360 if(!ConfigureConnected) { | 402 if(!ConfigureConnected) { |
361 dw_signal_connect(hwnd, DW_SIGNAL_CONFIGURE, DW_SIGNAL_FUNC(_OnConfigure), this); | 403 dw_signal_connect(hwnd, DW_SIGNAL_CONFIGURE, DW_SIGNAL_FUNC(_OnConfigure), this); |
362 ConfigureConnected = true; | 404 ConfigureConnected = true; |
363 } else { | 405 } else { |
364 ConfigureConnected = false; | 406 ConfigureConnected = false; |
561 std::function<int(int, int)> _ConnectConfigure; | 603 std::function<int(int, int)> _ConnectConfigure; |
562 std::function<int(char c, int, int, char *)> _ConnectKeyPress; | 604 std::function<int(char c, int, int, char *)> _ConnectKeyPress; |
563 std::function<int(int, int, int)> _ConnectButtonPress; | 605 std::function<int(int, int, int)> _ConnectButtonPress; |
564 std::function<int(int, int, int)> _ConnectButtonRelease; | 606 std::function<int(int, int, int)> _ConnectButtonRelease; |
565 std::function<int(int, int, int)> _ConnectMotionNotify; | 607 std::function<int(int, int, int)> _ConnectMotionNotify; |
566 #else | 608 #endif |
567 int (*_ConnectExpose)(DWExpose *); | 609 int (*_ConnectExposeOld)(Render *, DWExpose *); |
568 int (*_ConnectConfigure)(int width, int height); | 610 int (*_ConnectConfigureOld)(Render *, int width, int height); |
569 int (*_ConnectKeyPress)(char c, int vk, int state, char *utf8); | 611 int (*_ConnectKeyPressOld)(Render *, char c, int vk, int state, char *utf8); |
570 int (*_ConnectButtonPress)(int x, int y, int buttonmask); | 612 int (*_ConnectButtonPressOld)(Render *, int x, int y, int buttonmask); |
571 int (*_ConnectButtonRelease)(int x, int y, int buttonmask); | 613 int (*_ConnectButtonReleaseOld)(Render *, int x, int y, int buttonmask); |
572 int (*_ConnectMotionNotify)(int x, int y, int buttonmask); | 614 int (*_ConnectMotionNotifyOld)(Render *, int x, int y, int buttonmask); |
573 #endif | |
574 void Setup() { | 615 void Setup() { |
616 #ifdef DW_LAMBDA | |
575 _ConnectExpose = 0; | 617 _ConnectExpose = 0; |
576 _ConnectConfigure = 0; | 618 _ConnectConfigure = 0; |
577 _ConnectKeyPress = 0; | 619 _ConnectKeyPress = 0; |
578 _ConnectButtonPress = 0; | 620 _ConnectButtonPress = 0; |
579 _ConnectButtonRelease = 0; | 621 _ConnectButtonRelease = 0; |
580 _ConnectMotionNotify = 0; | 622 _ConnectMotionNotify = 0; |
623 #endif | |
624 _ConnectExposeOld = 0; | |
625 _ConnectConfigureOld = 0; | |
626 _ConnectKeyPressOld = 0; | |
627 _ConnectButtonPressOld = 0; | |
628 _ConnectButtonReleaseOld = 0; | |
629 _ConnectMotionNotifyOld = 0; | |
581 if(IsOverridden(Render::OnExpose, this)) { | 630 if(IsOverridden(Render::OnExpose, this)) { |
582 dw_signal_connect(hwnd, DW_SIGNAL_EXPOSE, DW_SIGNAL_FUNC(_OnExpose), this); | 631 dw_signal_connect(hwnd, DW_SIGNAL_EXPOSE, DW_SIGNAL_FUNC(_OnExpose), this); |
583 ExposeConnected = true; | 632 ExposeConnected = true; |
584 } else { | 633 } else { |
585 ExposeConnected = false; | 634 ExposeConnected = false; |
614 } else { | 663 } else { |
615 MotionNotifyConnected = false; | 664 MotionNotifyConnected = false; |
616 } | 665 } |
617 } | 666 } |
618 static int _OnExpose(HWND window, DWExpose *exp, void *data) { | 667 static int _OnExpose(HWND window, DWExpose *exp, void *data) { |
619 if(reinterpret_cast<Render *>(data)->_ConnectExpose) | 668 Render *classptr = reinterpret_cast<Render *>(data); |
620 return reinterpret_cast<Render *>(data)->_ConnectExpose(exp); | 669 #ifdef DW_LAMBDA |
621 return reinterpret_cast<Render *>(data)->OnExpose(exp); } | 670 if(classptr->_ConnectExpose) |
671 return classptr->_ConnectExpose(exp); | |
672 #endif | |
673 if(classptr->_ConnectExposeOld) | |
674 return classptr->_ConnectExposeOld(classptr, exp); | |
675 return classptr->OnExpose(exp); } | |
622 static int _OnConfigure(HWND window, int width, int height, void *data) { | 676 static int _OnConfigure(HWND window, int width, int height, void *data) { |
623 if(reinterpret_cast<Render *>(data)->_ConnectConfigure) | 677 Render *classptr = reinterpret_cast<Render *>(data); |
624 return reinterpret_cast<Render *>(data)->_ConnectConfigure(width, height); | 678 #ifdef DW_LAMBDA |
625 return reinterpret_cast<Render *>(data)->OnConfigure(width, height); } | 679 if(classptr->_ConnectConfigure) |
680 return classptr->_ConnectConfigure(width, height); | |
681 #endif | |
682 if(classptr->_ConnectConfigureOld) | |
683 return classptr->_ConnectConfigureOld(classptr, width, height); | |
684 return classptr->OnConfigure(width, height); } | |
626 static int _OnKeyPress(HWND window, char c, int vk, int state, void *data, char *utf8) { | 685 static int _OnKeyPress(HWND window, char c, int vk, int state, void *data, char *utf8) { |
627 if(reinterpret_cast<Render *>(data)->_ConnectKeyPress) | 686 Render *classptr = reinterpret_cast<Render *>(data); |
628 return reinterpret_cast<Render *>(data)->_ConnectKeyPress(c, vk, state, utf8); | 687 #ifdef DW_LAMBDA |
629 return reinterpret_cast<Render *>(data)->OnKeyPress(c, vk, state, utf8); } | 688 if(classptr->_ConnectKeyPress) |
689 return classptr->_ConnectKeyPress(c, vk, state, utf8); | |
690 #endif | |
691 if(classptr->_ConnectKeyPressOld) | |
692 return classptr->_ConnectKeyPressOld(classptr, c, vk, state, utf8); | |
693 return classptr->OnKeyPress(c, vk, state, utf8); } | |
630 static int _OnButtonPress(HWND window, int x, int y, int buttonmask, void *data) { | 694 static int _OnButtonPress(HWND window, int x, int y, int buttonmask, void *data) { |
631 if(reinterpret_cast<Render *>(data)->_ConnectButtonPress) | 695 Render *classptr = reinterpret_cast<Render *>(data); |
632 return reinterpret_cast<Render *>(data)->_ConnectButtonPress(x, y, buttonmask); | 696 #ifdef DW_LAMBDA |
633 return reinterpret_cast<Render *>(data)->OnButtonPress(x, y, buttonmask); } | 697 if(classptr->_ConnectButtonPress) |
698 return classptr->_ConnectButtonPress(x, y, buttonmask); | |
699 #endif | |
700 if(classptr->_ConnectButtonPressOld) | |
701 return classptr->_ConnectButtonPressOld(classptr, x, y, buttonmask); | |
702 return classptr->OnButtonPress(x, y, buttonmask); } | |
634 static int _OnButtonRelease(HWND window, int x, int y, int buttonmask, void *data) { | 703 static int _OnButtonRelease(HWND window, int x, int y, int buttonmask, void *data) { |
635 if(reinterpret_cast<Render *>(data)->_ConnectButtonRelease) | 704 Render *classptr = reinterpret_cast<Render *>(data); |
636 return reinterpret_cast<Render *>(data)->_ConnectButtonRelease(x, y, buttonmask); | 705 #ifdef DW_LAMBDA |
637 return reinterpret_cast<Render *>(data)->OnButtonRelease(x, y, buttonmask); } | 706 if(classptr->_ConnectButtonRelease) |
707 return classptr->_ConnectButtonRelease(x, y, buttonmask); | |
708 #endif | |
709 if(classptr->_ConnectButtonReleaseOld) | |
710 return classptr->_ConnectButtonReleaseOld(classptr, x, y, buttonmask); | |
711 return classptr->OnButtonRelease(x, y, buttonmask); } | |
638 static int _OnMotionNotify(HWND window, int x, int y, int buttonmask, void *data) { | 712 static int _OnMotionNotify(HWND window, int x, int y, int buttonmask, void *data) { |
639 if(reinterpret_cast<Render *>(data)->_ConnectMotionNotify) | 713 Render *classptr = reinterpret_cast<Render *>(data); |
640 return reinterpret_cast<Render *>(data)->_ConnectMotionNotify(x, y, buttonmask); | 714 #ifdef DW_LAMBDA |
641 return reinterpret_cast<Render *>(data)->OnMotionNotify(x, y, buttonmask); } | 715 if(classptr->_ConnectMotionNotify) |
716 return classptr->_ConnectMotionNotify(x, y, buttonmask); | |
717 #endif | |
718 if(classptr->_ConnectMotionNotifyOld) | |
719 return classptr->_ConnectMotionNotifyOld(classptr, x, y, buttonmask); | |
720 return classptr->OnMotionNotify(x, y, buttonmask); } | |
642 public: | 721 public: |
643 // Constructors | 722 // Constructors |
644 Render(unsigned long id) { SetHWND(dw_render_new(id)); Setup(); } | 723 Render(unsigned long id) { SetHWND(dw_render_new(id)); Setup(); } |
645 Render() { SetHWND(dw_render_new(0)); Setup(); } | 724 Render() { SetHWND(dw_render_new(0)); Setup(); } |
646 | 725 |
664 char *GetFont() { return dw_window_get_font(hwnd); } | 743 char *GetFont() { return dw_window_get_font(hwnd); } |
665 void Redraw() { dw_render_redraw(hwnd); } | 744 void Redraw() { dw_render_redraw(hwnd); } |
666 void Flush() { dw_flush(); } | 745 void Flush() { dw_flush(); } |
667 #ifdef DW_LAMBDA | 746 #ifdef DW_LAMBDA |
668 void ConnectExpose(std::function<int(DWExpose *)> userfunc) | 747 void ConnectExpose(std::function<int(DWExpose *)> userfunc) |
669 #else | |
670 void ConnectExpose(int (*userfunc)(DWExpose *)) | |
671 #endif | |
672 { | 748 { |
673 _ConnectExpose = userfunc; | 749 _ConnectExpose = userfunc; |
674 if(!ExposeConnected) { | 750 if(!ExposeConnected) { |
675 dw_signal_connect(hwnd, DW_SIGNAL_EXPOSE, DW_SIGNAL_FUNC(_OnExpose), this); | 751 dw_signal_connect(hwnd, DW_SIGNAL_EXPOSE, DW_SIGNAL_FUNC(_OnExpose), this); |
676 ExposeConnected = true; | 752 ExposeConnected = true; |
677 } | 753 } |
678 } | 754 } |
755 #endif | |
756 void ConnectExpose(int (*userfunc)(Render *, DWExpose *)) | |
757 { | |
758 _ConnectExposeOld = userfunc; | |
759 if(!ExposeConnected) { | |
760 dw_signal_connect(hwnd, DW_SIGNAL_EXPOSE, DW_SIGNAL_FUNC(_OnExpose), this); | |
761 ExposeConnected = true; | |
762 } | |
763 } | |
679 #ifdef DW_LAMBDA | 764 #ifdef DW_LAMBDA |
680 void ConnectConfigure(std::function<int(int, int)> userfunc) | 765 void ConnectConfigure(std::function<int(int, int)> userfunc) |
681 #else | |
682 void ConnectConfigure(int (*userfunc)(int, int)) | |
683 #endif | |
684 { | 766 { |
685 _ConnectConfigure = userfunc; | 767 _ConnectConfigure = userfunc; |
686 if(!ConfigureConnected) { | 768 if(!ConfigureConnected) { |
687 dw_signal_connect(hwnd, DW_SIGNAL_CONFIGURE, DW_SIGNAL_FUNC(_OnConfigure), this); | 769 dw_signal_connect(hwnd, DW_SIGNAL_CONFIGURE, DW_SIGNAL_FUNC(_OnConfigure), this); |
688 ConfigureConnected = true; | 770 ConfigureConnected = true; |
689 } | 771 } |
690 } | 772 } |
773 #endif | |
774 void ConnectConfigure(int (*userfunc)(Render *, int, int)) | |
775 { | |
776 _ConnectConfigureOld = userfunc; | |
777 if(!ConfigureConnected) { | |
778 dw_signal_connect(hwnd, DW_SIGNAL_CONFIGURE, DW_SIGNAL_FUNC(_OnConfigure), this); | |
779 ConfigureConnected = true; | |
780 } | |
781 } | |
691 #ifdef DW_LAMBDA | 782 #ifdef DW_LAMBDA |
692 void ConnectKeyPress(std::function<int(char, int, int, char *)> userfunc) | 783 void ConnectKeyPress(std::function<int(char, int, int, char *)> userfunc) |
693 #else | |
694 void ConnectKeyPress(int (*userfunc)(char, int, int, char *)) | |
695 #endif | |
696 { | 784 { |
697 _ConnectKeyPress = userfunc; | 785 _ConnectKeyPress = userfunc; |
698 if(!KeyPressConnected) { | 786 if(!KeyPressConnected) { |
699 dw_signal_connect(hwnd, DW_SIGNAL_KEY_PRESS, DW_SIGNAL_FUNC(_OnKeyPress), this); | 787 dw_signal_connect(hwnd, DW_SIGNAL_KEY_PRESS, DW_SIGNAL_FUNC(_OnKeyPress), this); |
700 KeyPressConnected = true; | 788 KeyPressConnected = true; |
701 } | 789 } |
702 } | 790 } |
791 #endif | |
792 void ConnectKeyPress(int (*userfunc)(Render *, char, int, int, char *)) | |
793 { | |
794 _ConnectKeyPressOld = userfunc; | |
795 if(!KeyPressConnected) { | |
796 dw_signal_connect(hwnd, DW_SIGNAL_KEY_PRESS, DW_SIGNAL_FUNC(_OnKeyPress), this); | |
797 KeyPressConnected = true; | |
798 } | |
799 } | |
703 #ifdef DW_LAMBDA | 800 #ifdef DW_LAMBDA |
704 void ConnectButtonPress(std::function<int(int, int, int)> userfunc) | 801 void ConnectButtonPress(std::function<int(int, int, int)> userfunc) |
705 #else | |
706 void ConnectButtonPress(int (*userfunc)(int, int, int)) | |
707 #endif | |
708 { | 802 { |
709 _ConnectButtonPress = userfunc; | 803 _ConnectButtonPress = userfunc; |
710 if(!KeyPressConnected) { | 804 if(!KeyPressConnected) { |
711 dw_signal_connect(hwnd, DW_SIGNAL_BUTTON_PRESS, DW_SIGNAL_FUNC(_OnButtonPress), this); | 805 dw_signal_connect(hwnd, DW_SIGNAL_BUTTON_PRESS, DW_SIGNAL_FUNC(_OnButtonPress), this); |
712 ButtonPressConnected = true; | 806 ButtonPressConnected = true; |
713 } | 807 } |
714 } | 808 } |
809 #endif | |
810 void ConnectButtonPress(int (*userfunc)(Render *, int, int, int)) | |
811 { | |
812 _ConnectButtonPressOld = userfunc; | |
813 if(!KeyPressConnected) { | |
814 dw_signal_connect(hwnd, DW_SIGNAL_BUTTON_PRESS, DW_SIGNAL_FUNC(_OnButtonPress), this); | |
815 ButtonPressConnected = true; | |
816 } | |
817 } | |
715 #ifdef DW_LAMBDA | 818 #ifdef DW_LAMBDA |
716 void ConnectButtonRelease(std::function<int(int, int, int)> userfunc) | 819 void ConnectButtonRelease(std::function<int(int, int, int)> userfunc) |
717 #else | |
718 void ConnectButtonRelease(int (*userfunc)(int, int, int)) | |
719 #endif | |
720 { | 820 { |
721 _ConnectButtonRelease = userfunc; | 821 _ConnectButtonRelease = userfunc; |
722 if(!KeyPressConnected) { | 822 if(!KeyPressConnected) { |
723 dw_signal_connect(hwnd, DW_SIGNAL_BUTTON_RELEASE, DW_SIGNAL_FUNC(_OnButtonRelease), this); | 823 dw_signal_connect(hwnd, DW_SIGNAL_BUTTON_RELEASE, DW_SIGNAL_FUNC(_OnButtonRelease), this); |
724 ButtonReleaseConnected = true; | 824 ButtonReleaseConnected = true; |
725 } | 825 } |
726 } | 826 } |
827 #endif | |
828 void ConnectButtonRelease(int (*userfunc)(Render *, int, int, int)) | |
829 { | |
830 _ConnectButtonReleaseOld = userfunc; | |
831 if(!KeyPressConnected) { | |
832 dw_signal_connect(hwnd, DW_SIGNAL_BUTTON_RELEASE, DW_SIGNAL_FUNC(_OnButtonRelease), this); | |
833 ButtonReleaseConnected = true; | |
834 } | |
835 } | |
727 #ifdef DW_LAMBDA | 836 #ifdef DW_LAMBDA |
728 void ConnectMotionNotify(std::function<int(int, int, int)> userfunc) | 837 void ConnectMotionNotify(std::function<int(int, int, int)> userfunc) |
729 #else | |
730 void ConnectMotionNotify(int (*userfunc)(int, int, int)) | |
731 #endif | |
732 { | 838 { |
733 _ConnectMotionNotify = userfunc; | 839 _ConnectMotionNotify = userfunc; |
840 if(!MotionNotifyConnected) { | |
841 dw_signal_connect(hwnd, DW_SIGNAL_MOTION_NOTIFY, DW_SIGNAL_FUNC(_OnMotionNotify), this); | |
842 MotionNotifyConnected = true; | |
843 } | |
844 } | |
845 #endif | |
846 void ConnectMotionNotify(int (*userfunc)(Render *, int, int, int)) | |
847 { | |
848 _ConnectMotionNotifyOld = userfunc; | |
734 if(!MotionNotifyConnected) { | 849 if(!MotionNotifyConnected) { |
735 dw_signal_connect(hwnd, DW_SIGNAL_MOTION_NOTIFY, DW_SIGNAL_FUNC(_OnMotionNotify), this); | 850 dw_signal_connect(hwnd, DW_SIGNAL_MOTION_NOTIFY, DW_SIGNAL_FUNC(_OnMotionNotify), this); |
736 MotionNotifyConnected = true; | 851 MotionNotifyConnected = true; |
737 } | 852 } |
738 } | 853 } |
852 private: | 967 private: |
853 bool ChangedConnected, ResultConnected; | 968 bool ChangedConnected, ResultConnected; |
854 #ifdef DW_LAMBDA | 969 #ifdef DW_LAMBDA |
855 std::function<int(int, char *)> _ConnectChanged; | 970 std::function<int(int, char *)> _ConnectChanged; |
856 std::function<int(int, char *, void *)> _ConnectResult; | 971 std::function<int(int, char *, void *)> _ConnectResult; |
857 #else | 972 #endif |
858 int (*_ConnectChanged)(int status, char *url); | 973 int (*_ConnectChangedOld)(HTML *, int status, char *url); |
859 int (*_ConnectResult)(int status, char *result, void *scriptdata); | 974 int (*_ConnectResultOld)(HTML *, int status, char *result, void *scriptdata); |
860 #endif | |
861 void Setup() { | 975 void Setup() { |
976 #ifdef DW_LAMBDA | |
862 _ConnectChanged = 0; | 977 _ConnectChanged = 0; |
863 _ConnectResult = 0; | 978 _ConnectResult = 0; |
979 #endif | |
980 _ConnectChangedOld = 0; | |
981 _ConnectResultOld = 0; | |
864 if(IsOverridden(HTML::OnChanged, this)) { | 982 if(IsOverridden(HTML::OnChanged, this)) { |
865 dw_signal_connect(hwnd, DW_SIGNAL_HTML_CHANGED, DW_SIGNAL_FUNC(_OnChanged), this); | 983 dw_signal_connect(hwnd, DW_SIGNAL_HTML_CHANGED, DW_SIGNAL_FUNC(_OnChanged), this); |
866 ChangedConnected = true; | 984 ChangedConnected = true; |
867 } else { | 985 } else { |
868 ChangedConnected = false; | 986 ChangedConnected = false; |
873 } else { | 991 } else { |
874 ResultConnected = false; | 992 ResultConnected = false; |
875 } | 993 } |
876 } | 994 } |
877 static int _OnChanged(HWND window, int status, char *url, void *data) { | 995 static int _OnChanged(HWND window, int status, char *url, void *data) { |
878 if(reinterpret_cast<HTML *>(data)->_ConnectChanged) | 996 HTML *classptr = reinterpret_cast<HTML *>(data); |
879 return reinterpret_cast<HTML *>(data)->_ConnectChanged(status, url); | 997 #ifdef DW_LAMBDA |
880 return reinterpret_cast<HTML *>(data)->OnChanged(status, url); } | 998 if(classptr->_ConnectChanged) |
999 return classptr->_ConnectChanged(status, url); | |
1000 #endif | |
1001 if(classptr->_ConnectChangedOld) | |
1002 return classptr->_ConnectChangedOld(classptr, status, url); | |
1003 return classptr->OnChanged(status, url); } | |
881 static int _OnResult(HWND window, int status, char *result, void *scriptdata, void *data) { | 1004 static int _OnResult(HWND window, int status, char *result, void *scriptdata, void *data) { |
882 if(reinterpret_cast<HTML *>(data)->_ConnectResult) | 1005 HTML *classptr = reinterpret_cast<HTML *>(data); |
883 return reinterpret_cast<HTML *>(data)->_ConnectResult(status, result, scriptdata); | 1006 #ifdef DW_LAMBDA |
884 return reinterpret_cast<HTML *>(data)->OnResult(status, result, scriptdata); } | 1007 if(classptr->_ConnectResult) |
1008 return classptr->_ConnectResult(status, result, scriptdata); | |
1009 #endif | |
1010 if(classptr->_ConnectResultOld) | |
1011 return classptr->_ConnectResultOld(classptr, status, result, scriptdata); | |
1012 return classptr->OnResult(status, result, scriptdata); } | |
885 public: | 1013 public: |
886 // Constructors | 1014 // Constructors |
887 HTML(unsigned long id) { SetHWND(dw_html_new(id)); Setup(); } | 1015 HTML(unsigned long id) { SetHWND(dw_html_new(id)); Setup(); } |
888 HTML() { SetHWND(dw_html_new(0)); Setup(); } | 1016 HTML() { SetHWND(dw_html_new(0)); Setup(); } |
889 | 1017 |
892 int JavascriptRun(const char *script, void *scriptdata) { return dw_html_javascript_run(hwnd, script, scriptdata); } | 1020 int JavascriptRun(const char *script, void *scriptdata) { return dw_html_javascript_run(hwnd, script, scriptdata); } |
893 int Raw(const char *buffer) { return dw_html_raw(hwnd, buffer); } | 1021 int Raw(const char *buffer) { return dw_html_raw(hwnd, buffer); } |
894 int URL(const char *url) { return dw_html_url(hwnd, url); } | 1022 int URL(const char *url) { return dw_html_url(hwnd, url); } |
895 #ifdef DW_LAMBDA | 1023 #ifdef DW_LAMBDA |
896 void ConnectChanged(std::function<int(int, char *)> userfunc) | 1024 void ConnectChanged(std::function<int(int, char *)> userfunc) |
897 #else | |
898 void ConnectChanged(int (*userfunc)(int, char *)) | |
899 #endif | |
900 { | 1025 { |
901 _ConnectChanged = userfunc; | 1026 _ConnectChanged = userfunc; |
902 if(!ChangedConnected) { | 1027 if(!ChangedConnected) { |
903 dw_signal_connect(hwnd, DW_SIGNAL_HTML_CHANGED, DW_SIGNAL_FUNC(_OnChanged), this); | 1028 dw_signal_connect(hwnd, DW_SIGNAL_HTML_CHANGED, DW_SIGNAL_FUNC(_OnChanged), this); |
904 ChangedConnected = true; | 1029 ChangedConnected = true; |
905 } | 1030 } |
906 } | 1031 } |
1032 #endif | |
1033 void ConnectChanged(int (*userfunc)(HTML *, int, char *)) | |
1034 { | |
1035 _ConnectChangedOld = userfunc; | |
1036 if(!ChangedConnected) { | |
1037 dw_signal_connect(hwnd, DW_SIGNAL_HTML_CHANGED, DW_SIGNAL_FUNC(_OnChanged), this); | |
1038 ChangedConnected = true; | |
1039 } | |
1040 } | |
907 #ifdef DW_LAMBDA | 1041 #ifdef DW_LAMBDA |
908 void ConnectResult(std::function<int(int, char *, void *)> userfunc) | 1042 void ConnectResult(std::function<int(int, char *, void *)> userfunc) |
909 #else | |
910 void ConnectResult(int (*userfunc)(int, char *, void *)) | |
911 #endif | |
912 { | 1043 { |
913 _ConnectResult = userfunc; | 1044 _ConnectResult = userfunc; |
1045 if(!ResultConnected) { | |
1046 dw_signal_connect(hwnd, DW_SIGNAL_HTML_CHANGED, DW_SIGNAL_FUNC(_OnResult), this); | |
1047 ResultConnected = true; | |
1048 } | |
1049 } | |
1050 #endif | |
1051 void ConnectResult(int (*userfunc)(HTML *, int, char *, void *)) | |
1052 { | |
1053 _ConnectResultOld = userfunc; | |
914 if(!ResultConnected) { | 1054 if(!ResultConnected) { |
915 dw_signal_connect(hwnd, DW_SIGNAL_HTML_CHANGED, DW_SIGNAL_FUNC(_OnResult), this); | 1055 dw_signal_connect(hwnd, DW_SIGNAL_HTML_CHANGED, DW_SIGNAL_FUNC(_OnResult), this); |
916 ResultConnected = true; | 1056 ResultConnected = true; |
917 } | 1057 } |
918 } | 1058 } |
965 { | 1105 { |
966 private: | 1106 private: |
967 bool ListSelectConnected; | 1107 bool ListSelectConnected; |
968 #ifdef DW_LAMBDA | 1108 #ifdef DW_LAMBDA |
969 std::function<int(int)> _ConnectListSelect; | 1109 std::function<int(int)> _ConnectListSelect; |
970 #else | 1110 #endif |
971 int (*_ConnectListSelect)(int index); | 1111 int (*_ConnectListSelectOld)(ListBoxes *, int index); |
972 #endif | |
973 void Setup() { | 1112 void Setup() { |
1113 #ifdef DW_LAMBDA | |
974 _ConnectListSelect = 0; | 1114 _ConnectListSelect = 0; |
1115 #endif | |
1116 _ConnectListSelectOld = 0; | |
975 if(IsOverridden(ListBoxes::OnListSelect, this)) { | 1117 if(IsOverridden(ListBoxes::OnListSelect, this)) { |
976 dw_signal_connect(hwnd, DW_SIGNAL_LIST_SELECT, DW_SIGNAL_FUNC(_OnListSelect), this); | 1118 dw_signal_connect(hwnd, DW_SIGNAL_LIST_SELECT, DW_SIGNAL_FUNC(_OnListSelect), this); |
977 ListSelectConnected = true; | 1119 ListSelectConnected = true; |
978 } | 1120 } |
979 } | 1121 } |
980 static int _OnListSelect(HWND window, int index, void *data) { | 1122 static int _OnListSelect(HWND window, int index, void *data) { |
981 if(reinterpret_cast<ListBoxes *>(data)->_ConnectListSelect) | 1123 ListBoxes *classptr = reinterpret_cast<ListBoxes *>(data); |
982 return reinterpret_cast<ListBoxes *>(data)->_ConnectListSelect(index); | 1124 #ifdef DW_LAMBDA |
983 return reinterpret_cast<ListBoxes *>(data)->OnListSelect(index); | 1125 if(classptr->_ConnectListSelect) |
1126 return classptr->_ConnectListSelect(index); | |
1127 #endif | |
1128 if(classptr->_ConnectListSelectOld) | |
1129 return classptr->_ConnectListSelectOld(classptr, index); | |
1130 return classptr->OnListSelect(index); | |
984 } | 1131 } |
985 public: | 1132 public: |
986 // User functions | 1133 // User functions |
987 void Append(const char *text) { dw_listbox_append(hwnd, text); } | 1134 void Append(const char *text) { dw_listbox_append(hwnd, text); } |
988 void Clear() { dw_listbox_clear(hwnd); } | 1135 void Clear() { dw_listbox_clear(hwnd); } |
996 int Selected() { return dw_listbox_selected(hwnd); } | 1143 int Selected() { return dw_listbox_selected(hwnd); } |
997 int Selected(int where) { return dw_listbox_selected_multi(hwnd, where); } | 1144 int Selected(int where) { return dw_listbox_selected_multi(hwnd, where); } |
998 void SetTop(int top) { dw_listbox_set_top(hwnd, top); } | 1145 void SetTop(int top) { dw_listbox_set_top(hwnd, top); } |
999 #ifdef DW_LAMBDA | 1146 #ifdef DW_LAMBDA |
1000 void ConnectListSelect(std::function<int(int)> userfunc) | 1147 void ConnectListSelect(std::function<int(int)> userfunc) |
1001 #else | |
1002 void ConnectListSelect(int (*userfunc)(int)) | |
1003 #endif | |
1004 { | 1148 { |
1005 _ConnectListSelect = userfunc; | 1149 _ConnectListSelect = userfunc; |
1150 if(!ListSelectConnected) { | |
1151 dw_signal_connect(hwnd, DW_SIGNAL_LIST_SELECT, DW_SIGNAL_FUNC(_OnListSelect), this); | |
1152 ListSelectConnected = true; | |
1153 } | |
1154 } | |
1155 #endif | |
1156 void ConnectListSelect(int (*userfunc)(ListBoxes *, int)) | |
1157 { | |
1158 _ConnectListSelectOld = userfunc; | |
1006 if(!ListSelectConnected) { | 1159 if(!ListSelectConnected) { |
1007 dw_signal_connect(hwnd, DW_SIGNAL_LIST_SELECT, DW_SIGNAL_FUNC(_OnListSelect), this); | 1160 dw_signal_connect(hwnd, DW_SIGNAL_LIST_SELECT, DW_SIGNAL_FUNC(_OnListSelect), this); |
1008 ListSelectConnected = true; | 1161 ListSelectConnected = true; |
1009 } | 1162 } |
1010 } | 1163 } |
1043 { | 1196 { |
1044 private: | 1197 private: |
1045 bool ValueChangedConnected; | 1198 bool ValueChangedConnected; |
1046 #ifdef DW_LAMBDA | 1199 #ifdef DW_LAMBDA |
1047 std::function<int(int)> _ConnectValueChanged; | 1200 std::function<int(int)> _ConnectValueChanged; |
1048 #else | 1201 #endif |
1049 int (*_ConnectValueChanged)(int value); | 1202 int (*_ConnectValueChangedOld)(Ranged *, int value); |
1050 #endif | |
1051 static int _OnValueChanged(HWND window, int value, void *data) { | 1203 static int _OnValueChanged(HWND window, int value, void *data) { |
1052 if(reinterpret_cast<Ranged *>(data)->_ConnectValueChanged) | 1204 Ranged *classptr = reinterpret_cast<Ranged *>(data); |
1053 return reinterpret_cast<Ranged *>(data)->_ConnectValueChanged(value); | 1205 #ifdef DW_LAMBDA |
1054 return reinterpret_cast<Ranged *>(data)->OnValueChanged(value); | 1206 if(classptr->_ConnectValueChanged) |
1207 return classptr->_ConnectValueChanged(value); | |
1208 #endif | |
1209 if(classptr->_ConnectValueChangedOld) | |
1210 return classptr->_ConnectValueChangedOld(classptr, value); | |
1211 return classptr->OnValueChanged(value); | |
1055 } | 1212 } |
1056 protected: | 1213 protected: |
1057 void Setup() { | 1214 void Setup() { |
1058 _ConnectValueChanged = 0; | 1215 _ConnectValueChanged = 0; |
1059 if(IsOverridden(Ranged::OnValueChanged, this)) { | 1216 if(IsOverridden(Ranged::OnValueChanged, this)) { |
1071 return FALSE; | 1228 return FALSE; |
1072 } | 1229 } |
1073 public: | 1230 public: |
1074 #ifdef DW_LAMBDA | 1231 #ifdef DW_LAMBDA |
1075 void ConnectValueChanged(std::function<int(int)> userfunc) | 1232 void ConnectValueChanged(std::function<int(int)> userfunc) |
1076 #else | |
1077 void ConnectValueChanged(int (*userfunc)(int)) | |
1078 #endif | |
1079 { | 1233 { |
1080 _ConnectValueChanged = userfunc; | 1234 _ConnectValueChanged = userfunc; |
1235 if(!ValueChangedConnected) { | |
1236 dw_signal_connect(hwnd, DW_SIGNAL_VALUE_CHANGED, DW_SIGNAL_FUNC(_OnValueChanged), this); | |
1237 ValueChangedConnected = true; | |
1238 } | |
1239 } | |
1240 #endif | |
1241 void ConnectValueChanged(int (*userfunc)(Ranged *, int)) | |
1242 { | |
1243 _ConnectValueChangedOld = userfunc; | |
1081 if(!ValueChangedConnected) { | 1244 if(!ValueChangedConnected) { |
1082 dw_signal_connect(hwnd, DW_SIGNAL_VALUE_CHANGED, DW_SIGNAL_FUNC(_OnValueChanged), this); | 1245 dw_signal_connect(hwnd, DW_SIGNAL_VALUE_CHANGED, DW_SIGNAL_FUNC(_OnValueChanged), this); |
1083 ValueChangedConnected = true; | 1246 ValueChangedConnected = true; |
1084 } | 1247 } |
1085 } | 1248 } |
1153 { | 1316 { |
1154 private: | 1317 private: |
1155 bool SwitchPageConnected; | 1318 bool SwitchPageConnected; |
1156 #ifdef DW_LAMBDA | 1319 #ifdef DW_LAMBDA |
1157 std::function<int(unsigned long)> _ConnectSwitchPage; | 1320 std::function<int(unsigned long)> _ConnectSwitchPage; |
1158 #else | 1321 #endif |
1159 int (*_ConnectSwitchPage)(unsigned long); | 1322 int (*_ConnectSwitchPageOld)(Notebook *, unsigned long); |
1160 #endif | |
1161 static int _OnSwitchPage(HWND window, unsigned long pageid, void *data) { | 1323 static int _OnSwitchPage(HWND window, unsigned long pageid, void *data) { |
1162 if(reinterpret_cast<Notebook *>(data)->_ConnectSwitchPage) | 1324 Notebook *classptr = reinterpret_cast<Notebook *>(data); |
1163 return reinterpret_cast<Notebook *>(data)->_ConnectSwitchPage(pageid); | 1325 #ifdef DW_LAMBDA |
1164 return reinterpret_cast<Notebook *>(data)->OnSwitchPage(pageid); | 1326 if(classptr->_ConnectSwitchPage) |
1327 return classptr->_ConnectSwitchPage(pageid); | |
1328 #endif | |
1329 if(classptr->_ConnectSwitchPageOld) | |
1330 return classptr->_ConnectSwitchPageOld(classptr, pageid); | |
1331 return classptr->OnSwitchPage(pageid); | |
1165 } | 1332 } |
1166 protected: | 1333 protected: |
1167 void Setup() { | 1334 void Setup() { |
1168 _ConnectSwitchPage = 0; | 1335 _ConnectSwitchPage = 0; |
1169 if(IsOverridden(Notebook::OnSwitchPage, this)) { | 1336 if(IsOverridden(Notebook::OnSwitchPage, this)) { |
1196 void PageSet(unsigned long pageid) { dw_notebook_page_set(hwnd, pageid); } | 1363 void PageSet(unsigned long pageid) { dw_notebook_page_set(hwnd, pageid); } |
1197 void PageSetStatusText(unsigned long pageid, const char *text) { dw_notebook_page_set_status_text(hwnd, pageid, text); } | 1364 void PageSetStatusText(unsigned long pageid, const char *text) { dw_notebook_page_set_status_text(hwnd, pageid, text); } |
1198 void PageSetText(unsigned long pageid, const char *text) { dw_notebook_page_set_text(hwnd, pageid, text); } | 1365 void PageSetText(unsigned long pageid, const char *text) { dw_notebook_page_set_text(hwnd, pageid, text); } |
1199 #ifdef DW_LAMBDA | 1366 #ifdef DW_LAMBDA |
1200 void ConnectSwitchPage(std::function<int(unsigned long)> userfunc) | 1367 void ConnectSwitchPage(std::function<int(unsigned long)> userfunc) |
1201 #else | |
1202 void ConnectSwitchPage(int (*userfunc)(unsigned long)) | |
1203 #endif | |
1204 { | 1368 { |
1205 _ConnectSwitchPage = userfunc; | 1369 _ConnectSwitchPage = userfunc; |
1206 if(!SwitchPageConnected) { | 1370 if(!SwitchPageConnected) { |
1207 dw_signal_connect(hwnd, DW_SIGNAL_SWITCH_PAGE, DW_SIGNAL_FUNC(_OnSwitchPage), this); | 1371 dw_signal_connect(hwnd, DW_SIGNAL_SWITCH_PAGE, DW_SIGNAL_FUNC(_OnSwitchPage), this); |
1208 SwitchPageConnected = true; | 1372 SwitchPageConnected = true; |
1209 } | 1373 } |
1210 } | 1374 } |
1375 #endif | |
1376 void ConnectSwitchPage(int (*userfunc)(Notebook *, unsigned long)) | |
1377 { | |
1378 _ConnectSwitchPageOld = userfunc; | |
1379 if(!SwitchPageConnected) { | |
1380 dw_signal_connect(hwnd, DW_SIGNAL_SWITCH_PAGE, DW_SIGNAL_FUNC(_OnSwitchPage), this); | |
1381 SwitchPageConnected = true; | |
1382 } | |
1383 } | |
1211 }; | 1384 }; |
1212 | 1385 |
1213 class ObjectView : virtual public Widget | 1386 class ObjectView : virtual public Widget |
1214 { | 1387 { |
1215 private: | 1388 private: |
1216 bool ItemSelectConnected, ItemContextConnected; | 1389 bool ItemSelectConnected, ItemContextConnected; |
1217 #ifdef DW_LAMBDA | 1390 #ifdef DW_LAMBDA |
1218 std::function<int(HTREEITEM, char *, void *)> _ConnectItemSelect; | 1391 std::function<int(HTREEITEM, char *, void *)> _ConnectItemSelect; |
1219 std::function<int(char *, int, int, void *)> _ConnectItemContext; | 1392 std::function<int(char *, int, int, void *)> _ConnectItemContext; |
1220 #else | 1393 #endif |
1221 int (*_ConnectItemSelect)(HTREEITEM, char *, void *); | 1394 int (*_ConnectItemSelectOld)(ObjectView *, HTREEITEM, char *, void *); |
1222 int (*_ConnectItemContext)(char *, int, int, void *); | 1395 int (*_ConnectItemContextOld)(ObjectView *, char *, int, int, void *); |
1223 #endif | |
1224 static int _OnItemSelect(HWND window, HTREEITEM item, char *text, void *itemdata, void *data) { | 1396 static int _OnItemSelect(HWND window, HTREEITEM item, char *text, void *itemdata, void *data) { |
1225 if(reinterpret_cast<ObjectView *>(data)->_ConnectItemSelect) | 1397 ObjectView *classptr = reinterpret_cast<ObjectView *>(data); |
1226 return reinterpret_cast<ObjectView *>(data)->_ConnectItemSelect(item, text, itemdata); | 1398 #ifdef DW_LAMBDA |
1227 return reinterpret_cast<ObjectView *>(data)->OnItemSelect(item, text, itemdata); | 1399 if(classptr->_ConnectItemSelect) |
1400 return classptr->_ConnectItemSelect(item, text, itemdata); | |
1401 #endif | |
1402 if(classptr->_ConnectItemSelectOld) | |
1403 return classptr->_ConnectItemSelectOld(classptr, item, text, itemdata); | |
1404 return classptr->OnItemSelect(item, text, itemdata); | |
1228 } | 1405 } |
1229 static int _OnItemContext(HWND window, char *text, int x, int y, void *itemdata, void *data) { | 1406 static int _OnItemContext(HWND window, char *text, int x, int y, void *itemdata, void *data) { |
1230 if(reinterpret_cast<ObjectView *>(data)->_ConnectItemContext) | 1407 ObjectView *classptr = reinterpret_cast<ObjectView *>(data); |
1231 return reinterpret_cast<ObjectView *>(data)->_ConnectItemContext(text, x, y, itemdata); | 1408 #ifdef DW_LAMBDA |
1232 return reinterpret_cast<ObjectView *>(data)->OnItemContext(text, x, y, itemdata); | 1409 if(classptr->_ConnectItemContext) |
1410 return classptr->_ConnectItemContext(text, x, y, itemdata); | |
1411 #endif | |
1412 if(classptr->_ConnectItemContextOld) | |
1413 return classptr->_ConnectItemContextOld(classptr, text, x, y, itemdata); | |
1414 return classptr->OnItemContext(text, x, y, itemdata); | |
1233 } | 1415 } |
1234 protected: | 1416 protected: |
1235 void SetupObjectView() { | 1417 void SetupObjectView() { |
1418 #ifdef DW_LAMBDA | |
1236 _ConnectItemSelect = 0; | 1419 _ConnectItemSelect = 0; |
1237 _ConnectItemContext = 0; | 1420 _ConnectItemContext = 0; |
1421 #endif | |
1422 _ConnectItemSelectOld = 0; | |
1423 _ConnectItemContextOld = 0; | |
1238 if(IsOverridden(ObjectView::OnItemSelect, this)) { | 1424 if(IsOverridden(ObjectView::OnItemSelect, this)) { |
1239 dw_signal_connect(hwnd, DW_SIGNAL_ITEM_SELECT, DW_SIGNAL_FUNC(_OnItemSelect), this); | 1425 dw_signal_connect(hwnd, DW_SIGNAL_ITEM_SELECT, DW_SIGNAL_FUNC(_OnItemSelect), this); |
1240 ItemSelectConnected = true; | 1426 ItemSelectConnected = true; |
1241 } else { | 1427 } else { |
1242 ItemSelectConnected = false; | 1428 ItemSelectConnected = false; |
1261 return FALSE; | 1447 return FALSE; |
1262 } | 1448 } |
1263 public: | 1449 public: |
1264 #ifdef DW_LAMBDA | 1450 #ifdef DW_LAMBDA |
1265 void ConnectItemSelect(std::function<int(HTREEITEM, char *, void *)> userfunc) | 1451 void ConnectItemSelect(std::function<int(HTREEITEM, char *, void *)> userfunc) |
1266 #else | |
1267 void ConnectItemSelect(int (*userfunc)(HTREEITEM, char *, void *)) | |
1268 #endif | |
1269 { | 1452 { |
1270 _ConnectItemSelect = userfunc; | 1453 _ConnectItemSelect = userfunc; |
1271 if(!ItemSelectConnected) { | 1454 if(!ItemSelectConnected) { |
1272 dw_signal_connect(hwnd, DW_SIGNAL_ITEM_SELECT, DW_SIGNAL_FUNC(_OnItemSelect), this); | 1455 dw_signal_connect(hwnd, DW_SIGNAL_ITEM_SELECT, DW_SIGNAL_FUNC(_OnItemSelect), this); |
1273 ItemSelectConnected = true; | 1456 ItemSelectConnected = true; |
1274 } | 1457 } |
1275 } | 1458 } |
1459 #endif | |
1460 void ConnectItemSelect(int (*userfunc)(ObjectView *, HTREEITEM, char *, void *)) | |
1461 { | |
1462 _ConnectItemSelectOld = userfunc; | |
1463 if(!ItemSelectConnected) { | |
1464 dw_signal_connect(hwnd, DW_SIGNAL_ITEM_SELECT, DW_SIGNAL_FUNC(_OnItemSelect), this); | |
1465 ItemSelectConnected = true; | |
1466 } | |
1467 } | |
1276 #ifdef DW_LAMBDA | 1468 #ifdef DW_LAMBDA |
1277 void ConnectItemContext(std::function<int(char *, int, int, void *)> userfunc) | 1469 void ConnectItemContext(std::function<int(char *, int, int, void *)> userfunc) |
1278 #else | |
1279 void ConnectItemContext(int (*userfunc)(char *, int, int, void *)) | |
1280 #endif | |
1281 { | 1470 { |
1282 _ConnectItemContext = userfunc; | 1471 _ConnectItemContext = userfunc; |
1283 if(!ItemContextConnected) { | 1472 if(!ItemContextConnected) { |
1284 dw_signal_connect(hwnd, DW_SIGNAL_ITEM_CONTEXT, DW_SIGNAL_FUNC(_OnItemContext), this); | 1473 dw_signal_connect(hwnd, DW_SIGNAL_ITEM_CONTEXT, DW_SIGNAL_FUNC(_OnItemContext), this); |
1285 ItemContextConnected = true; | 1474 ItemContextConnected = true; |
1286 } | 1475 } |
1287 } | 1476 } |
1477 #endif | |
1478 void ConnectItemContext(int (*userfunc)(ObjectView *, char *, int, int, void *)) | |
1479 { | |
1480 _ConnectItemContextOld = userfunc; | |
1481 if(!ItemContextConnected) { | |
1482 dw_signal_connect(hwnd, DW_SIGNAL_ITEM_CONTEXT, DW_SIGNAL_FUNC(_OnItemContext), this); | |
1483 ItemContextConnected = true; | |
1484 } | |
1485 } | |
1288 }; | 1486 }; |
1289 | 1487 |
1290 class Containers : virtual public Focusable, virtual public ObjectView | 1488 class Containers : virtual public Focusable, virtual public ObjectView |
1291 { | 1489 { |
1292 private: | 1490 private: |
1293 bool ItemEnterConnected, ColumnClickConnected; | 1491 bool ItemEnterConnected, ColumnClickConnected; |
1294 #ifdef DW_LAMBDA | 1492 #ifdef DW_LAMBDA |
1295 std::function<int(char *)> _ConnectItemEnter; | 1493 std::function<int(char *)> _ConnectItemEnter; |
1296 std::function<int(int)> _ConnectColumnClick; | 1494 std::function<int(int)> _ConnectColumnClick; |
1297 #else | 1495 #endif |
1298 int (*_ConnectItemEnter)(char *); | 1496 int (*_ConnectItemEnterOld)(Containers *, char *); |
1299 int (*_ConnectColumnClick)(int); | 1497 int (*_ConnectColumnClickOld)(Containers *, int); |
1300 #endif | |
1301 static int _OnItemEnter(HWND window, char *text, void *data) { | 1498 static int _OnItemEnter(HWND window, char *text, void *data) { |
1302 if(reinterpret_cast<Containers *>(data)->_ConnectItemEnter) | 1499 Containers *classptr = reinterpret_cast<Containers *>(data); |
1303 return reinterpret_cast<Containers *>(data)->_ConnectItemEnter(text); | 1500 #ifdef DW_LAMBDA |
1304 return reinterpret_cast<Containers *>(data)->OnItemEnter(text); | 1501 if(classptr->_ConnectItemEnter) |
1502 return classptr->_ConnectItemEnter(text); | |
1503 #endif | |
1504 if(classptr->_ConnectItemEnterOld) | |
1505 return classptr->_ConnectItemEnterOld(classptr, text); | |
1506 return classptr->OnItemEnter(text); | |
1305 } | 1507 } |
1306 static int _OnColumnClick(HWND window, int column, void *data) { | 1508 static int _OnColumnClick(HWND window, int column, void *data) { |
1307 if(reinterpret_cast<Containers *>(data)->_ConnectColumnClick) | 1509 Containers *classptr = reinterpret_cast<Containers *>(data); |
1308 return reinterpret_cast<Containers *>(data)->_ConnectColumnClick(column); | 1510 #ifdef DW_LAMBDA |
1309 return reinterpret_cast<Containers *>(data)->OnColumnClick(column); | 1511 if(classptr->_ConnectColumnClick) |
1512 return classptr->_ConnectColumnClick(column); | |
1513 #endif | |
1514 if(classptr->_ConnectColumnClickOld) | |
1515 return classptr->_ConnectColumnClickOld(classptr, column); | |
1516 return classptr->OnColumnClick(column); | |
1310 } | 1517 } |
1311 protected: | 1518 protected: |
1312 void *allocpointer; | 1519 void *allocpointer; |
1313 int allocrowcount; | 1520 int allocrowcount; |
1314 void SetupContainer() { | 1521 void SetupContainer() { |
1522 #ifdef DW_LAMBDA | |
1315 _ConnectItemEnter = 0; | 1523 _ConnectItemEnter = 0; |
1316 _ConnectColumnClick = 0; | 1524 _ConnectColumnClick = 0; |
1525 #endif | |
1526 _ConnectItemEnterOld = 0; | |
1527 _ConnectColumnClickOld = 0; | |
1317 if(IsOverridden(Container::OnItemEnter, this)) { | 1528 if(IsOverridden(Container::OnItemEnter, this)) { |
1318 dw_signal_connect(hwnd, DW_SIGNAL_ITEM_ENTER, DW_SIGNAL_FUNC(_OnItemEnter), this); | 1529 dw_signal_connect(hwnd, DW_SIGNAL_ITEM_ENTER, DW_SIGNAL_FUNC(_OnItemEnter), this); |
1319 ItemEnterConnected = true; | 1530 ItemEnterConnected = true; |
1320 } else { | 1531 } else { |
1321 ItemEnterConnected = false; | 1532 ItemEnterConnected = false; |
1359 void SetRowData(int row, void *data) { dw_container_set_row_data(allocpointer, row, data); } | 1570 void SetRowData(int row, void *data) { dw_container_set_row_data(allocpointer, row, data); } |
1360 void SetRowTitle(int row, const char *title) { dw_container_set_row_title(allocpointer, row, title); } | 1571 void SetRowTitle(int row, const char *title) { dw_container_set_row_title(allocpointer, row, title); } |
1361 void SetStripe(unsigned long oddcolor, unsigned long evencolor) { dw_container_set_stripe(hwnd, oddcolor, evencolor); } | 1572 void SetStripe(unsigned long oddcolor, unsigned long evencolor) { dw_container_set_stripe(hwnd, oddcolor, evencolor); } |
1362 #ifdef DW_LAMBDA | 1573 #ifdef DW_LAMBDA |
1363 void ConnectItemEnter(std::function<int(char *)> userfunc) | 1574 void ConnectItemEnter(std::function<int(char *)> userfunc) |
1364 #else | |
1365 void ConnectItemEnter(int (*userfunc)(char *)) | |
1366 #endif | |
1367 { | 1575 { |
1368 _ConnectItemEnter = userfunc; | 1576 _ConnectItemEnter = userfunc; |
1369 if(!ItemEnterConnected) { | 1577 if(!ItemEnterConnected) { |
1370 dw_signal_connect(hwnd, DW_SIGNAL_ITEM_ENTER, DW_SIGNAL_FUNC(_OnItemEnter), this); | 1578 dw_signal_connect(hwnd, DW_SIGNAL_ITEM_ENTER, DW_SIGNAL_FUNC(_OnItemEnter), this); |
1371 ItemEnterConnected = true; | 1579 ItemEnterConnected = true; |
1372 } | 1580 } |
1373 } | 1581 } |
1582 #endif | |
1583 void ConnectItemEnter(int (*userfunc)(Containers *, char *)) | |
1584 { | |
1585 _ConnectItemEnterOld = userfunc; | |
1586 if(!ItemEnterConnected) { | |
1587 dw_signal_connect(hwnd, DW_SIGNAL_ITEM_ENTER, DW_SIGNAL_FUNC(_OnItemEnter), this); | |
1588 ItemEnterConnected = true; | |
1589 } | |
1590 } | |
1374 #ifdef DW_LAMBDA | 1591 #ifdef DW_LAMBDA |
1375 void ConnecColumnClick(std::function<int(int)> userfunc) | 1592 void ConnecColumnClick(std::function<int(int)> userfunc) |
1376 #else | |
1377 void ConnectColumnClick(int (*userfunc)(int)) | |
1378 #endif | |
1379 { | 1593 { |
1380 _ConnectColumnClick = userfunc; | 1594 _ConnectColumnClick = userfunc; |
1595 if(!ColumnClickConnected) { | |
1596 dw_signal_connect(hwnd, DW_SIGNAL_COLUMN_CLICK, DW_SIGNAL_FUNC(_OnColumnClick), this); | |
1597 ColumnClickConnected = true; | |
1598 } | |
1599 } | |
1600 #endif | |
1601 void ConnectColumnClick(int (*userfunc)(Containers *, int)) | |
1602 { | |
1603 _ConnectColumnClickOld = userfunc; | |
1381 if(!ColumnClickConnected) { | 1604 if(!ColumnClickConnected) { |
1382 dw_signal_connect(hwnd, DW_SIGNAL_COLUMN_CLICK, DW_SIGNAL_FUNC(_OnColumnClick), this); | 1605 dw_signal_connect(hwnd, DW_SIGNAL_COLUMN_CLICK, DW_SIGNAL_FUNC(_OnColumnClick), this); |
1383 ColumnClickConnected = true; | 1606 ColumnClickConnected = true; |
1384 } | 1607 } |
1385 } | 1608 } |
1422 { | 1645 { |
1423 private: | 1646 private: |
1424 bool TreeExpandConnected; | 1647 bool TreeExpandConnected; |
1425 #ifdef DW_LAMBDA | 1648 #ifdef DW_LAMBDA |
1426 std::function<int(HTREEITEM)> _ConnectTreeExpand; | 1649 std::function<int(HTREEITEM)> _ConnectTreeExpand; |
1427 #else | 1650 #endif |
1428 int (*_ConnectTreeExpand)(HTREEITEM); | 1651 int (*_ConnectTreeExpandOld)(Tree *, HTREEITEM); |
1429 #endif | |
1430 static int _OnTreeExpand(HWND window, HTREEITEM item, void *data) { | 1652 static int _OnTreeExpand(HWND window, HTREEITEM item, void *data) { |
1431 if(reinterpret_cast<Tree *>(data)->_ConnectTreeExpand) | 1653 Tree *classptr = reinterpret_cast<Tree *>(data); |
1432 return reinterpret_cast<Tree *>(data)->_ConnectTreeExpand(item); | 1654 #ifdef DW_LAMBDA |
1433 return reinterpret_cast<Tree *>(data)->OnTreeExpand(item); | 1655 if(classptr->_ConnectTreeExpand) |
1656 return classptr->_ConnectTreeExpand(item); | |
1657 #endif | |
1658 if(classptr->_ConnectTreeExpandOld) | |
1659 return classptr->_ConnectTreeExpandOld(classptr, item); | |
1660 return classptr->OnTreeExpand(item); | |
1434 } | 1661 } |
1435 void SetupTree() { | 1662 void SetupTree() { |
1663 #ifdef DW_LAMBDA | |
1436 _ConnectTreeExpand = 0; | 1664 _ConnectTreeExpand = 0; |
1665 #endif | |
1666 _ConnectTreeExpandOld = 0; | |
1437 if(IsOverridden(Tree::OnTreeExpand, this)) { | 1667 if(IsOverridden(Tree::OnTreeExpand, this)) { |
1438 dw_signal_connect(hwnd, DW_SIGNAL_TREE_EXPAND, DW_SIGNAL_FUNC(_OnTreeExpand), this); | 1668 dw_signal_connect(hwnd, DW_SIGNAL_TREE_EXPAND, DW_SIGNAL_FUNC(_OnTreeExpand), this); |
1439 TreeExpandConnected = true; | 1669 TreeExpandConnected = true; |
1440 } else { | 1670 } else { |
1441 TreeExpandConnected = false; | 1671 TreeExpandConnected = false; |
1467 void *GetData(HTREEITEM item) { return dw_tree_item_get_data(hwnd, item); } | 1697 void *GetData(HTREEITEM item) { return dw_tree_item_get_data(hwnd, item); } |
1468 void Select(HTREEITEM item) { dw_tree_item_select(hwnd, item); } | 1698 void Select(HTREEITEM item) { dw_tree_item_select(hwnd, item); } |
1469 void SetData(HTREEITEM item, void *itemdata) { dw_tree_item_set_data(hwnd, item, itemdata); } | 1699 void SetData(HTREEITEM item, void *itemdata) { dw_tree_item_set_data(hwnd, item, itemdata); } |
1470 #ifdef DW_LAMBDA | 1700 #ifdef DW_LAMBDA |
1471 void ConnectTreeExpand(std::function<int(HTREEITEM)> userfunc) | 1701 void ConnectTreeExpand(std::function<int(HTREEITEM)> userfunc) |
1472 #else | |
1473 void ConnectTreeExpand(int (*userfunc)(HTREEITEM)) | |
1474 #endif | |
1475 { | 1702 { |
1476 _ConnectTreeExpand = userfunc; | 1703 _ConnectTreeExpand = userfunc; |
1704 if(!TreeExpandConnected) { | |
1705 dw_signal_connect(hwnd, DW_SIGNAL_TREE_EXPAND, DW_SIGNAL_FUNC(_OnTreeExpand), this); | |
1706 TreeExpandConnected = true; | |
1707 } | |
1708 } | |
1709 #endif | |
1710 void ConnectTreeExpandOld(int (*userfunc)(Tree *, HTREEITEM)) | |
1711 { | |
1712 _ConnectTreeExpandOld = userfunc; | |
1477 if(!TreeExpandConnected) { | 1713 if(!TreeExpandConnected) { |
1478 dw_signal_connect(hwnd, DW_SIGNAL_TREE_EXPAND, DW_SIGNAL_FUNC(_OnTreeExpand), this); | 1714 dw_signal_connect(hwnd, DW_SIGNAL_TREE_EXPAND, DW_SIGNAL_FUNC(_OnTreeExpand), this); |
1479 TreeExpandConnected = true; | 1715 TreeExpandConnected = true; |
1480 } | 1716 } |
1481 } | 1717 } |
1569 { | 1805 { |
1570 private: | 1806 private: |
1571 HTIMER timer; | 1807 HTIMER timer; |
1572 #ifdef DW_LAMBDA | 1808 #ifdef DW_LAMBDA |
1573 std::function<int()> _ConnectTimer; | 1809 std::function<int()> _ConnectTimer; |
1574 #else | 1810 #endif |
1575 int (*_ConnectTimer)(); | 1811 int (*_ConnectTimerOld)(Timer *); |
1576 #endif | |
1577 static int _OnTimer(void *data) { | 1812 static int _OnTimer(void *data) { |
1578 if(reinterpret_cast<Timer *>(data)->_ConnectTimer) | 1813 Timer *classptr = reinterpret_cast<Timer *>(data); |
1579 return reinterpret_cast<Timer *>(data)->_ConnectTimer(); | 1814 #ifdef DW_LAMBDA |
1580 return reinterpret_cast<Timer *>(data)->OnTimer(); | 1815 if(classptr->_ConnectTimer) |
1816 return classptr->_ConnectTimer(); | |
1817 #endif | |
1818 if(classptr->_ConnectTimerOld) | |
1819 return classptr->_ConnectTimerOld(classptr); | |
1820 return classptr->OnTimer(); | |
1581 } | 1821 } |
1582 public: | 1822 public: |
1583 // Constructors | 1823 // Constructors |
1584 Timer(int interval) { _ConnectTimer = 0; timer = dw_timer_connect(interval, DW_SIGNAL_FUNC(_OnTimer), this); SetHandle(reinterpret_cast<void *>(timer)); } | 1824 Timer(int interval) { _ConnectTimer = 0; timer = dw_timer_connect(interval, DW_SIGNAL_FUNC(_OnTimer), this); SetHandle(reinterpret_cast<void *>(timer)); } |
1585 #ifdef DW_LAMBDA | 1825 #ifdef DW_LAMBDA |
1586 Timer(int interval, std::function<int()> userfunc) | 1826 Timer(int interval, std::function<int()> userfunc) { |
1587 #else | |
1588 Timer(int interval, int (*userfunc)()) | |
1589 #endif | |
1590 { | |
1591 _ConnectTimer = userfunc; | 1827 _ConnectTimer = userfunc; |
1828 _ConnectTimerOld = 0; | |
1829 timer = dw_timer_connect(interval, DW_SIGNAL_FUNC(_OnTimer), this); | |
1830 SetHandle(reinterpret_cast<void *>(timer)); | |
1831 } | |
1832 #endif | |
1833 Timer(int interval, int (*userfunc)(Timer *)) { | |
1834 _ConnectTimerOld = userfunc; | |
1835 #ifdef DW_LAMBDA | |
1836 _ConnectTimer = 0; | |
1837 #endif | |
1592 timer = dw_timer_connect(interval, DW_SIGNAL_FUNC(_OnTimer), this); | 1838 timer = dw_timer_connect(interval, DW_SIGNAL_FUNC(_OnTimer), this); |
1593 SetHandle(reinterpret_cast<void *>(timer)); | 1839 SetHandle(reinterpret_cast<void *>(timer)); |
1594 } | 1840 } |
1595 // Destructor | 1841 // Destructor |
1596 virtual ~Timer() { if(timer) { dw_timer_disconnect(timer); timer = 0; } } | 1842 virtual ~Timer() { if(timer) { dw_timer_disconnect(timer); timer = 0; } } |
1625 { | 1871 { |
1626 private: | 1872 private: |
1627 HPRINT print; | 1873 HPRINT print; |
1628 #ifdef DW_LAMBDA | 1874 #ifdef DW_LAMBDA |
1629 std::function<int(Pixmap *, int)> _ConnectDrawPage; | 1875 std::function<int(Pixmap *, int)> _ConnectDrawPage; |
1630 #else | 1876 #endif |
1631 int (*_ConnectDrawPage)(Pixmap *, int); | 1877 int (*_ConnectDrawPageOld)(Print *, Pixmap *, int); |
1632 #endif | |
1633 static int _OnDrawPage(HPRINT print, HPIXMAP hpm, int page_num, void *data) { | 1878 static int _OnDrawPage(HPRINT print, HPIXMAP hpm, int page_num, void *data) { |
1634 int retval; | 1879 int retval; |
1635 Pixmap *pixmap = new Pixmap(hpm); | 1880 Pixmap *pixmap = new Pixmap(hpm); |
1636 | 1881 Print *classptr = reinterpret_cast<Print *>(data); |
1637 if(reinterpret_cast<Print *>(data)->_ConnectDrawPage) | 1882 |
1638 retval = reinterpret_cast<Print *>(data)->_ConnectDrawPage(pixmap, page_num); | 1883 #ifdef DW_LAMBDA |
1884 if(classptr->_ConnectDrawPage) | |
1885 retval = classptr->_ConnectDrawPage(pixmap, page_num); | |
1639 else | 1886 else |
1640 retval = reinterpret_cast<Print *>(data)->OnDrawPage(pixmap, page_num); | 1887 #endif |
1888 if(classptr->_ConnectDrawPageOld) | |
1889 retval = classptr->_ConnectDrawPageOld(classptr, pixmap, page_num); | |
1890 else | |
1891 retval = classptr->OnDrawPage(pixmap, page_num); | |
1641 | 1892 |
1642 delete pixmap; | 1893 delete pixmap; |
1643 return retval; | 1894 return retval; |
1644 } | 1895 } |
1645 public: | 1896 public: |
1647 #ifdef DW_LAMBDA | 1898 #ifdef DW_LAMBDA |
1648 Print(const char *jobname, unsigned long flags, unsigned int pages, std::function<int(Pixmap *, int)> userfunc) { | 1899 Print(const char *jobname, unsigned long flags, unsigned int pages, std::function<int(Pixmap *, int)> userfunc) { |
1649 print = dw_print_new(jobname, flags, pages, DW_SIGNAL_FUNC(_OnDrawPage), this); | 1900 print = dw_print_new(jobname, flags, pages, DW_SIGNAL_FUNC(_OnDrawPage), this); |
1650 SetHandle(reinterpret_cast<void *>(print)); | 1901 SetHandle(reinterpret_cast<void *>(print)); |
1651 _ConnectDrawPage = userfunc; | 1902 _ConnectDrawPage = userfunc; |
1652 } | 1903 _ConnectDrawPageOld = 0; |
1653 #else | 1904 } |
1654 Print(const char *jobname, unsigned long flags, unsigned int pages, int (*userfunc)(Pixmap *, int)) { | 1905 #endif |
1906 Print(const char *jobname, unsigned long flags, unsigned int pages, int (*userfunc)(Print *, Pixmap *, int)) { | |
1655 print = dw_print_new(jobname, flags, pages, DW_SIGNAL_FUNC(_OnDrawPage), this); | 1907 print = dw_print_new(jobname, flags, pages, DW_SIGNAL_FUNC(_OnDrawPage), this); |
1656 SetHandle(reinterpret_cast<void *>(print)); | 1908 SetHandle(reinterpret_cast<void *>(print)); |
1657 _ConnectDrawPage = userfunc; | 1909 _ConnectDrawPageOld = userfunc; |
1658 } | 1910 #ifdef DW_LAMBDA |
1659 #endif | 1911 _ConnectDrawPage = 0; |
1912 #endif | |
1913 } | |
1660 // Destructor | 1914 // Destructor |
1661 virtual ~Print() { if(print) dw_print_cancel(print); print = 0; } | 1915 virtual ~Print() { if(print) dw_print_cancel(print); print = 0; } |
1662 | 1916 |
1663 // User functions | 1917 // User functions |
1664 void Cancel() { dw_print_cancel(print); delete this; } | 1918 void Cancel() { dw_print_cancel(print); delete this; } |