comparison dw.hpp @ 2917:77e5d6743013

C++: Implement most of Page 2 (Render) except the actual rendering.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Wed, 28 Dec 2022 09:32:27 +0000
parents fe43f8667d3d
children e609aa6a5b93
comparison
equal deleted inserted replaced
2916:fe43f8667d3d 2917:77e5d6743013
776 void SetHPIXMAP(HPIXMAP newpixmap) { 776 void SetHPIXMAP(HPIXMAP newpixmap) {
777 hpixmap = newpixmap; 777 hpixmap = newpixmap;
778 SetHandle(reinterpret_cast<void *>(newpixmap)); 778 SetHandle(reinterpret_cast<void *>(newpixmap));
779 } 779 }
780 HPIXMAP hpixmap; 780 HPIXMAP hpixmap;
781 public: 781 unsigned long pwidth, pheight;
782 // Constructors 782 public:
783 Pixmap(HWND window, unsigned long width, unsigned long height, int depth) { SetHPIXMAP(dw_pixmap_new(window, width, height, depth)); } 783 // Constructors
784 Pixmap(HWND window, unsigned long width, unsigned long height) { SetHPIXMAP(dw_pixmap_new(window, width, height, 32)); } 784 Pixmap(Render *window, unsigned long width, unsigned long height, int depth) {
785 SetHPIXMAP(dw_pixmap_new(window ? window->GetHWND() : DW_NOHWND, width, height, depth));
786 pwidth = width; pheight = height;
787 }
788 Pixmap(Render *window, unsigned long width, unsigned long height) {
789 SetHPIXMAP(dw_pixmap_new(window ? window->GetHWND() : DW_NOHWND, width, height, 32));
790 pwidth = width; pheight = height;
791 }
792 Pixmap(Render *window, const char *filename) {
793 SetHPIXMAP(dw_pixmap_new_from_file(window ? window->GetHWND() : DW_NOHWND, filename));
794 pwidth = hpixmap ? DW_PIXMAP_WIDTH(hpixmap) : 0;
795 pheight = hpixmap ? DW_PIXMAP_HEIGHT(hpixmap) : 0;
796 }
785 797
786 // User functions 798 // User functions
787 HPIXMAP GetHPIXMAP() { return hpixmap; } 799 HPIXMAP GetHPIXMAP() { return hpixmap; }
788 void DrawPoint(int x, int y) { dw_draw_point(DW_NOHWND, hpixmap, x, y); } 800 void DrawPoint(int x, int y) { dw_draw_point(DW_NOHWND, hpixmap, x, y); }
789 void DrawLine(int x1, int y1, int x2, int y2) { dw_draw_line(DW_NOHWND, hpixmap, x1, y1, x2, y2); } 801 void DrawLine(int x1, int y1, int x2, int y2) { dw_draw_line(DW_NOHWND, hpixmap, x1, y1, x2, y2); }
803 void BitBlt(int xdest, int ydest, int width, int height, Pixmap *src, int xsrc, int ysrc) { 815 void BitBlt(int xdest, int ydest, int width, int height, Pixmap *src, int xsrc, int ysrc) {
804 dw_pixmap_bitblt(DW_NOHWND, hpixmap, xdest, ydest, width, height, DW_NOHWND, src ? src->GetHPIXMAP() : DW_NULL, xsrc, ysrc); 816 dw_pixmap_bitblt(DW_NOHWND, hpixmap, xdest, ydest, width, height, DW_NOHWND, src ? src->GetHPIXMAP() : DW_NULL, xsrc, ysrc);
805 } 817 }
806 int SetFont(const char *fontname) { return dw_pixmap_set_font(hpixmap, fontname); } 818 int SetFont(const char *fontname) { return dw_pixmap_set_font(hpixmap, fontname); }
807 void GetTextExtents(const char *text, int *width, int *height) { dw_font_text_extents_get(DW_NOHWND, hpixmap, text, width, height); } 819 void GetTextExtents(const char *text, int *width, int *height) { dw_font_text_extents_get(DW_NOHWND, hpixmap, text, width, height); }
820 void SetTransparentColor(unsigned long color) { dw_pixmap_set_transparent_color(hpixmap, color); }
821 unsigned long GetWidth() { return pwidth; }
822 unsigned long GetHeight() { return pheight; }
808 }; 823 };
809 824
810 // Need to declare these here after Pixmap is defined 825 // Need to declare these here after Pixmap is defined
811 int Render::BitBltStretch(int xdest, int ydest, int width, int height, Pixmap *src, int xsrc, int ysrc, int srcwidth, int srcheight) 826 int Render::BitBltStretch(int xdest, int ydest, int width, int height, Pixmap *src, int xsrc, int ysrc, int srcwidth, int srcheight)
812 { 827 {
988 ListSelectConnected = false; 1003 ListSelectConnected = false;
989 return FALSE; 1004 return FALSE;
990 } 1005 }
991 }; 1006 };
992 1007
993 class Combobox : public TextEntry, public ListBoxes 1008 class ComboBox : public TextEntry, public ListBoxes
994 { 1009 {
995 public: 1010 public:
996 // Constructors 1011 // Constructors
997 Combobox(const char *text, unsigned long id) { SetHWND(dw_combobox_new(text, id)); } 1012 ComboBox(const char *text, unsigned long id) { SetHWND(dw_combobox_new(text, id)); }
998 Combobox(unsigned long id) { SetHWND(dw_combobox_new("", id)); } 1013 ComboBox(unsigned long id) { SetHWND(dw_combobox_new("", id)); }
999 Combobox(const char *text) { SetHWND(dw_combobox_new(text, 0)); } 1014 ComboBox(const char *text) { SetHWND(dw_combobox_new(text, 0)); }
1000 Combobox() { SetHWND(dw_combobox_new("", 0)); } 1015 ComboBox() { SetHWND(dw_combobox_new("", 0)); }
1001 }; 1016 };
1002 1017
1003 class Listbox : public ListBoxes 1018 class ListBox : public ListBoxes
1004 { 1019 {
1005 public: 1020 public:
1006 // Constructors 1021 // Constructors
1007 Listbox(unsigned long id, int multi) { SetHWND(dw_listbox_new(id, multi)); } 1022 ListBox(unsigned long id, int multi) { SetHWND(dw_listbox_new(id, multi)); }
1008 Listbox(unsigned long id) { SetHWND(dw_listbox_new(id, FALSE)); } 1023 ListBox(unsigned long id) { SetHWND(dw_listbox_new(id, FALSE)); }
1009 Listbox(int multi) { SetHWND(dw_listbox_new(0, multi)); } 1024 ListBox(int multi) { SetHWND(dw_listbox_new(0, multi)); }
1010 Listbox() { SetHWND(dw_listbox_new(0, FALSE)); } 1025 ListBox() { SetHWND(dw_listbox_new(0, FALSE)); }
1011 }; 1026 };
1012 1027
1013 // Base class for several ranged type widgets 1028 // Base class for several ranged type widgets
1014 class Ranged : virtual public Widget 1029 class Ranged : virtual public Widget
1015 { 1030 {
1067 // User functions 1082 // User functions
1068 unsigned int GetPos() { return dw_slider_get_pos(hwnd); } 1083 unsigned int GetPos() { return dw_slider_get_pos(hwnd); }
1069 void SetPos(unsigned int position) { dw_slider_set_pos(hwnd, position); } 1084 void SetPos(unsigned int position) { dw_slider_set_pos(hwnd, position); }
1070 }; 1085 };
1071 1086
1072 class Scrollbar : public Ranged 1087 class ScrollBar : public Ranged
1073 { 1088 {
1074 public: 1089 public:
1075 // Constructors 1090 // Constructors
1076 Scrollbar(int orient, unsigned long id) { SetHWND(dw_scrollbar_new(orient, id)); Setup(); } 1091 ScrollBar(int orient, unsigned long id) { SetHWND(dw_scrollbar_new(orient, id)); Setup(); }
1077 Scrollbar(int orient) { SetHWND(dw_scrollbar_new(orient, 0)); Setup(); } 1092 ScrollBar(int orient) { SetHWND(dw_scrollbar_new(orient, 0)); Setup(); }
1078 1093
1079 // User functions 1094 // User functions
1080 unsigned int GetPos() { return dw_scrollbar_get_pos(hwnd); } 1095 unsigned int GetPos() { return dw_scrollbar_get_pos(hwnd); }
1081 void SetPos(unsigned int position) { dw_scrollbar_set_pos(hwnd, position); } 1096 void SetPos(unsigned int position) { dw_scrollbar_set_pos(hwnd, position); }
1082 void SetRange(unsigned int range, unsigned int visible) { dw_scrollbar_set_range(hwnd, range, visible); } 1097 void SetRange(unsigned int range, unsigned int visible) { dw_scrollbar_set_range(hwnd, range, visible); }
1640 void Beep(int freq, int dur) { dw_beep(freq, dur); } 1655 void Beep(int freq, int dur) { dw_beep(freq, dur); }
1641 char *GetDir() { return dw_app_dir(); } 1656 char *GetDir() { return dw_app_dir(); }
1642 void GetEnvironment(DWEnv *env) { dw_environment_query(env); } 1657 void GetEnvironment(DWEnv *env) { dw_environment_query(env); }
1643 int GetScreenWidth() { return dw_screen_width(); } 1658 int GetScreenWidth() { return dw_screen_width(); }
1644 int GetScreenHeight() { return dw_screen_height(); } 1659 int GetScreenHeight() { return dw_screen_height(); }
1660 void GetPointerPos(long *x, long *y) { dw_pointer_query_pos(x, y); }
1645 unsigned long GetColorDepth() { return dw_color_depth_get(); } 1661 unsigned long GetColorDepth() { return dw_color_depth_get(); }
1646 char *GetClipboard() { return dw_clipboard_get_text(); } 1662 char *GetClipboard() { return dw_clipboard_get_text(); }
1647 void SetClipboard(const char *text) { if(text) dw_clipboard_set_text(text, (int)strlen(text)); } 1663 void SetClipboard(const char *text) { if(text) dw_clipboard_set_text(text, (int)strlen(text)); }
1648 void SetClipboard(const char *text, int len) { if(text) dw_clipboard_set_text(text, len); } 1664 void SetClipboard(const char *text, int len) { if(text) dw_clipboard_set_text(text, len); }
1649 void SetDefaultFont(const char *fontname) { dw_font_set_default(fontname); } 1665 void SetDefaultFont(const char *fontname) { dw_font_set_default(fontname); }
1655 int SetFeature(DWFEATURE feature, int state) { return dw_feature_set(feature, state); } 1671 int SetFeature(DWFEATURE feature, int state) { return dw_feature_set(feature, state); }
1656 HICN LoadIcon(unsigned long id) { return dw_icon_load(0, id); } 1672 HICN LoadIcon(unsigned long id) { return dw_icon_load(0, id); }
1657 HICN LoadIcon(const char *filename) { return dw_icon_load_from_file(filename); } 1673 HICN LoadIcon(const char *filename) { return dw_icon_load_from_file(filename); }
1658 HICN LoadIcon(const char *data, int len) { return dw_icon_load_from_data(data, len); } 1674 HICN LoadIcon(const char *data, int len) { return dw_icon_load_from_data(data, len); }
1659 void FreeIcon(HICN icon) { dw_icon_free(icon); } 1675 void FreeIcon(HICN icon) { dw_icon_free(icon); }
1676 void TaskBarInsert(Widget *handle, HICN icon, char *bubbletext) { dw_taskbar_insert(handle ? handle->GetHWND() : DW_NOHWND, icon, bubbletext); }
1677 void TaskBarDelete(Widget *handle, HICN icon) { dw_taskbar_delete(handle ? handle->GetHWND() : DW_NOHWND, icon); }
1660 }; 1678 };
1661 1679
1662 // Static singleton reference declared outside of the class 1680 // Static singleton reference declared outside of the class
1663 App* App::_app = DW_NULL; 1681 App* App::_app = DW_NULL;
1664 1682