mGUtils API Reference  v1.2.0
A component of MiniGUI providing users with a number of common dialog templates
mgutils.h
Go to the documentation of this file.
1 
42 /*
43  * $Id: mgutils.h 231 2017-10-26 07:25:36Z weiym $
44  *
45  * mGUtils: A MiniGUI component which contains miscellaneous
46  * utilities like ColorSelectionDialogBox, FileOpenDialogBox, and so on.
47  *
48  */
49 
50 #ifndef _MGUTILS_H
51 #define _MGUTILS_H
52 
53 #ifdef __cplusplus
54 extern "C" {
55 #endif
56 
57 #if !defined(__NODLL__) && (defined (WIN32) || defined (__NUCLEUS_MNT__))
58  #ifdef __MGUTILS_LIB__
59  #define MGUTILS_EXPORT __declspec(dllexport)
60  #else
61  #define MGUTILS_EXPORT __declspec(dllimport)
62  #endif
63 #elif defined(__NODLL__) && defined(WIN32)
64  #define MGUTILS_EXPORT __declspec(dllimport)
65 #else
66  #define MGUTILS_EXPORT
67 #endif
68 
69 #ifndef MGUTILS_MAJOR_VERSION
70 # undef PACKAGE
71 # undef VERSION
72 # undef PACKAGE_BUGREPORT
73 # undef PACKAGE_NAME
74 # undef PACKAGE_STRING
75 # undef PACKAGE_TARNAME
76 # undef PACKAGE_VERSION
77 # ifdef __MGUTILS_LIB__
78 # include "../mgutilsconfig.h"
79 # else
80 # include "mgutilsconfig.h"
81 # endif
82 #endif
83 
84 #define MGUTILS_MSG_BASE MSG_USER + 0x40
85 #define MSG_FILESELOK (MGUTILS_MSG_BASE + 1)
86 #define MSG_FILESELCANCEL (MGUTILS_MSG_BASE + 2)
87 #define MSG_COLORSELOK (MGUTILS_MSG_BASE + 3)
88 #define MSG_COLORSELCANCEL (MGUTILS_MSG_BASE + 4)
89 #define MSG_FONTSELOK (MGUTILS_MSG_BASE + 5)
90 #define MSG_FONTSELCANCEL (MGUTILS_MSG_BASE + 6)
91 
92 #ifdef _MGUTILS_MYWINS
93 
121 MGUTILS_EXPORT int myMessageBox (HWND hwnd, DWORD dwStyle, const char* title,
122  const char* text, ...);
123 
145 MGUTILS_EXPORT int myWinMessage (HWND hwnd, const char* title,
146  const char* button1, const char* text, ...);
147 
173 MGUTILS_EXPORT int myWinChoice (HWND hwnd, const char* title,
174  const char* button1, const char* button2,
175  const char* text, ...);
176 
203 MGUTILS_EXPORT int myWinTernary (HWND hwnd, const char* title,
204  const char* button1, const char* button2, const char* button3,
205  const char* text, ...);
206 
221 MGUTILS_EXPORT void errorWindow (HWND hwnd, const char* str, const char* title);
222 
242 MGUTILS_EXPORT HWND createStatusWin (HWND hParentWnd, int width, int height,
243  const char* title, const char* text, ...);
244 
256 MGUTILS_EXPORT void destroyStatusWin (HWND hwnd);
257 
258 /* back-compatibility definitions */
259 #define createToolTipWin CreateToolTipWin
260 #define resetToolTipWin ResetToolTipWin
261 #define destroyToolTipWin DestroyToolTipWin
262 
263 #ifdef _MGCTRL_PROGRESSBAR
264 
286 MGUTILS_EXPORT HWND createProgressWin (HWND hParentWnd, const char* title,
287  const char* label, int id, int range);
288 
300 MGUTILS_EXPORT void destroyProgressWin (HWND hwnd);
301 
302 #endif /* _MGCTRL_PROGRESSBAR */
303 
308 typedef struct _myWinButton
309 {
311  char* text;
313  int id;
315  DWORD flags;
316 } myWINBUTTON;
317 
318 /* This is an internal structure. */
319 typedef struct _myWinMenuItems
320 {
321  /* The pointer to the array of the item strings. */
322  char** items;
323  /* The identifier of the listbox display the menu items. */
324  int listboxid;
325  /* The pointer to the array of the selection status of the items. */
326  int* selected;
327  /* The minimal button identifier. */
328  int minbuttonid;
329  /* The maximal button identifier. */
330  int maxbuttonid;
331 } myWINMENUITEMS;
332 
361 MGUTILS_EXPORT int myWinMenu (HWND hParentWnd, const char* title,
362  const char* label, int width, int listboxheight,
363  char ** items, int * listItem, myWINBUTTON* buttons);
364 
369 typedef struct _myWinEntry
370 {
372  char* text;
374  char** value;
376  int maxlen;
378  DWORD flags;
379 } myWINENTRY;
380 
381 /* This is an internal structure. */
382 typedef struct _myWinEntryItems
383 {
384  myWINENTRY* entries;
385  int entrycount;
386  int firstentryid;
387  int minbuttonid;
388  int maxbuttonid;
389 } myWINENTRYITEMS;
390 
418 MGUTILS_EXPORT int myWinEntries (HWND hParentWnd, const char* title,
419  const char* label, int width, int editboxwidth,
420  BOOL fIME, myWINENTRY* items, myWINBUTTON* buttons);
421 
439 MGUTILS_EXPORT int myWinHelpMessage (HWND hwnd, int width, int height,
440  const char* help_title, const char* help_msg);
441 
444 #endif /* _MGUTILS_MYWINS */
445 
446 #ifdef _MGUTILS_VCONGUI
447 
456 #ifndef __cplusplus
457 #ifndef __ECOS__
458 typedef enum {false, true} bool;
459 #endif
460 #endif
461 
462 #define VCONGUI_VERSION "Version 0.8 (Feb. 2018)"
463 
464 #define MIN_COLS 10
465 #define MAX_COLS 100
466 #define MIN_ROWS 10
467 #define MAX_ROWS 60
468 
469 #define GetCharWidth GetSysCharWidth
470 #define GetCCharWidth GetSysCCharWidth
471 #define GetCharHeight GetSysCharHeight
472 
477 typedef struct _CHILDINFO
478 {
482  const char* startupStr;
487  const char* execProg;
489  const char* execArgs;
490 
495  WNDPROC DefWinProc;
497  bool fMenu;
499  int left, top;
501  int rows, cols;
502 }CHILDINFO;
505 
514 void* VCOnMiniGUI (void* data);
515 
516 #ifdef _MGRM_THREADS
517 void* NewVirtualConsole (PCHILDINFO pChildInfo);
518 #endif
519 
522 #endif /* _MGUTILS_VCONGUI */
523 
549 MGUTILS_EXPORT BOOL ShowCommonDialog (PDLGTEMPLATE dlg_template, HWND hwnd,
550  WNDPROC proc, void* private_data);
551 
552 #ifdef _MGUTILS_DLGOPENFILE
553 
554 #ifndef WIN32
555 #include <sys/types.h>
556 #include <dirent.h>
557 #endif
558 
563 #define FILE_ERROR_OK 0
564 
569 #define FILE_ERROR_PARAMERR -1
570 
575 #define FILE_ERROR_PATHNOTEXIST -2
576 
581 #define MAX_FILTER_LEN 255
582 
587 #define MY_NAMEMAX 127
588 
593 #define MY_PATHMAX 255
594 typedef struct _FILEDLGDATA
595 {
597  BOOL is_save;
598 
600  BOOL is_trans;
601 
603  char filefullname[MY_NAMEMAX + MY_PATHMAX + 1];
604 
606  char filename[MY_NAMEMAX + 1];
607 
609  char filepath[MY_PATHMAX + 1];
610 
615  char filter[MAX_FILTER_LEN + 1];
616 
618  int filterindex;
619 
620  WNDPROC hook;
621 } FILEDLGDATA, *PFILEDLGDATA;
622 
623 #define IDC_FOSD_BASE 520
624 #define IDC_FOSD_PATH_NOTE (IDC_FOSD_BASE + 1)
625 #define IDC_FOSD_PATH (IDC_FOSD_BASE + 2)
626 #define IDC_FOSD_UPPER (IDC_FOSD_BASE + 3)
627 #define IDC_FOSD_FILELIST (IDC_FOSD_BASE + 4)
628 #define IDC_FOSD_FILENAME_NOTE (IDC_FOSD_BASE + 5)
629 #define IDC_FOSD_FILENAME (IDC_FOSD_BASE + 6)
630 #define IDC_FOSD_FILETYPE_NOTE (IDC_FOSD_BASE + 7)
631 #define IDC_FOSD_FILETYPE (IDC_FOSD_BASE + 8)
632 #define IDC_FOSD_ISHIDE (IDC_FOSD_BASE + 9)
633 #define IDC_FOSD_OK (IDC_FOSD_BASE + 10)
634 #define IDC_FOSD_CANCEL (IDC_FOSD_BASE + 11)
635 
652 MGUTILS_EXPORT BOOL FileOpenSaveDialog (PDLGTEMPLATE dlg_template, HWND hwnd,
653  WNDPROC proc, PFILEDLGDATA pfdd);
654 
655 MGUTILS_EXPORT extern DLGTEMPLATE DefFileDlg;
656 MGUTILS_EXPORT extern DLGTEMPLATE DefSimpleFileDlg;
657 
659 MGUTILS_EXPORT LRESULT DefFileDialogProc (HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
660 
665 typedef struct _NEWFILEDLGDATA
666 {
668  BOOL IsSave;
670  BOOL IsTrans;
672  char filefullname[MY_NAMEMAX + MY_PATHMAX + 1];
674  char filename[MY_NAMEMAX + 1];
676  char filepath[MY_PATHMAX + 1];
681  char filter[MAX_FILTER_LEN + 1];
687 
712 MGUTILS_EXPORT int ShowOpenDialog (HWND hWnd, int lx, int ty,
713  int w, int h, PNEWFILEDLGDATA pnfdd);
714 
715 #endif /* _MGUTILS_DLGOPENFILE */
716 
717 #ifdef _MGUTILS_DLGCOLORSEL
718 
741 void RGB2HSV (Uint8 r, Uint8 g, Uint8 b,
742  Uint16 *hout, Uint8 *sout, Uint8 *vout);
743 
768 void HSV2RGB (Uint16 hin, Uint8 sin, Uint8 vin,
769  Uint8 *rout, Uint8 *gout, Uint8 *bout);
770 
792 void YUV2RGB (int y, int u, int v, Uint8 *r, Uint8 *g, Uint8 *b);
793 
811 MG_EXPORT void RGB2YUV (Uint8 r, Uint8 g, Uint8 b, int *y, int *u, int *v);
812 
813 typedef struct _COLORDLGDATA {
815  gal_pixel pixel;
816 
818  Uint8 r, g, b;
819 
821  Uint16 h;
822 
824  Uint8 s, v;
825 
827  BOOL is_trans;
828 
829  WNDPROC hook;
830 } COLORDLGDATA, *PCOLORDLGDATA;
831 
832 #define IDC_CSD_BASE 600
833 #define IDC_CSD_BASIC_COLOR_NOTE (IDC_CSD_BASE + 1)
834 #define IDC_CSD_BASIC_COLOR (IDC_CSD_BASE + 2)
835 #define IDC_CSD_BASIC_COLOR_0 (IDC_CSD_BASE + 2)
836 #define IDC_CSD_BASIC_COLOR_1 (IDC_CSD_BASE + 3)
837 #define IDC_CSD_BASIC_COLOR_2 (IDC_CSD_BASE + 4)
838 #define IDC_CSD_BASIC_COLOR_3 (IDC_CSD_BASE + 5)
839 #define IDC_CSD_BASIC_COLOR_4 (IDC_CSD_BASE + 6)
840 #define IDC_CSD_BASIC_COLOR_5 (IDC_CSD_BASE + 7)
841 #define IDC_CSD_BASIC_COLOR_6 (IDC_CSD_BASE + 8)
842 #define IDC_CSD_BASIC_COLOR_7 (IDC_CSD_BASE + 9)
843 #define IDC_CSD_BASIC_COLOR_8 (IDC_CSD_BASE + 10)
844 #define IDC_CSD_BASIC_COLOR_9 (IDC_CSD_BASE + 11)
845 #define IDC_CSD_BASIC_COLOR_10 (IDC_CSD_BASE + 12)
846 #define IDC_CSD_BASIC_COLOR_11 (IDC_CSD_BASE + 13)
847 #define IDC_CSD_BASIC_COLOR_12 (IDC_CSD_BASE + 14)
848 #define IDC_CSD_BASIC_COLOR_13 (IDC_CSD_BASE + 15)
849 #define IDC_CSD_BASIC_COLOR_14 (IDC_CSD_BASE + 16)
850 #define IDC_CSD_BASIC_COLOR_15 (IDC_CSD_BASE + 17)
851 #define IDC_CSD_BASIC_COLOR_16 (IDC_CSD_BASE + 18)
852 #define IDC_CSD_BASIC_COLOR_17 (IDC_CSD_BASE + 19)
853 #define IDC_CSD_BASIC_COLOR_18 (IDC_CSD_BASE + 20)
854 #define IDC_CSD_BASIC_COLOR_19 (IDC_CSD_BASE + 21)
855 #define IDC_CSD_BASIC_COLOR_20 (IDC_CSD_BASE + 22)
856 #define IDC_CSD_BASIC_COLOR_21 (IDC_CSD_BASE + 23)
857 #define IDC_CSD_BASIC_COLOR_22 (IDC_CSD_BASE + 24)
858 #define IDC_CSD_BASIC_COLOR_23 (IDC_CSD_BASE + 25)
859 #define IDC_CSD_BASIC_COLOR_24 (IDC_CSD_BASE + 26)
860 #define IDC_CSD_BASIC_COLOR_25 (IDC_CSD_BASE + 27)
861 #define IDC_CSD_BASIC_COLOR_26 (IDC_CSD_BASE + 28)
862 #define IDC_CSD_BASIC_COLOR_27 (IDC_CSD_BASE + 29)
863 #define IDC_CSD_BASIC_COLOR_28 (IDC_CSD_BASE + 30)
864 #define IDC_CSD_BASIC_COLOR_29 (IDC_CSD_BASE + 31)
865 #define IDC_CSD_CUSTOM_COLOR_NOTE (IDC_CSD_BASE + 32)
866 #define IDC_CSD_CUSTOM_COLOR_0 (IDC_CSD_BASE + 33)
867 #define IDC_CSD_CUSTOM (IDC_CSD_BASE + 33)
868 #define IDC_CSD_CUSTOM_COLOR_1 (IDC_CSD_BASE + 34)
869 #define IDC_CSD_CUSTOM_COLOR_2 (IDC_CSD_BASE + 35)
870 #define IDC_CSD_CUSTOM_COLOR_3 (IDC_CSD_BASE + 36)
871 #define IDC_CSD_CUSTOM_COLOR_4 (IDC_CSD_BASE + 37)
872 #define IDC_CSD_CUSTOM_COLOR_5 (IDC_CSD_BASE + 38)
873 #define IDC_CSD_SPACE (IDC_CSD_BASE + 39)
874 #define IDC_CSD_YSPACE (IDC_CSD_BASE + 40)
875 #define IDC_CSD_COLOR (IDC_CSD_BASE + 41)
876 #define IDC_CSD_NOTE_H (IDC_CSD_BASE + 42)
877 #define IDC_CSD_NOTE_S (IDC_CSD_BASE + 43)
878 #define IDC_CSD_NOTE_V (IDC_CSD_BASE + 44)
879 #define IDC_CSD_NOTE_R (IDC_CSD_BASE + 45)
880 #define IDC_CSD_NOTE_G (IDC_CSD_BASE + 46)
881 #define IDC_CSD_NOTE_B (IDC_CSD_BASE + 47)
882 #define IDC_CSD_VALUE_H (IDC_CSD_BASE + 48)
883 #define IDC_CSD_VALUE_S (IDC_CSD_BASE + 49)
884 #define IDC_CSD_VALUE_V (IDC_CSD_BASE + 50)
885 #define IDC_CSD_VALUE_R (IDC_CSD_BASE + 51)
886 #define IDC_CSD_VALUE_G (IDC_CSD_BASE + 52)
887 #define IDC_CSD_VALUE_B (IDC_CSD_BASE + 53)
888 #define IDC_CSD_ADD (IDC_CSD_BASE + 54)
889 #define IDC_CSD_OK (IDC_CSD_BASE + 55)
890 #define IDC_CSD_CANCEL (IDC_CSD_BASE + 56)
891 
908 MGUTILS_EXPORT BOOL ColorSelectDialog (PDLGTEMPLATE dlg_template, HWND hwnd,
909  WNDPROC proc, PCOLORDLGDATA pcdd);
910 
911 MGUTILS_EXPORT extern DLGTEMPLATE DefColorDlg;
912 MGUTILS_EXPORT extern DLGTEMPLATE DefSimpleColorDlg;
913 
915 MGUTILS_EXPORT LRESULT DefColorDialogProc (HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
916 
921 typedef struct _COLORDATA {
923  DWORD style;
925  gal_pixel pixel;
927  Uint8 r, g, b;
929  Uint16 h;
931  Uint8 s, v;
933  BOOL is_trans;
935 
936 /* Internal use */
937 #define SELCOLOR_OK IDOK
938 /* Internal use */
939 #define SELCOLOR_CANCEL IDCANCEL
940 
961 MGUTILS_EXPORT int ColorSelDialog (HWND hWnd, int x, int y,
962  int w, int h, PCOLORDATA pClrData);
963 
964 #endif /* _MGUTILS_DLGCOLORSEL */
965 
966 #ifdef _MGUTILS_DLGFONTSEL
967 
968 typedef struct _FONTDLGDATA {
969  /* The font minimize size. */
970  int min_size;
971  /* The font maximize size. */
972  int max_size;
973  /* Indicates the controls is transparent or no?*/
974  BOOL is_trans;
975 
976  /* The font color. */
977  RGB color;
978  PLOGFONT logfont;
979 
980  WNDPROC hook;
981 } FONTDLGDATA, *PFONTDLGDATA;
982 
983 #define IDC_FSD_BASE 540
984 #define IDC_FSD_FONT_NOTE (IDC_FSD_BASE + 1)
985 #define IDC_FSD_FONT (IDC_FSD_BASE + 2)
986 #define IDC_FSD_STYLE_NOTE (IDC_FSD_BASE + 3)
987 #define IDC_FSD_STYLE (IDC_FSD_BASE + 4)
988 #define IDC_FSD_SIZE_NOTE (IDC_FSD_BASE + 5)
989 #define IDC_FSD_SIZE (IDC_FSD_BASE + 6)
990 #define IDC_FSD_EFFECTS_NOTE (IDC_FSD_BASE + 7)
991 #define IDC_FSD_FLIP_NOTE (IDC_FSD_BASE + 8)
992 #define IDC_FSD_FLIP (IDC_FSD_BASE + 9)
993 #define IDC_FSD_COLOR_NOTE (IDC_FSD_BASE + 10)
994 #define IDC_FSD_COLOR (IDC_FSD_BASE + 11)
995 #define IDC_FSD_ITALIC (IDC_FSD_BASE + 12)
996 #define IDC_FSD_STRIKEOUT (IDC_FSD_BASE + 13)
997 #define IDC_FSD_UNDERLINE (IDC_FSD_BASE + 14)
998 #define IDC_FSD_SAMPLE_NOTE (IDC_FSD_BASE + 15)
999 #define IDC_FSD_SAMPLE (IDC_FSD_BASE + 16)
1000 #define IDC_FSD_CHARSET_NOTE (IDC_FSD_BASE + 17)
1001 #define IDC_FSD_CHARSET (IDC_FSD_BASE + 18)
1002 #define IDC_FSD_OK (IDC_FSD_BASE + 19)
1003 #define IDC_FSD_CANCEL (IDC_FSD_BASE + 20)
1004 
1021 MGUTILS_EXPORT BOOL FontSelectDialog (PDLGTEMPLATE dlg_template, HWND hwnd,
1022  WNDPROC proc, PFONTDLGDATA pfsd);
1023 
1024 MGUTILS_EXPORT extern DLGTEMPLATE DefSimpleFontDlg;
1025 MGUTILS_EXPORT extern DLGTEMPLATE DefFontDlg;
1026 
1028 MGUTILS_EXPORT LRESULT DefFontDialogProc (HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
1029 
1030 #endif /* _MGUTILS_DLGFONTSEL */
1031 
1032 #ifdef _MGUTILS_DLGSHOWINFO
1033 
1034 typedef struct _INFODLGDATA {
1035  const char* msg;
1036  WNDPROC hook;
1037 
1038  /* for internal usage.*/
1039  int nr_lines;
1040  int vis_lines;
1041  int start_line;
1042  RECT rc;
1043 } INFODLGDATA, *PINFODLGDATA;
1044 
1045 #define IDC_IFD_SPIN 580
1046 
1062 MGUTILS_EXPORT BOOL InfoShowDialog (PDLGTEMPLATE dlg_template, HWND hwnd,
1063  WNDPROC proc, PINFODLGDATA pidd);
1064 
1065 MGUTILS_EXPORT extern DLGTEMPLATE DefInfoDlg;
1066 MGUTILS_EXPORT extern DLGTEMPLATE DefSimpleInfoDlg;
1067 
1069 MGUTILS_EXPORT LRESULT DefInfoDialogProc (HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
1070 
1071 #endif /* _MGUTILS_DLGSHOWINFO */
1072 
1075 #ifdef _MGUTILS_SKIN
1076 
1083 /* skin messages (send to items) */
1084 #define SKIN_MSG_LBUTTONDOWN 1
1085 #define SKIN_MSG_LBUTTONUP 2
1086 #define SKIN_MSG_CLICK 3
1087 /*#define SKIN_MSG_DBCLICK 4 */
1088 #define SKIN_MSG_MOUSEMOVE 5
1089 #define SKIN_MSG_MOUSEDRAG 6
1090 #define SKIN_MSG_SETFOCUS 7
1091 #define SKIN_MSG_KILLFOCUS 8
1092 
1093 /* type of item */
1094 
1099 #define SI_TYPE_NRMLABEL 0x10000000
1100 
1105 #define SI_TYPE_BMPLABEL 0x20000000
1106 
1111 #define SI_TYPE_CMDBUTTON 0x30000000
1112 
1117 #define SI_TYPE_CHKBUTTON 0x40000000
1118 
1123 #define SI_TYPE_NRMSLIDER 0x50000000
1124 
1125 #ifdef _MGHAVE_FIXED_MATH
1126 
1130 #define SI_TYPE_ROTSLIDER 0x60000000
1131 #endif
1132 
1137 #define SI_TYPE_CONTROL 0x70000000
1138 
1143 #define SI_TYPE_MASK 0xF0000000
1144 
1145 /* type of hittest shape */
1146 
1151 #define SI_TEST_SHAPE_RECT 0x01000000
1152 
1157 #define SI_TEST_SHAPE_ELLIPSE 0x02000000
1158 
1163 #define SI_TEST_SHAPE_LOZENGE 0x03000000
1164 
1169 #define SI_TEST_SHAPE_LTRIANGLE 0x04000000
1170 
1175 #define SI_TEST_SHAPE_RTRIANGLE 0x05000000
1176 
1181 #define SI_TEST_SHAPE_UTRIANGLE 0x06000000
1182 
1187 #define SI_TEST_SHAPE_DTRIANGLE 0x07000000
1188 
1189 #define SI_TEST_SHAPE_MASK 0x0F000000
1190 
1191 /* common status of item */
1192 
1197 #define SI_STATUS_OK 0x00000001
1198 
1203 #define SI_STATUS_VISIBLE 0x00000002
1204 
1209 #define SI_STATUS_DISABLED 0x00000004
1210 
1215 #define SI_STATUS_HILIGHTED 0x00000008
1216 
1217 #define SI_STATUS_MASK 0x0000000F
1218 
1219 /* status of button item */
1220 
1225 #define SI_BTNSTATUS_CLICKED 0x00000010
1226 
1231 #define SI_BTNSTATUS_CHECKED SI_BTNSTATUS_CLICKED
1232 
1233 #define SI_STATUS_CLICKED SI_BTNSTATUS_CLICKED
1234 
1235 #define SI_BTNSTATUS_MASK 0x000000F0
1236 
1238 #define SI_CMDBUTTON_2STATE 0x00000100
1239 
1240 /* style of normal slider item */
1241 
1246 #define SI_NRMSLIDER_HORZ 0x00000100
1247 
1252 #define SI_NRMSLIDER_VERT 0x00000200
1253 
1258 #define SI_NRMSLIDER_STATIC 0x00000400
1259 
1260 #ifdef _MGHAVE_FIXED_MATH
1261 
1262 /* style of rotation slider item */
1263 
1268 #define SI_ROTSLIDER_CW 0x00000100
1269 
1274 #define SI_ROTSLIDER_ANTICW 0x00000200
1275 
1280 #define SI_ROTSLIDER_STATIC 0x00000400
1281 
1282 #endif /* _MGHAVE_FIXED_MATH */
1283 
1284 #define SI_STYLE_MASK 0x0000FF00
1285 
1290 #define CTRL_SKIN "skin"
1291 
1297 
1302 typedef struct skin_head_s skin_head_t;
1303 
1305 typedef struct skin_item_s
1306 {
1308  int id;
1309 
1388  DWORD style;
1389 
1391  int x;
1393  int y;
1394 
1396  RECT item_rc;
1397 
1398  union {
1401 
1403  HWND hwnd;
1404  };
1405 
1407  char* tip;
1408 
1410  DWORD attached;
1411 
1416  void* type_data;
1417 
1418  /******** start of internal fields ********/
1419  /* The bounding rectangle of the item. */
1420  RECT shape;
1421  /* The hit-test rectangle of the item. */
1422  RECT rc_hittest;
1423  /* The region for mouse hittest. */
1424  CLIPRGN region;
1425  /* The operation routines of the item. */
1426  skin_item_ops_t *ops;
1427  /* The parent skin. */
1428  skin_head_t *hostskin;
1429 } skin_item_t;
1430 
1433 {
1435  int (*init) (skin_head_t*, skin_item_t*);
1437  int (*deinit) (skin_item_t*);
1438 
1440  int (*on_create) (skin_item_t*);
1442  int (*on_destroy) (skin_item_t*);
1443 
1445  void (*draw_bg) (HDC, skin_item_t*);
1447  void (*draw_attached) (HDC, skin_item_t*);
1448 
1456  DWORD (*get_value) (skin_item_t *item);
1464  DWORD (*set_value) (skin_item_t *item, DWORD status);
1465 
1467  int (*item_msg_proc) (skin_item_t* item, int message,
1468  WPARAM wparam, LPARAM lparam);
1469 };
1470 
1472 typedef struct sie_slider_s
1473 {
1475  int min_pos;
1477  int max_pos;
1479  int cur_pos;
1480 } sie_slider_t;
1481 
1483 typedef struct si_nrmlabel_s
1484 {
1486  char* label;
1487 
1489  DWORD color;
1491  DWORD color_focus;
1493  DWORD color_click;
1496 } si_nrmlabel_t;
1497 
1499 typedef struct si_bmplabel_s
1500 {
1502  char* label;
1504  const char* label_chars;
1505 } si_bmplabel_t;
1506 
1508 typedef struct si_nrmslider_s
1509 {
1512 
1515 } si_nrmslider_t;
1516 
1517 #ifdef _MGHAVE_FIXED_MATH
1518 
1520 typedef struct si_rotslider_s
1521 {
1523  int radius;
1527  int end_deg;
1529  int cur_pos;
1530 
1533 } si_rotslider_t;
1534 
1535 #endif /* _MGHAVE_FIXED_MATH */
1536 
1541 #define SIE_BUTTON_CLICKED 0x00000001
1542 
1547 #define SIE_SLIDER_CHANGED 0x00000002
1548 
1553 #define SIE_GAIN_FOCUS 0x00010000
1554 
1559 #define SIE_LOST_FOCUS 0x00020000
1560 
1578 typedef int (* skin_event_cb_t) (HWND hwnd, skin_item_t* item,
1579  int event, void* data);
1584 #define MSG_CB_GOON 0
1585 
1590 #define MSG_CB_DEF_GOON 1
1591 
1596 #define MSG_CB_STOP 2
1597 
1623 typedef int (* skin_msg_cb_t) (HWND hwnd, int message,
1624  WPARAM wparam, LPARAM lparam, int* result);
1625 
1630 #define SKIN_STYLE_NONE 0x00000000
1631 
1636 #define SKIN_STYLE_TOOLTIP 0x00000001
1637 
1642 #define SKIN_STYLE_MODAL 0x00000002
1643 
1646 {
1648  char* name;
1649 
1655  DWORD style;
1656 
1658  const BITMAP* bmps;
1660  const LOGFONT* fonts;
1661 
1664 
1669 
1671  DWORD attached;
1672 
1673  /******** start of internal fields ********/
1674 
1675  /* The event callback function of the skin. */
1676  skin_event_cb_t event_cb;
1677 
1678  /* The window message procedure of the skin window. */
1679  skin_msg_cb_t msg_cb;
1680 
1681  /**** The fields initialized when skin_init called. ****/
1682  /* The rectangle heap for hit-test regions. */
1683  BLOCKHEAP rc_heap;
1684 
1685  /****
1686  * The fields initialized when create_skin_main_window or
1687  * create_skin_control called.
1688  ****/
1689  /* The handle of window in which the skin locates. */
1690  HWND hwnd;
1691  /* The handle of tool tip window. */
1692  HWND tool_tip;
1693 
1694  /* The old x and y. */
1695  int oldx, oldy;
1696  /* The current hilighted item. */
1697  skin_item_t* hilighted;
1698 
1699  /* cached identifier. */
1700  int cached_id;
1701  /* the item whose identifier is cached_id. */
1702  skin_item_t* cached_item;
1703 };
1704 
1723 MGUTILS_EXPORT BOOL skin_init (skin_head_t* skin,
1724  skin_event_cb_t event_cb, skin_msg_cb_t msg_cb);
1725 
1736 MGUTILS_EXPORT void skin_deinit (skin_head_t* skin);
1737 
1765 MGUTILS_EXPORT HWND create_skin_main_window_ex (skin_head_t* skin, HWND hosting,
1766  int lx, int ty, int rx, int by, DWORD dwExStyle, BOOL modal);
1771 #define create_skin_main_window(skin, hosting, lx, ty, rx, by, modal) \
1772  create_skin_main_window_ex (skin, hosting, lx, ty, rx, by, 0, modal)
1773 
1805 MGUTILS_EXPORT HWND create_skin_control (skin_head_t* skin, HWND parent,
1806  int id, int x, int y, int w, int h);
1807 
1821 MGUTILS_EXPORT BOOL is_skin_main_window (HWND hwnd);
1822 
1833 MGUTILS_EXPORT void destroy_skin_window (HWND hwnd);
1834 
1849 MGUTILS_EXPORT skin_head_t* set_window_skin (HWND hwnd, skin_head_t *new_skin);
1850 
1863 MGUTILS_EXPORT skin_head_t* get_window_skin (HWND hwnd);
1864 
1880  skin_event_cb_t event_cb)
1881 {
1882  skin_event_cb_t old = skin->event_cb;
1883  skin->event_cb = event_cb;
1884  return old;
1885 }
1886 
1902  skin_msg_cb_t msg_cb)
1903 {
1904  skin_msg_cb_t old = skin->msg_cb;
1905  skin->msg_cb = msg_cb;
1906  return old;
1907 }
1908 
1922 MGUTILS_EXPORT skin_item_t* skin_get_item (skin_head_t* skin, int id);
1923 
1937 MGUTILS_EXPORT DWORD skin_get_item_status (skin_head_t* skin, int id);
1938 
1953 MGUTILS_EXPORT DWORD skin_set_item_status (skin_head_t* skin, int id, DWORD status);
1954 
1965 MGUTILS_EXPORT skin_item_t* skin_get_hilited_item (skin_head_t* skin);
1966 
1981 MGUTILS_EXPORT DWORD skin_show_item (skin_head_t* skin, int id, BOOL show);
1982 
1996 MGUTILS_EXPORT DWORD skin_enable_item (skin_head_t* skin, int id, BOOL enable);
1997 
2011 MGUTILS_EXPORT skin_item_t* skin_set_hilited_item (skin_head_t* skin, int id);
2012 
2027 MGUTILS_EXPORT BOOL skin_get_check_status (skin_head_t* skin, int id);
2028 
2044 MGUTILS_EXPORT DWORD skin_set_check_status (skin_head_t* skin,
2045  int id, BOOL check);
2046 
2062 MGUTILS_EXPORT const char* skin_get_item_label (skin_head_t* skin, int id);
2063 
2080 MGUTILS_EXPORT BOOL skin_set_item_label (skin_head_t* skin,
2081  int id, const char* label);
2082 
2097 MGUTILS_EXPORT HWND skin_get_control_hwnd (skin_head_t* skin, int id);
2098 
2112 MGUTILS_EXPORT int skin_get_thumb_pos (skin_head_t* skin, int id);
2113 
2130 MGUTILS_EXPORT BOOL skin_set_thumb_pos (skin_head_t* skin, int id, int pos);
2131 
2149 MGUTILS_EXPORT BOOL skin_get_slider_info (skin_head_t* skin,
2150  int id, sie_slider_t* sie);
2151 
2167 MGUTILS_EXPORT BOOL skin_set_slider_info (skin_head_t* skin,
2168  int id, const sie_slider_t* sie);
2169 
2188 MGUTILS_EXPORT int skin_scale_slider_pos (const sie_slider_t* org,
2189  int new_min, int new_max);
2190 
2193 #endif /* _MGUTILS_SKIN */
2194 
2195 #ifdef __cplusplus
2196 }
2197 #endif
2198 
2199 #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:1396
int font_index
Definition: mgutils.h:1495
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:501
Uint16 h
Definition: mgutils.h:929
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:1532
DWORD flags
Definition: mgutils.h:378
bool startupMessage
Definition: mgutils.h:480
int(* skin_msg_cb_t)(HWND hwnd, int message, WPARAM wparam, LPARAM lparam, int *result)
Definition: mgutils.h:1623
DWORD color
Definition: mgutils.h:1489
int maxlen
Definition: mgutils.h:376
int(* skin_event_cb_t)(HWND hwnd, skin_item_t *item, int event, void *data)
Definition: mgutils.h:1578
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:374
MGUTILS_EXPORT LRESULT DefInfoDialogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
char * text
Definition: mgutils.h:311
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:1502
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:495
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:1648
int nr_items
Definition: mgutils.h:1666
struct _myWinButton myWINBUTTON
DWORD style
Definition: mgutils.h:923
struct sie_slider_s sie_slider_t
DWORD style
Definition: mgutils.h:1388
MGUTILS_EXPORT BOOL FileOpenSaveDialog(PDLGTEMPLATE dlg_template, HWND hwnd, WNDPROC proc, PFILEDLGDATA pfdd)
const char * execProg
Definition: mgutils.h:487
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:1504
Uint8 r
Definition: mgutils.h:927
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:1879
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:499
const BITMAP * bmps
Definition: mgutils.h:1658
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:931
DWORD attached
Definition: mgutils.h:1671
DWORD style
Definition: mgutils.h:1655
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:372
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:1400
MGUTILS_EXPORT skin_item_t * skin_get_hilited_item(skin_head_t *skin)
Gets the current highlighted skin item.
HWND hwnd
Definition: mgutils.h:1403
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:1901
BOOL is_trans
Definition: mgutils.h:933
skin_item_t * items
Definition: mgutils.h:1668
NEWFILEDLGDATA * PNEWFILEDLGDATA
Definition: mgutils.h:686
const char * startupStr
Definition: mgutils.h:482
#define MAX_FILTER_LEN
The maximum length of filter string.
Definition: mgutils.h:581
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:497
gal_pixel pixel
Definition: mgutils.h:925
#define MY_PATHMAX
The maximum length of path.
Definition: mgutils.h:593
const LOGFONT * fonts
Definition: mgutils.h:1660
DWORD flags
Definition: mgutils.h:315
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:1491
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:504
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:1514
char * label
Definition: mgutils.h:1486
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:1407
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:1663
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:489
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:1493
sie_slider_t slider_info
Definition: mgutils.h:1511
void * type_data
Definition: mgutils.h:1416
MGUTILS_EXPORT BOOL ColorSelectDialog(PDLGTEMPLATE dlg_template, HWND hwnd, WNDPROC proc, PCOLORDLGDATA pcdd)
#define MY_NAMEMAX
The maximum length of name.
Definition: mgutils.h:587
DWORD attached
Definition: mgutils.h:1410
MGUTILS_EXPORT int skin_get_thumb_pos(skin_head_t *skin, int id)
Gets the thumb position of a slider item.