mGUtils API Reference  v1.2.2
A component of MiniGUI providing users with a number of common dialog templates
mgutils.h
Go to the documentation of this file.
1 //
3 // IMPORTANT NOTICE
4 //
5 // The following open source license statement does not apply to any
6 // entity in the Exception List published by FMSoft.
7 //
8 // For more information, please visit:
9 //
10 // https://www.fmsoft.cn/exception-list
11 //
13 
54 /*
55  * $Id: mgutils.h 231 2017-10-26 07:25:36Z weiym $
56  *
57  * mGUtils: A MiniGUI component which contains miscellaneous
58  * utilities like ColorSelectionDialogBox, FileOpenDialogBox, and so on.
59  *
60  */
61 
62 #ifndef _MGUTILS_H
63 #define _MGUTILS_H
64 
65 #ifdef __cplusplus
66 extern "C" {
67 #endif
68 
69 #if !defined(__NODLL__) && (defined (WIN32) || defined (__NUCLEUS_MNT__))
70  #ifdef __MGUTILS_LIB__
71  #define MGUTILS_EXPORT __declspec(dllexport)
72  #else
73  #define MGUTILS_EXPORT __declspec(dllimport)
74  #endif
75 #elif defined(__NODLL__) && defined(WIN32)
76  #define MGUTILS_EXPORT __declspec(dllimport)
77 #else
78  #define MGUTILS_EXPORT
79 #endif
80 
81 #ifndef MGUTILS_MAJOR_VERSION
82 # undef PACKAGE
83 # undef VERSION
84 # undef PACKAGE_BUGREPORT
85 # undef PACKAGE_NAME
86 # undef PACKAGE_STRING
87 # undef PACKAGE_TARNAME
88 # undef PACKAGE_VERSION
89 # ifdef __MGUTILS_LIB__
90 # include "../mgutilsconfig.h"
91 # else
92 # include "mgutilsconfig.h"
93 # endif
94 #endif
95 
96 #define MGUTILS_MSG_BASE MSG_USER + 0x40
97 #define MSG_FILESELOK (MGUTILS_MSG_BASE + 1)
98 #define MSG_FILESELCANCEL (MGUTILS_MSG_BASE + 2)
99 #define MSG_COLORSELOK (MGUTILS_MSG_BASE + 3)
100 #define MSG_COLORSELCANCEL (MGUTILS_MSG_BASE + 4)
101 #define MSG_FONTSELOK (MGUTILS_MSG_BASE + 5)
102 #define MSG_FONTSELCANCEL (MGUTILS_MSG_BASE + 6)
103 
104 #ifdef _MGUTILS_MYWINS
105 
133 MGUTILS_EXPORT int myMessageBox (HWND hwnd, DWORD dwStyle, const char* title,
134  const char* text, ...);
135 
157 MGUTILS_EXPORT int myWinMessage (HWND hwnd, const char* title,
158  const char* button1, const char* text, ...);
159 
185 MGUTILS_EXPORT int myWinChoice (HWND hwnd, const char* title,
186  const char* button1, const char* button2,
187  const char* text, ...);
188 
215 MGUTILS_EXPORT int myWinTernary (HWND hwnd, const char* title,
216  const char* button1, const char* button2, const char* button3,
217  const char* text, ...);
218 
233 MGUTILS_EXPORT void errorWindow (HWND hwnd, const char* str, const char* title);
234 
254 MGUTILS_EXPORT HWND createStatusWin (HWND hParentWnd, int width, int height,
255  const char* title, const char* text, ...);
256 
268 MGUTILS_EXPORT void destroyStatusWin (HWND hwnd);
269 
270 /* back-compatibility definitions */
271 #define createToolTipWin CreateToolTipWin
272 #define resetToolTipWin ResetToolTipWin
273 #define destroyToolTipWin DestroyToolTipWin
274 
275 #ifdef _MGCTRL_PROGRESSBAR
276 
298 MGUTILS_EXPORT HWND createProgressWin (HWND hParentWnd, const char* title,
299  const char* label, int id, int range);
300 
312 MGUTILS_EXPORT void destroyProgressWin (HWND hwnd);
313 
314 #endif /* _MGCTRL_PROGRESSBAR */
315 
320 typedef struct _myWinButton
321 {
323  char* text;
325  int id;
327  DWORD flags;
328 } myWINBUTTON;
329 
330 /* This is an internal structure. */
331 typedef struct _myWinMenuItems
332 {
333  /* The pointer to the array of the item strings. */
334  char** items;
335  /* The identifier of the listbox display the menu items. */
336  int listboxid;
337  /* The pointer to the array of the selection status of the items. */
338  int* selected;
339  /* The minimal button identifier. */
340  int minbuttonid;
341  /* The maximal button identifier. */
342  int maxbuttonid;
343 } myWINMENUITEMS;
344 
373 MGUTILS_EXPORT int myWinMenu (HWND hParentWnd, const char* title,
374  const char* label, int width, int listboxheight,
375  char ** items, int * listItem, myWINBUTTON* buttons);
376 
381 typedef struct _myWinEntry
382 {
384  char* text;
386  char** value;
388  int maxlen;
390  DWORD flags;
391 } myWINENTRY;
392 
393 /* This is an internal structure. */
394 typedef struct _myWinEntryItems
395 {
396  myWINENTRY* entries;
397  int entrycount;
398  int firstentryid;
399  int minbuttonid;
400  int maxbuttonid;
401 } myWINENTRYITEMS;
402 
430 MGUTILS_EXPORT int myWinEntries (HWND hParentWnd, const char* title,
431  const char* label, int width, int editboxwidth,
432  BOOL fIME, myWINENTRY* items, myWINBUTTON* buttons);
433 
451 MGUTILS_EXPORT int myWinHelpMessage (HWND hwnd, int width, int height,
452  const char* help_title, const char* help_msg);
453 
456 #endif /* _MGUTILS_MYWINS */
457 
458 #ifdef _MGUTILS_VCONGUI
459 
468 #ifndef __cplusplus
469 #ifndef __ECOS__
470 typedef enum {false, true} bool;
471 #endif
472 #endif
473 
474 #define VCONGUI_VERSION "Version 0.8 (Feb. 2018)"
475 
476 #define MIN_COLS 10
477 #define MAX_COLS 100
478 #define MIN_ROWS 10
479 #define MAX_ROWS 60
480 
481 #define GetCharWidth GetSysCharWidth
482 #define GetCCharWidth GetSysCCharWidth
483 #define GetCharHeight GetSysCharHeight
484 
489 typedef struct _CHILDINFO
490 {
494  const char* startupStr;
499  const char* execProg;
501  const char* execArgs;
502 
507  WNDPROC DefWinProc;
509  bool fMenu;
511  int left, top;
513  int rows, cols;
514 }CHILDINFO;
517 
526 void* VCOnMiniGUI (void* data);
527 
528 #ifdef _MGRM_THREADS
529 void* NewVirtualConsole (PCHILDINFO pChildInfo);
530 #endif
531 
534 #endif /* _MGUTILS_VCONGUI */
535 
561 MGUTILS_EXPORT BOOL ShowCommonDialog (PDLGTEMPLATE dlg_template, HWND hwnd,
562  WNDPROC proc, void* private_data);
563 
564 #ifdef _MGUTILS_DLGOPENFILE
565 
566 #ifndef WIN32
567 #include <sys/types.h>
568 #include <dirent.h>
569 #endif
570 
575 #define FILE_ERROR_OK 0
576 
581 #define FILE_ERROR_PARAMERR -1
582 
587 #define FILE_ERROR_PATHNOTEXIST -2
588 
593 #define MAX_FILTER_LEN 255
594 
599 #define MY_NAMEMAX 127
600 
605 #define MY_PATHMAX 255
606 typedef struct _FILEDLGDATA
607 {
609  BOOL is_save;
610 
612  BOOL is_trans;
613 
615  char filefullname[MY_NAMEMAX + MY_PATHMAX + 1];
616 
618  char filename[MY_NAMEMAX + 1];
619 
621  char filepath[MY_PATHMAX + 1];
622 
627  char filter[MAX_FILTER_LEN + 1];
628 
630  int filterindex;
631 
632  WNDPROC hook;
633 } FILEDLGDATA, *PFILEDLGDATA;
634 
635 #define IDC_FOSD_BASE 520
636 #define IDC_FOSD_PATH_NOTE (IDC_FOSD_BASE + 1)
637 #define IDC_FOSD_PATH (IDC_FOSD_BASE + 2)
638 #define IDC_FOSD_UPPER (IDC_FOSD_BASE + 3)
639 #define IDC_FOSD_FILELIST (IDC_FOSD_BASE + 4)
640 #define IDC_FOSD_FILENAME_NOTE (IDC_FOSD_BASE + 5)
641 #define IDC_FOSD_FILENAME (IDC_FOSD_BASE + 6)
642 #define IDC_FOSD_FILETYPE_NOTE (IDC_FOSD_BASE + 7)
643 #define IDC_FOSD_FILETYPE (IDC_FOSD_BASE + 8)
644 #define IDC_FOSD_ISHIDE (IDC_FOSD_BASE + 9)
645 #define IDC_FOSD_OK (IDC_FOSD_BASE + 10)
646 #define IDC_FOSD_CANCEL (IDC_FOSD_BASE + 11)
647 
664 MGUTILS_EXPORT BOOL FileOpenSaveDialog (PDLGTEMPLATE dlg_template, HWND hwnd,
665  WNDPROC proc, PFILEDLGDATA pfdd);
666 
667 MGUTILS_EXPORT extern DLGTEMPLATE DefFileDlg;
668 MGUTILS_EXPORT extern DLGTEMPLATE DefSimpleFileDlg;
669 
671 MGUTILS_EXPORT LRESULT DefFileDialogProc (HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
672 
677 typedef struct _NEWFILEDLGDATA
678 {
680  BOOL IsSave;
682  BOOL IsTrans;
684  char filefullname[MY_NAMEMAX + MY_PATHMAX + 1];
686  char filename[MY_NAMEMAX + 1];
688  char filepath[MY_PATHMAX + 1];
693  char filter[MAX_FILTER_LEN + 1];
699 
724 MGUTILS_EXPORT int ShowOpenDialog (HWND hWnd, int lx, int ty,
725  int w, int h, PNEWFILEDLGDATA pnfdd);
726 
727 #endif /* _MGUTILS_DLGOPENFILE */
728 
729 #ifdef _MGUTILS_DLGCOLORSEL
730 
753 void RGB2HSV (Uint8 r, Uint8 g, Uint8 b,
754  Uint16 *hout, Uint8 *sout, Uint8 *vout);
755 
780 void HSV2RGB (Uint16 hin, Uint8 sin, Uint8 vin,
781  Uint8 *rout, Uint8 *gout, Uint8 *bout);
782 
804 void YUV2RGB (int y, int u, int v, Uint8 *r, Uint8 *g, Uint8 *b);
805 
823 MG_EXPORT void RGB2YUV (Uint8 r, Uint8 g, Uint8 b, int *y, int *u, int *v);
824 
825 typedef struct _COLORDLGDATA {
827  gal_pixel pixel;
828 
830  Uint8 r, g, b;
831 
833  Uint16 h;
834 
836  Uint8 s, v;
837 
839  BOOL is_trans;
840 
841  WNDPROC hook;
842 } COLORDLGDATA, *PCOLORDLGDATA;
843 
844 #define IDC_CSD_BASE 600
845 #define IDC_CSD_BASIC_COLOR_NOTE (IDC_CSD_BASE + 1)
846 #define IDC_CSD_BASIC_COLOR (IDC_CSD_BASE + 2)
847 #define IDC_CSD_BASIC_COLOR_0 (IDC_CSD_BASE + 2)
848 #define IDC_CSD_BASIC_COLOR_1 (IDC_CSD_BASE + 3)
849 #define IDC_CSD_BASIC_COLOR_2 (IDC_CSD_BASE + 4)
850 #define IDC_CSD_BASIC_COLOR_3 (IDC_CSD_BASE + 5)
851 #define IDC_CSD_BASIC_COLOR_4 (IDC_CSD_BASE + 6)
852 #define IDC_CSD_BASIC_COLOR_5 (IDC_CSD_BASE + 7)
853 #define IDC_CSD_BASIC_COLOR_6 (IDC_CSD_BASE + 8)
854 #define IDC_CSD_BASIC_COLOR_7 (IDC_CSD_BASE + 9)
855 #define IDC_CSD_BASIC_COLOR_8 (IDC_CSD_BASE + 10)
856 #define IDC_CSD_BASIC_COLOR_9 (IDC_CSD_BASE + 11)
857 #define IDC_CSD_BASIC_COLOR_10 (IDC_CSD_BASE + 12)
858 #define IDC_CSD_BASIC_COLOR_11 (IDC_CSD_BASE + 13)
859 #define IDC_CSD_BASIC_COLOR_12 (IDC_CSD_BASE + 14)
860 #define IDC_CSD_BASIC_COLOR_13 (IDC_CSD_BASE + 15)
861 #define IDC_CSD_BASIC_COLOR_14 (IDC_CSD_BASE + 16)
862 #define IDC_CSD_BASIC_COLOR_15 (IDC_CSD_BASE + 17)
863 #define IDC_CSD_BASIC_COLOR_16 (IDC_CSD_BASE + 18)
864 #define IDC_CSD_BASIC_COLOR_17 (IDC_CSD_BASE + 19)
865 #define IDC_CSD_BASIC_COLOR_18 (IDC_CSD_BASE + 20)
866 #define IDC_CSD_BASIC_COLOR_19 (IDC_CSD_BASE + 21)
867 #define IDC_CSD_BASIC_COLOR_20 (IDC_CSD_BASE + 22)
868 #define IDC_CSD_BASIC_COLOR_21 (IDC_CSD_BASE + 23)
869 #define IDC_CSD_BASIC_COLOR_22 (IDC_CSD_BASE + 24)
870 #define IDC_CSD_BASIC_COLOR_23 (IDC_CSD_BASE + 25)
871 #define IDC_CSD_BASIC_COLOR_24 (IDC_CSD_BASE + 26)
872 #define IDC_CSD_BASIC_COLOR_25 (IDC_CSD_BASE + 27)
873 #define IDC_CSD_BASIC_COLOR_26 (IDC_CSD_BASE + 28)
874 #define IDC_CSD_BASIC_COLOR_27 (IDC_CSD_BASE + 29)
875 #define IDC_CSD_BASIC_COLOR_28 (IDC_CSD_BASE + 30)
876 #define IDC_CSD_BASIC_COLOR_29 (IDC_CSD_BASE + 31)
877 #define IDC_CSD_CUSTOM_COLOR_NOTE (IDC_CSD_BASE + 32)
878 #define IDC_CSD_CUSTOM_COLOR_0 (IDC_CSD_BASE + 33)
879 #define IDC_CSD_CUSTOM (IDC_CSD_BASE + 33)
880 #define IDC_CSD_CUSTOM_COLOR_1 (IDC_CSD_BASE + 34)
881 #define IDC_CSD_CUSTOM_COLOR_2 (IDC_CSD_BASE + 35)
882 #define IDC_CSD_CUSTOM_COLOR_3 (IDC_CSD_BASE + 36)
883 #define IDC_CSD_CUSTOM_COLOR_4 (IDC_CSD_BASE + 37)
884 #define IDC_CSD_CUSTOM_COLOR_5 (IDC_CSD_BASE + 38)
885 #define IDC_CSD_SPACE (IDC_CSD_BASE + 39)
886 #define IDC_CSD_YSPACE (IDC_CSD_BASE + 40)
887 #define IDC_CSD_COLOR (IDC_CSD_BASE + 41)
888 #define IDC_CSD_NOTE_H (IDC_CSD_BASE + 42)
889 #define IDC_CSD_NOTE_S (IDC_CSD_BASE + 43)
890 #define IDC_CSD_NOTE_V (IDC_CSD_BASE + 44)
891 #define IDC_CSD_NOTE_R (IDC_CSD_BASE + 45)
892 #define IDC_CSD_NOTE_G (IDC_CSD_BASE + 46)
893 #define IDC_CSD_NOTE_B (IDC_CSD_BASE + 47)
894 #define IDC_CSD_VALUE_H (IDC_CSD_BASE + 48)
895 #define IDC_CSD_VALUE_S (IDC_CSD_BASE + 49)
896 #define IDC_CSD_VALUE_V (IDC_CSD_BASE + 50)
897 #define IDC_CSD_VALUE_R (IDC_CSD_BASE + 51)
898 #define IDC_CSD_VALUE_G (IDC_CSD_BASE + 52)
899 #define IDC_CSD_VALUE_B (IDC_CSD_BASE + 53)
900 #define IDC_CSD_ADD (IDC_CSD_BASE + 54)
901 #define IDC_CSD_OK (IDC_CSD_BASE + 55)
902 #define IDC_CSD_CANCEL (IDC_CSD_BASE + 56)
903 
920 MGUTILS_EXPORT BOOL ColorSelectDialog (PDLGTEMPLATE dlg_template, HWND hwnd,
921  WNDPROC proc, PCOLORDLGDATA pcdd);
922 
923 MGUTILS_EXPORT extern DLGTEMPLATE DefColorDlg;
924 MGUTILS_EXPORT extern DLGTEMPLATE DefSimpleColorDlg;
925 
927 MGUTILS_EXPORT LRESULT DefColorDialogProc (HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
928 
933 typedef struct _COLORDATA {
935  DWORD style;
937  gal_pixel pixel;
939  Uint8 r, g, b;
941  Uint16 h;
943  Uint8 s, v;
945  BOOL is_trans;
947 
948 /* Internal use */
949 #define SELCOLOR_OK IDOK
950 /* Internal use */
951 #define SELCOLOR_CANCEL IDCANCEL
952 
973 MGUTILS_EXPORT int ColorSelDialog (HWND hWnd, int x, int y,
974  int w, int h, PCOLORDATA pClrData);
975 
976 #endif /* _MGUTILS_DLGCOLORSEL */
977 
978 #ifdef _MGUTILS_DLGFONTSEL
979 
980 typedef struct _FONTDLGDATA {
981  /* The font minimize size. */
982  int min_size;
983  /* The font maximize size. */
984  int max_size;
985  /* Indicates the controls is transparent or no?*/
986  BOOL is_trans;
987 
988  /* The font color. */
989  RGB color;
990  PLOGFONT logfont;
991 
992  WNDPROC hook;
993 } FONTDLGDATA, *PFONTDLGDATA;
994 
995 #define IDC_FSD_BASE 540
996 #define IDC_FSD_FONT_NOTE (IDC_FSD_BASE + 1)
997 #define IDC_FSD_FONT (IDC_FSD_BASE + 2)
998 #define IDC_FSD_STYLE_NOTE (IDC_FSD_BASE + 3)
999 #define IDC_FSD_STYLE (IDC_FSD_BASE + 4)
1000 #define IDC_FSD_SIZE_NOTE (IDC_FSD_BASE + 5)
1001 #define IDC_FSD_SIZE (IDC_FSD_BASE + 6)
1002 #define IDC_FSD_EFFECTS_NOTE (IDC_FSD_BASE + 7)
1003 #define IDC_FSD_FLIP_NOTE (IDC_FSD_BASE + 8)
1004 #define IDC_FSD_FLIP (IDC_FSD_BASE + 9)
1005 #define IDC_FSD_COLOR_NOTE (IDC_FSD_BASE + 10)
1006 #define IDC_FSD_COLOR (IDC_FSD_BASE + 11)
1007 #define IDC_FSD_ITALIC (IDC_FSD_BASE + 12)
1008 #define IDC_FSD_STRIKEOUT (IDC_FSD_BASE + 13)
1009 #define IDC_FSD_UNDERLINE (IDC_FSD_BASE + 14)
1010 #define IDC_FSD_SAMPLE_NOTE (IDC_FSD_BASE + 15)
1011 #define IDC_FSD_SAMPLE (IDC_FSD_BASE + 16)
1012 #define IDC_FSD_CHARSET_NOTE (IDC_FSD_BASE + 17)
1013 #define IDC_FSD_CHARSET (IDC_FSD_BASE + 18)
1014 #define IDC_FSD_OK (IDC_FSD_BASE + 19)
1015 #define IDC_FSD_CANCEL (IDC_FSD_BASE + 20)
1016 
1033 MGUTILS_EXPORT BOOL FontSelectDialog (PDLGTEMPLATE dlg_template, HWND hwnd,
1034  WNDPROC proc, PFONTDLGDATA pfsd);
1035 
1036 MGUTILS_EXPORT extern DLGTEMPLATE DefSimpleFontDlg;
1037 MGUTILS_EXPORT extern DLGTEMPLATE DefFontDlg;
1038 
1040 MGUTILS_EXPORT LRESULT DefFontDialogProc (HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
1041 
1042 #endif /* _MGUTILS_DLGFONTSEL */
1043 
1044 #ifdef _MGUTILS_DLGSHOWINFO
1045 
1046 typedef struct _INFODLGDATA {
1047  const char* msg;
1048  WNDPROC hook;
1049 
1050  /* for internal usage.*/
1051  int nr_lines;
1052  int vis_lines;
1053  int start_line;
1054  RECT rc;
1055 } INFODLGDATA, *PINFODLGDATA;
1056 
1057 #define IDC_IFD_SPIN 580
1058 
1074 MGUTILS_EXPORT BOOL InfoShowDialog (PDLGTEMPLATE dlg_template, HWND hwnd,
1075  WNDPROC proc, PINFODLGDATA pidd);
1076 
1077 MGUTILS_EXPORT extern DLGTEMPLATE DefInfoDlg;
1078 MGUTILS_EXPORT extern DLGTEMPLATE DefSimpleInfoDlg;
1079 
1081 MGUTILS_EXPORT LRESULT DefInfoDialogProc (HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
1082 
1083 #endif /* _MGUTILS_DLGSHOWINFO */
1084 
1087 #ifdef _MGUTILS_SKIN
1088 
1095 /* skin messages (send to items) */
1096 #define SKIN_MSG_LBUTTONDOWN 1
1097 #define SKIN_MSG_LBUTTONUP 2
1098 #define SKIN_MSG_CLICK 3
1099 /*#define SKIN_MSG_DBCLICK 4 */
1100 #define SKIN_MSG_MOUSEMOVE 5
1101 #define SKIN_MSG_MOUSEDRAG 6
1102 #define SKIN_MSG_SETFOCUS 7
1103 #define SKIN_MSG_KILLFOCUS 8
1104 
1105 /* type of item */
1106 
1111 #define SI_TYPE_NRMLABEL 0x10000000
1112 
1117 #define SI_TYPE_BMPLABEL 0x20000000
1118 
1123 #define SI_TYPE_CMDBUTTON 0x30000000
1124 
1129 #define SI_TYPE_CHKBUTTON 0x40000000
1130 
1135 #define SI_TYPE_NRMSLIDER 0x50000000
1136 
1137 #ifdef _MGHAVE_FIXED_MATH
1138 
1142 #define SI_TYPE_ROTSLIDER 0x60000000
1143 #endif
1144 
1149 #define SI_TYPE_CONTROL 0x70000000
1150 
1155 #define SI_TYPE_MASK 0xF0000000
1156 
1157 /* type of hittest shape */
1158 
1163 #define SI_TEST_SHAPE_RECT 0x01000000
1164 
1169 #define SI_TEST_SHAPE_ELLIPSE 0x02000000
1170 
1175 #define SI_TEST_SHAPE_LOZENGE 0x03000000
1176 
1181 #define SI_TEST_SHAPE_LTRIANGLE 0x04000000
1182 
1187 #define SI_TEST_SHAPE_RTRIANGLE 0x05000000
1188 
1193 #define SI_TEST_SHAPE_UTRIANGLE 0x06000000
1194 
1199 #define SI_TEST_SHAPE_DTRIANGLE 0x07000000
1200 
1201 #define SI_TEST_SHAPE_MASK 0x0F000000
1202 
1203 /* common status of item */
1204 
1209 #define SI_STATUS_OK 0x00000001
1210 
1215 #define SI_STATUS_VISIBLE 0x00000002
1216 
1221 #define SI_STATUS_DISABLED 0x00000004
1222 
1227 #define SI_STATUS_HILIGHTED 0x00000008
1228 
1229 #define SI_STATUS_MASK 0x0000000F
1230 
1231 /* status of button item */
1232 
1237 #define SI_BTNSTATUS_CLICKED 0x00000010
1238 
1243 #define SI_BTNSTATUS_CHECKED SI_BTNSTATUS_CLICKED
1244 
1245 #define SI_STATUS_CLICKED SI_BTNSTATUS_CLICKED
1246 
1247 #define SI_BTNSTATUS_MASK 0x000000F0
1248 
1250 #define SI_CMDBUTTON_2STATE 0x00000100
1251 
1252 /* style of normal slider item */
1253 
1258 #define SI_NRMSLIDER_HORZ 0x00000100
1259 
1264 #define SI_NRMSLIDER_VERT 0x00000200
1265 
1270 #define SI_NRMSLIDER_STATIC 0x00000400
1271 
1272 #ifdef _MGHAVE_FIXED_MATH
1273 
1274 /* style of rotation slider item */
1275 
1280 #define SI_ROTSLIDER_CW 0x00000100
1281 
1286 #define SI_ROTSLIDER_ANTICW 0x00000200
1287 
1292 #define SI_ROTSLIDER_STATIC 0x00000400
1293 
1294 #endif /* _MGHAVE_FIXED_MATH */
1295 
1296 #define SI_STYLE_MASK 0x0000FF00
1297 
1302 #define CTRL_SKIN "skin"
1303 
1309 
1314 typedef struct skin_head_s skin_head_t;
1315 
1317 typedef struct skin_item_s
1318 {
1320  int id;
1321 
1400  DWORD style;
1401 
1403  int x;
1405  int y;
1406 
1408  RECT item_rc;
1409 
1410  union {
1413 
1415  HWND hwnd;
1416  };
1417 
1419  char* tip;
1420 
1422  DWORD attached;
1423 
1428  void* type_data;
1429 
1430  /******** start of internal fields ********/
1431  /* The bounding rectangle of the item. */
1432  RECT shape;
1433  /* The hit-test rectangle of the item. */
1434  RECT rc_hittest;
1435  /* The region for mouse hittest. */
1436  CLIPRGN region;
1437  /* The operation routines of the item. */
1438  skin_item_ops_t *ops;
1439  /* The parent skin. */
1440  skin_head_t *hostskin;
1441 } skin_item_t;
1442 
1445 {
1447  int (*init) (skin_head_t*, skin_item_t*);
1449  int (*deinit) (skin_item_t*);
1450 
1452  int (*on_create) (skin_item_t*);
1454  int (*on_destroy) (skin_item_t*);
1455 
1457  void (*draw_bg) (HDC, skin_item_t*);
1459  void (*draw_attached) (HDC, skin_item_t*);
1460 
1468  DWORD (*get_value) (skin_item_t *item);
1476  DWORD (*set_value) (skin_item_t *item, DWORD status);
1477 
1479  int (*item_msg_proc) (skin_item_t* item, int message,
1480  WPARAM wparam, LPARAM lparam);
1481 };
1482 
1484 typedef struct sie_slider_s
1485 {
1487  int min_pos;
1489  int max_pos;
1491  int cur_pos;
1492 } sie_slider_t;
1493 
1495 typedef struct si_nrmlabel_s
1496 {
1498  char* label;
1499 
1501  DWORD color;
1503  DWORD color_focus;
1505  DWORD color_click;
1508 } si_nrmlabel_t;
1509 
1511 typedef struct si_bmplabel_s
1512 {
1514  char* label;
1516  const char* label_chars;
1517 } si_bmplabel_t;
1518 
1520 typedef struct si_nrmslider_s
1521 {
1524 
1527 } si_nrmslider_t;
1528 
1529 #ifdef _MGHAVE_FIXED_MATH
1530 
1532 typedef struct si_rotslider_s
1533 {
1535  int radius;
1539  int end_deg;
1541  int cur_pos;
1542 
1545 } si_rotslider_t;
1546 
1547 #endif /* _MGHAVE_FIXED_MATH */
1548 
1553 #define SIE_BUTTON_CLICKED 0x00000001
1554 
1559 #define SIE_SLIDER_CHANGED 0x00000002
1560 
1565 #define SIE_GAIN_FOCUS 0x00010000
1566 
1571 #define SIE_LOST_FOCUS 0x00020000
1572 
1590 typedef int (* skin_event_cb_t) (HWND hwnd, skin_item_t* item,
1591  int event, void* data);
1596 #define MSG_CB_GOON 0
1597 
1602 #define MSG_CB_DEF_GOON 1
1603 
1608 #define MSG_CB_STOP 2
1609 
1635 typedef int (* skin_msg_cb_t) (HWND hwnd, int message,
1636  WPARAM wparam, LPARAM lparam, int* result);
1637 
1642 #define SKIN_STYLE_NONE 0x00000000
1643 
1648 #define SKIN_STYLE_TOOLTIP 0x00000001
1649 
1654 #define SKIN_STYLE_MODAL 0x00000002
1655 
1658 {
1660  char* name;
1661 
1667  DWORD style;
1668 
1670  const BITMAP* bmps;
1672  const LOGFONT* fonts;
1673 
1676 
1681 
1683  DWORD attached;
1684 
1685  /******** start of internal fields ********/
1686 
1687  /* The event callback function of the skin. */
1688  skin_event_cb_t event_cb;
1689 
1690  /* The window message procedure of the skin window. */
1691  skin_msg_cb_t msg_cb;
1692 
1693  /**** The fields initialized when skin_init called. ****/
1694  /* The rectangle heap for hit-test regions. */
1695  BLOCKHEAP rc_heap;
1696 
1697  /****
1698  * The fields initialized when create_skin_main_window or
1699  * create_skin_control called.
1700  ****/
1701  /* The handle of window in which the skin locates. */
1702  HWND hwnd;
1703  /* The handle of tool tip window. */
1704  HWND tool_tip;
1705 
1706  /* The old x and y. */
1707  int oldx, oldy;
1708  /* The current hilighted item. */
1709  skin_item_t* hilighted;
1710 
1711  /* cached identifier. */
1712  int cached_id;
1713  /* the item whose identifier is cached_id. */
1714  skin_item_t* cached_item;
1715 };
1716 
1735 MGUTILS_EXPORT BOOL skin_init (skin_head_t* skin,
1736  skin_event_cb_t event_cb, skin_msg_cb_t msg_cb);
1737 
1748 MGUTILS_EXPORT void skin_deinit (skin_head_t* skin);
1749 
1777 MGUTILS_EXPORT HWND create_skin_main_window_ex (skin_head_t* skin, HWND hosting,
1778  int lx, int ty, int rx, int by, DWORD dwExStyle, BOOL modal);
1783 #define create_skin_main_window(skin, hosting, lx, ty, rx, by, modal) \
1784  create_skin_main_window_ex (skin, hosting, lx, ty, rx, by, 0, modal)
1785 
1817 MGUTILS_EXPORT HWND create_skin_control (skin_head_t* skin, HWND parent,
1818  int id, int x, int y, int w, int h);
1819 
1833 MGUTILS_EXPORT BOOL is_skin_main_window (HWND hwnd);
1834 
1845 MGUTILS_EXPORT void destroy_skin_window (HWND hwnd);
1846 
1861 MGUTILS_EXPORT skin_head_t* set_window_skin (HWND hwnd, skin_head_t *new_skin);
1862 
1875 MGUTILS_EXPORT skin_head_t* get_window_skin (HWND hwnd);
1876 
1892  skin_event_cb_t event_cb)
1893 {
1894  skin_event_cb_t old = skin->event_cb;
1895  skin->event_cb = event_cb;
1896  return old;
1897 }
1898 
1914  skin_msg_cb_t msg_cb)
1915 {
1916  skin_msg_cb_t old = skin->msg_cb;
1917  skin->msg_cb = msg_cb;
1918  return old;
1919 }
1920 
1934 MGUTILS_EXPORT skin_item_t* skin_get_item (skin_head_t* skin, int id);
1935 
1949 MGUTILS_EXPORT DWORD skin_get_item_status (skin_head_t* skin, int id);
1950 
1965 MGUTILS_EXPORT DWORD skin_set_item_status (skin_head_t* skin, int id, DWORD status);
1966 
1977 MGUTILS_EXPORT skin_item_t* skin_get_hilited_item (skin_head_t* skin);
1978 
1993 MGUTILS_EXPORT DWORD skin_show_item (skin_head_t* skin, int id, BOOL show);
1994 
2008 MGUTILS_EXPORT DWORD skin_enable_item (skin_head_t* skin, int id, BOOL enable);
2009 
2023 MGUTILS_EXPORT skin_item_t* skin_set_hilited_item (skin_head_t* skin, int id);
2024 
2039 MGUTILS_EXPORT BOOL skin_get_check_status (skin_head_t* skin, int id);
2040 
2056 MGUTILS_EXPORT DWORD skin_set_check_status (skin_head_t* skin,
2057  int id, BOOL check);
2058 
2074 MGUTILS_EXPORT const char* skin_get_item_label (skin_head_t* skin, int id);
2075 
2092 MGUTILS_EXPORT BOOL skin_set_item_label (skin_head_t* skin,
2093  int id, const char* label);
2094 
2109 MGUTILS_EXPORT HWND skin_get_control_hwnd (skin_head_t* skin, int id);
2110 
2124 MGUTILS_EXPORT int skin_get_thumb_pos (skin_head_t* skin, int id);
2125 
2142 MGUTILS_EXPORT BOOL skin_set_thumb_pos (skin_head_t* skin, int id, int pos);
2143 
2161 MGUTILS_EXPORT BOOL skin_get_slider_info (skin_head_t* skin,
2162  int id, sie_slider_t* sie);
2163 
2179 MGUTILS_EXPORT BOOL skin_set_slider_info (skin_head_t* skin,
2180  int id, const sie_slider_t* sie);
2181 
2200 MGUTILS_EXPORT int skin_scale_slider_pos (const sie_slider_t* org,
2201  int new_min, int new_max);
2202 
2205 #endif /* _MGUTILS_SKIN */
2206 
2207 #ifdef __cplusplus
2208 }
2209 #endif
2210 
2211 #endif /* _MGUTILS_H */
MG_EXPORT void RGB2YUV(Uint8 r, Uint8 g, Uint8 b, int *y, int *u, int *v)
Converts r/g/b values of a color in RGB color space to y/u/v values of the color in YUV color space...
MGUTILS_EXPORT int ShowOpenDialog(HWND hWnd, int lx, int ty, int w, int h, PNEWFILEDLGDATA pnfdd)
Creates an Open File Dialog Box.
RECT item_rc
Definition: mgutils.h:1408
int font_index
Definition: mgutils.h:1507
MGUTILS_EXPORT int myWinTernary(HWND hwnd, const char *title, const char *button1, const char *button2, const char *button3, const char *text,...)
Creates a message box within three buttons.
MGUTILS_EXPORT HWND createProgressWin(HWND hParentWnd, const char *title, const char *label, int id, int range)
Creates a main window within a progress bar.
struct si_nrmslider_s si_nrmslider_t
MGUTILS_EXPORT BOOL skin_set_thumb_pos(skin_head_t *skin, int id, int pos)
Sets the thumb position of a slider item.
struct si_rotslider_s si_rotslider_t
MGUTILS_EXPORT LRESULT DefFontDialogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
MGUTILS_EXPORT BOOL FontSelectDialog(PDLGTEMPLATE dlg_template, HWND hwnd, WNDPROC proc, PFONTDLGDATA pfsd)
MGUTILS_EXPORT void destroyProgressWin(HWND hwnd)
Destroies progress window.
int rows
Definition: mgutils.h:513
Uint16 h
Definition: mgutils.h:941
MGUTILS_EXPORT int ColorSelDialog(HWND hWnd, int x, int y, int w, int h, PCOLORDATA pClrData)
Creates a Color Selection Dialog Box.
int thumb_bmp_index
Definition: mgutils.h:1544
DWORD flags
Definition: mgutils.h:390
bool startupMessage
Definition: mgutils.h:492
int(* skin_msg_cb_t)(HWND hwnd, int message, WPARAM wparam, LPARAM lparam, int *result)
Definition: mgutils.h:1635
DWORD color
Definition: mgutils.h:1501
int maxlen
Definition: mgutils.h:388
int(* skin_event_cb_t)(HWND hwnd, skin_item_t *item, int event, void *data)
Definition: mgutils.h:1590
MGUTILS_EXPORT BOOL is_skin_main_window(HWND hwnd)
Determines whether a window is a skin main window or not.
MGUTILS_EXPORT int myWinChoice(HWND hwnd, const char *title, const char *button1, const char *button2, const char *text,...)
Creates a message box within two buttons.
char ** value
Definition: mgutils.h:386
MGUTILS_EXPORT LRESULT DefInfoDialogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
char * text
Definition: mgutils.h:323
MGUTILS_EXPORT skin_item_t * skin_set_hilited_item(skin_head_t *skin, int id)
Sets the current highlighted skin item.
struct _COLORDATA COLORDATA
MGUTILS_EXPORT BOOL skin_init(skin_head_t *skin, skin_event_cb_t event_cb, skin_msg_cb_t msg_cb)
Initializes a skin.
MGUTILS_EXPORT int skin_scale_slider_pos(const sie_slider_t *org, int new_min, int new_max)
Scales the sliding position.
char * label
Definition: mgutils.h:1514
MGUTILS_EXPORT int myWinEntries(HWND hParentWnd, const char *title, const char *label, int width, int editboxwidth, BOOL fIME, myWINENTRY *items, myWINBUTTON *buttons)
Creates a entry main window for the user to enter something.
WNDPROC DefWinProc
Definition: mgutils.h:507
MGUTILS_EXPORT void destroy_skin_window(HWND hwnd)
Destroys a skin window.
MGUTILS_EXPORT LRESULT DefFileDialogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
MGUTILS_EXPORT BOOL skin_get_slider_info(skin_head_t *skin, int id, sie_slider_t *sie)
Retrives the sliding information of a slider item.
char * name
Definition: mgutils.h:1660
int nr_items
Definition: mgutils.h:1678
struct _myWinButton myWINBUTTON
DWORD style
Definition: mgutils.h:935
struct sie_slider_s sie_slider_t
DWORD style
Definition: mgutils.h:1400
MGUTILS_EXPORT BOOL FileOpenSaveDialog(PDLGTEMPLATE dlg_template, HWND hwnd, WNDPROC proc, PFILEDLGDATA pfdd)
const char * execProg
Definition: mgutils.h:499
struct _NEWFILEDLGDATA NEWFILEDLGDATA
MGUTILS_EXPORT int myWinMessage(HWND hwnd, const char *title, const char *button1, const char *text,...)
Creates a message box within only one button.
const char * label_chars
Definition: mgutils.h:1516
Uint8 r
Definition: mgutils.h:939
static skin_event_cb_t skin_set_event_cb(skin_head_t *skin, skin_event_cb_t event_cb)
Sets new event callback of a skin.
Definition: mgutils.h:1891
MGUTILS_EXPORT DWORD skin_get_item_status(skin_head_t *skin, int id)
Retrives the common status of a skin item.
int left
Definition: mgutils.h:511
const BITMAP * bmps
Definition: mgutils.h:1670
MGUTILS_EXPORT void skin_deinit(skin_head_t *skin)
Deinitializes an initialized skin.
MGUTILS_EXPORT HWND create_skin_main_window_ex(skin_head_t *skin, HWND hosting, int lx, int ty, int rx, int by, DWORD dwExStyle, BOOL modal)
Creates a main window for a skin.
void HSV2RGB(Uint16 hin, Uint8 sin, Uint8 vin, Uint8 *rout, Uint8 *gout, Uint8 *bout)
Converts h/s/v values of a color to r/g/b values of the color.
MGUTILS_EXPORT BOOL ShowCommonDialog(PDLGTEMPLATE dlg_template, HWND hwnd, WNDPROC proc, void *private_data)
MGUTILS_EXPORT int myMessageBox(HWND hwnd, DWORD dwStyle, const char *title, const char *text,...)
Creates a message box.
Uint8 s
Definition: mgutils.h:943
DWORD attached
Definition: mgutils.h:1683
DWORD style
Definition: mgutils.h:1667
MGUTILS_EXPORT HWND createStatusWin(HWND hParentWnd, int width, int height, const char *title, const char *text,...)
Creates a status main window.
MGUTILS_EXPORT int myWinMenu(HWND hParentWnd, const char *title, const char *label, int width, int listboxheight, char **items, int *listItem, myWINBUTTON *buttons)
Creates a menu main window for the user to select an item.
MGUTILS_EXPORT void destroyStatusWin(HWND hwnd)
Destroies a status window.
struct skin_item_s skin_item_t
char * text
Definition: mgutils.h:384
MGUTILS_EXPORT int myWinHelpMessage(HWND hwnd, int width, int height, const char *help_title, const char *help_msg)
Creates a help message window.
struct _CHILDINFO CHILDINFO
int bmp_index
Definition: mgutils.h:1412
MGUTILS_EXPORT skin_item_t * skin_get_hilited_item(skin_head_t *skin)
Gets the current highlighted skin item.
HWND hwnd
Definition: mgutils.h:1415
MGUTILS_EXPORT DWORD skin_set_item_status(skin_head_t *skin, int id, DWORD status)
Set the common status of a skin item.
static skin_msg_cb_t skin_set_msg_cb(skin_head_t *skin, skin_msg_cb_t msg_cb)
Sets new message callback of a skin window.
Definition: mgutils.h:1913
BOOL is_trans
Definition: mgutils.h:945
skin_item_t * items
Definition: mgutils.h:1680
NEWFILEDLGDATA * PNEWFILEDLGDATA
Definition: mgutils.h:698
const char * startupStr
Definition: mgutils.h:494
#define MAX_FILTER_LEN
The maximum length of filter string.
Definition: mgutils.h:593
MGUTILS_EXPORT HWND create_skin_control(skin_head_t *skin, HWND parent, int id, int x, int y, int w, int h)
Creates a control for a skin.
bool fMenu
Definition: mgutils.h:509
gal_pixel pixel
Definition: mgutils.h:937
#define MY_PATHMAX
The maximum length of path.
Definition: mgutils.h:605
const LOGFONT * fonts
Definition: mgutils.h:1672
DWORD flags
Definition: mgutils.h:327
void RGB2HSV(Uint8 r, Uint8 g, Uint8 b, Uint16 *hout, Uint8 *sout, Uint8 *vout)
Converts r/g/b values of a color in RGB color space to h/s/v of the color in HSV color space...
DWORD color_focus
Definition: mgutils.h:1503
MGUTILS_EXPORT HWND skin_get_control_hwnd(skin_head_t *skin, int id)
Gets the handle to a skin control item in the skin.
MGUTILS_EXPORT skin_head_t * get_window_skin(HWND hwnd)
Gets new skin.
MGUTILS_EXPORT LRESULT DefColorDialogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
MGUTILS_EXPORT BOOL skin_set_slider_info(skin_head_t *skin, int id, const sie_slider_t *sie)
Sets the sliding information of a slider item.
MGUTILS_EXPORT void errorWindow(HWND hwnd, const char *str, const char *title)
A MiniGUI edition of perror.
MGUTILS_EXPORT BOOL InfoShowDialog(PDLGTEMPLATE dlg_template, HWND hwnd, WNDPROC proc, PINFODLGDATA pidd)
CHILDINFO * PCHILDINFO
Definition: mgutils.h:516
MGUTILS_EXPORT BOOL skin_get_check_status(skin_head_t *skin, int id)
Gets the check status of a check button item.
MGUTILS_EXPORT skin_item_t * skin_get_item(skin_head_t *skin, int id)
Retrives a skin item through its identifier.
MGUTILS_EXPORT DWORD skin_show_item(skin_head_t *skin, int id, BOOL show)
Showes or hides a skin item.
void YUV2RGB(int y, int u, int v, Uint8 *r, Uint8 *g, Uint8 *b)
Converts y/u/v values of a color in YUV color space to to r/g/b values of the color in RGB color spac...
struct _myWinEntry myWINENTRY
MGUTILS_EXPORT skin_head_t * set_window_skin(HWND hwnd, skin_head_t *new_skin)
Sets new skin.
int thumb_bmp_index
Definition: mgutils.h:1526
char * label
Definition: mgutils.h:1498
MGUTILS_EXPORT BOOL skin_set_item_label(skin_head_t *skin, int id, const char *label)
Sets the label string of a label item.
void * VCOnMiniGUI(void *data)
Creates a vcongui main window.
struct si_nrmlabel_s si_nrmlabel_t
char * tip
Definition: mgutils.h:1419
MGUTILS_EXPORT DWORD skin_set_check_status(skin_head_t *skin, int id, BOOL check)
Sets the check status of a check button item.
int bk_bmp_index
Definition: mgutils.h:1675
MGUTILS_EXPORT DWORD skin_enable_item(skin_head_t *skin, int id, BOOL enable)
Enables or disables a skin item.
const char * execArgs
Definition: mgutils.h:501
struct si_bmplabel_s si_bmplabel_t
MGUTILS_EXPORT const char * skin_get_item_label(skin_head_t *skin, int id)
Gets the label string of a label item.
DWORD color_click
Definition: mgutils.h:1505
sie_slider_t slider_info
Definition: mgutils.h:1523
void * type_data
Definition: mgutils.h:1428
MGUTILS_EXPORT BOOL ColorSelectDialog(PDLGTEMPLATE dlg_template, HWND hwnd, WNDPROC proc, PCOLORDLGDATA pcdd)
#define MY_NAMEMAX
The maximum length of name.
Definition: mgutils.h:599
DWORD attached
Definition: mgutils.h:1422
MGUTILS_EXPORT int skin_get_thumb_pos(skin_head_t *skin, int id)
Gets the thumb position of a slider item.