globals.h
上传用户:tuheem
上传日期:2007-05-01
资源大小:21889k
文件大小:12k
源码类别:

多媒体编程

开发平台:

Visual C++

  1. // Globals
  2. # ifndef CP_GLOBALS_H
  3. # define CP_GLOBALS_H
  4. typedef struct _CPs_DrawContext
  5. {
  6.     HDC m_dcDraw;
  7.     POINT m_ptOffset;
  8.     RECT m_rClip;
  9. } CPs_DrawContext;
  10. typedef void* CP_HPLAYER;
  11. typedef void* CP_HPLAYLIST;
  12. typedef void* CP_HPLAYLISTITEM;
  13. typedef void* CP_COMPOSITEFILE;
  14. typedef void* CP_HINTERFACE;
  15. typedef void* CP_HINTERFACEPART;
  16. typedef void* CP_HSYSICON;
  17. #include "resource.h"
  18. #include "skin.h"
  19. #include "CPI_Verbs.h"
  20. #include "CPI_Keyboard.h"
  21. #include "CPI_Image.h"
  22. #include "CPI_Interface.h"
  23. #include "CPSK_Skin.h"
  24. #include "CLV_ListView.h"
  25. #include "String.h"
  26. // Handle to player
  27. #define CP_BUILD_NUMBER 214
  28. #define CIC_HTTPHEADER "http://"
  29. #define WM_NOTIFYICON WM_USER
  30. #define NOTIFY_ICON_ID 4567
  31. #define CPC_INVALIDCHAR -1
  32. // Registry
  33. #define CIC_COOLPLAYER_FILETYPE "CoolPlayer.Audio"
  34. #define CIC_COOLPLAYER_FILEDESC "CoolPlayer Audio file"
  35. #define CIC_COOLPLAYER_PLAYLISTFILETYPE "CoolPlayer.Playlist"
  36. #define CIC_COOLPLAYER_PLAYLISTFILEDESC "CoolPlayer Playlist"
  37. #define CLC_COOLPLAYER_INTERFACECLASSNAME "CoolPlayer_Interface"
  38. #define CLC_COOLPLAYER_WINDOWCLASSNAME "CoolPlayer"
  39. #define CLC_COOLPLAYER_PLAYLIST_WINDOWCLASSNAME "CoolPlayer_Playlist"
  40. // Playlist columns
  41. #define PLAYLIST_TRACKSTACK  0
  42. #define PLAYLIST_TITLE 1
  43. #define PLAYLIST_ARTIST 2
  44. #define PLAYLIST_ALBUM 3
  45. #define PLAYLIST_YEAR 4
  46. #define PLAYLIST_TRACKNUM 5
  47. #define PLAYLIST_COMMENT 6
  48. #define PLAYLIST_GENRE 7
  49. #define PLAYLIST_PATH 8
  50. #define PLAYLIST_FILENAME 9
  51. #define PLAYLIST_LENGTH 10
  52. #define PLAYLIST_first 0
  53. #define PLAYLIST_last 10
  54. #define PLAYLIST_IMAGE_SELECTED 0
  55. #define PLAYLIST_IMAGE_PLAIN 1
  56. // Hotkeys
  57. #define VK_MEDIA_NEXT_TRACK 0xB0
  58. #define VK_MEDIA_PREV_TRACK 0xB1
  59. #define VK_MEDIA_STOP 0xB2
  60. #define VK_MEDIA_PLAY_PAUSE 0xB3
  61. //
  62. #define CP_HOTKEY_NEXT 0x01
  63. #define CP_HOTKEY_PREV 0x02
  64. #define CP_HOTKEY_PLAY0 0x03
  65. #define CP_HOTKEY_STOP 0x04
  66. #define CP_HOTKEY_PLAY1 0x05
  67. #define VUVOLUME 0
  68. #define EQ1 1
  69. #define EQ2 2
  70. #define EQ3 3
  71. #define EQ4 4
  72. #define EQ5 5
  73. #define EQ6 6
  74. #define EQ7 7
  75. #define EQ8 8
  76. #define POSITION 100
  77. // Playlist defines for resizing
  78. #define RESIZE 5
  79. #define BOTTOMRIGHT 4
  80. #define TOPRIGHT 2
  81. #define BOTTOMLEFT 3
  82. #define TOPLEFT 1
  83. #define ASCENDING 0
  84. #define DESCENDING 1
  85. #define RANDOM 2
  86. // Timer IDs
  87. #define CPC_TIMERID_SCROLLTITLETEXT 0x033
  88. #define CPC_TIMERID_INTERTRACKDELAY 0x038
  89. #define CPC_TIMERID_BOUNCINGICON 0x29A
  90. #define CPC_TIMERID_ROTATINGSMILY 0x29A
  91. #define SC_SIZE_TOPLEFT SC_SIZE+4
  92. #define SC_SIZE_TOPMIDDLE SC_SIZE+3
  93. #define SC_SIZE_TOPRIGHT SC_SIZE+5
  94. #define SC_SIZE_SIDELEFT SC_SIZE+1
  95. #define SC_SIZE_SIDERIGHT SC_SIZE+2
  96. #define SC_SIZE_BOTTOMLEFT SC_SIZE+7
  97. #define SC_SIZE_BOTTOMMIDDLE SC_SIZE+6
  98. #define SC_SIZE_BOTTOMRIGHT SC_SIZE+8
  99. // Main graphics bitmaps
  100. struct
  101. {
  102.     HBITMAP bmp_main_up;
  103.     HBITMAP bmp_main_down;
  104.     HBITMAP bmp_main_switch;
  105.     HBITMAP bmp_main_time_font;
  106.     HBITMAP bmp_main_title_font;
  107.     HBITMAP bmp_main_track_font;
  108.     HBITMAP bmp_main_title_area;
  109.     HBITMAP bmp_playlist_bg;
  110.     HPALETTE pal_main;
  111. }
  112. graphics;
  113. // Window pointers
  114. struct
  115. {
  116.     HWND wnd_main;
  117.     HWND    dlg_playlist;
  118.     HWND    dlg_options;
  119.     HWND    wnd_tooltip;
  120.     HWND    wnd_playlist_IPEdit;
  121.     HWND    m_hWndFindDialog;
  122.     HWND    m_hWndMain;
  123.     HWND    m_hWndPlaylist;
  124.     CP_HINTERFACE m_hifMain;
  125.     CP_HINTERFACE m_hifPlaylist;
  126. }
  127. windows;
  128. // Drawable areas
  129. struct
  130. {
  131.     HDC     dc_memory;
  132.     HDC     dc_main;
  133. }
  134. drawables;
  135. // Bitmaps for playlist
  136. struct
  137. {
  138.     SIZE    UpLeft;
  139.     SIZE    UpRight;
  140.     SIZE    DownLeft;
  141.     SIZE    DownRight;
  142.     SIZE    UpMid;
  143.     SIZE    DownMid;
  144.     SIZE    LeftMid;
  145.     SIZE    RightMid;
  146.     SIZE    MinSize;
  147.     SIZE    Colors;
  148.     HBITMAP bm[16];
  149. }
  150. PlayListBitmap;
  151. // Playist item structure.
  152. struct ListStruct
  153. {
  154.     int     nritem;
  155.     unsigned char mp3track;
  156.     char    mp3title[MAX_PATH];
  157.     char    mp3artist[31];
  158.     char    mp3album[31];
  159.     char    mp3year[5];
  160.     char    mp3comment[31];
  161.     char    mp3genre[30];
  162.     char    mp3path[MAX_PATH];
  163. };
  164. /////////////////////////////////////////////////////////////////////////////////
  165. //
  166. // Player state
  167. typedef enum _CPe_PlayerState
  168. {
  169.     cppsUndefined,
  170.     cppsEndOfStream,
  171.     cppsPaused,
  172.     cppsPlaying,
  173.     cppsStopped
  174. } CPe_PlayerState;
  175. //
  176. // File info
  177. typedef struct _CPs_FileInfo
  178. {
  179.     UINT m_iFileLength_Secs;
  180.     UINT m_iBitRate_Kbs;
  181.     UINT m_iFreq_Hz;
  182.     BOOL m_bStereo;
  183.     BOOL m_b16bit;
  184. } CPs_FileInfo;
  185. //
  186. // EQ settings
  187. typedef struct _CPs_EQSettings
  188. {
  189.     BOOL m_bEnabled;
  190.     char m_aryBands[8];
  191. } CPs_EQSettings;
  192. //
  193. typedef enum _CPe_QuickFindTerm
  194. {
  195.     qftUndefined,
  196.     qftTitle,
  197.     qftAlbum,
  198.     qftArtist
  199. } CPe_QuickFindTerm;
  200. //
  201. typedef enum _CPe_MixerMode
  202. {
  203.     mmMasterVolume,
  204.     mmWaveVolume,
  205.     mmInternal
  206. } CPe_MixerMode;
  207. //
  208. //
  209. /////////////////////////////////////////////////////////////////////////////////
  210. BOOL    cmdline_parse_argument(char *token);
  211. BOOL    main_draw_vu_all(HWND hWnd, WPARAM wParam, LPARAM lParam,
  212.                          BOOL rememberlastval);
  213. BOOL    path_is_directory(char *filename);
  214. BOOL    path_is_relative(const char *path);
  215. BOOL    path_remove_filespec(LPTSTR path);
  216. BOOL    playlist_skin_draw_side(HDC hdc, HDC winmemdc, BITMAP * bm,
  217.                                 RECT * winrect, int type);
  218. BOOL    playlist_skin_get_ini_value(char *key, char *position,
  219.                                     SIZE * rect);
  220. BOOL    playlist_skin_set_control_bitmap(char *position);
  221. BOOL    window_set_always_on_top(HWND hWnd, BOOL yes);
  222. BOOL CALLBACK window_search(HWND hWnd, LPARAM lParam);
  223. char   *str_delete_substr(char *strbuf, char *strtodel);
  224. char   *str_trim(char *string);
  225. DWORD   main_get_program_path(HINSTANCE hInst, LPTSTR pszBuffer,
  226.                               DWORD dwSize);
  227. HBITMAP systray_rotate_bmp(HBITMAP hBitmap, float radians,
  228.                            COLORREF clrBack);
  229. HRESULT path_create_link(LPCSTR lpszPathObj, LPSTR lpszPathLink,
  230.                          LPSTR lpszDesc);
  231. HRGN    main_bitmap_to_region(HBITMAP hBmp, COLORREF cTransparentColor);
  232. HRGN    main_bitmap_to_region_1bit(HBITMAP hBmp, COLORREF cTransparentColor);
  233. HWND    about_create(HWND hWnd);
  234. int     cmdline_parse_files(int argc,char **argv);
  235. int     cmdline_parse_options(int argc,char **argv);
  236. int     main_add_tooltips(HWND hWnd, BOOL update);
  237. int     main_play_control(WORD wParam, HWND hWnd);
  238. int     main_set_default_skin(void);
  239. int     main_skin_open(char *name);
  240. int     main_skin_set_struct_value(int object, int x, int y, int w, int h,
  241.                                    int maxw, int x2, int y2, int w2,
  242.                                    int h2, char *tooltip);
  243. int     playlist_open_file(BOOL clearlist);
  244. int     playlist_skin_read();
  245. int     playlist_write();
  246. int     window_bmp_blt(HWND hWnd, HBITMAP SrcBmp, int srcx, int srcy,
  247.                        int srcw, int srch, int dstx, int dsty);
  248. int    *cmdline_get_argument(char *arg);
  249. LRESULT CALLBACK main_windowproc(HWND hWnd, UINT message, WPARAM wParam,
  250.                                  LPARAM lParam);
  251. LRESULT CALLBACK options_windowproc(HWND hwndDlg, UINT msg, WPARAM wParam,
  252.                                     LPARAM lParam);
  253. LRESULT CALLBACK url_windowproc(HWND hwndDlg, UINT msg, WPARAM wParam,
  254.                                 LPARAM lParam);
  255. LRESULT CALLBACK about_windowproc(HWND hwndDlg, UINT msg, WPARAM wParam,
  256.                                   LPARAM lParam);
  257. LRESULT CALLBACK playlist_windowproc(HWND hwndDlg, UINT msg, WPARAM wParam,
  258.                                      LPARAM lParam);
  259. void    cmdline_usage(void);
  260. void    main_update_title_text();
  261. void    main_draw_bitrate(HWND hWnd);
  262. void    playlist_draw_control(UINT controlid, LPDRAWITEMSTRUCT ds);
  263. void    main_draw_controls_all(HWND hWnd);
  264. void    main_draw_frequency(HWND hWnd);
  265. void    main_draw_time(HWND hWnd);
  266. void    main_draw_title(HWND hWnd);
  267. void    main_draw_tracknr(HWND hWnd);
  268. void    main_draw_vu_from_mouse(HWND hWnd, int vunummer, int vuwaarde);
  269. void    main_draw_vu_from_value(HWND hWnd, int vunummer, int vuwaarde);
  270. void    main_menuproc(HWND hWnd, LPPOINT points);
  271. void    main_reset_window(HWND hWnd);
  272. void    main_set_eq(void);
  273. void    main_skin_add_to_menu(char *name);
  274. void    main_skin_check_ini_value(char *textposition,
  275.                                   Associate * associate);
  276. void    main_skin_select_menu(char *name);
  277. void    options_read(void);
  278. void    options_write(void);
  279. void    path_add_backslash(char *path);
  280. void    path_unquote(LPTSTR path);
  281. void    playlist_write_default(void);
  282. void    options_create(HWND hWnd);
  283. void    playlist_move_control(int ControlID, LPRECT NewPlaylistrect,
  284.                               int type);
  285. void    url_create(HWND hWnd);
  286. struct
  287. {
  288.     BOOL    auto_exit_after_playing;
  289.     BOOL    auto_play_when_started;
  290.     BOOL    easy_move;
  291.     BOOL    equalizer;
  292.     BOOL    allow_file_once_in_playlist;
  293.     BOOL allow_multiple_instances;
  294.     BOOL    always_on_top;
  295.     BOOL    read_id3_tag;
  296.     BOOL    read_id3_tag_of_selected;
  297.     BOOL    read_id3_tag_in_background;
  298.     BOOL    support_id3v2;
  299.     BOOL    prefer_native_ogg_tags;
  300.     BOOL    work_out_track_lengths;
  301.     BOOL    show_remaining_time;
  302.     BOOL    remember_playlist;
  303.     BOOL    remember_last_played_track;
  304.     BOOL    repeat_playlist;
  305.     BOOL    rotate_systray_icon;
  306.     BOOL    scroll_track_title;
  307.     BOOL    show_on_taskbar;
  308.     BOOL    shuffle_play;
  309.     BOOL    use_default_skin;
  310.     BOOL    use_playlist_skin;
  311.     char    last_used_directory[MAX_PATH];
  312.     char initial_file[MAX_PATH];
  313.     int     playlist_column_widths[PLAYLIST_last + 1];
  314.     int     playlist_column_seq[PLAYLIST_last + 1];
  315.     BOOL    playlist_column_visible[PLAYLIST_last + 1];
  316.     int     eq_settings[9];
  317.     int     show_playlist;
  318.     int     decoder_output_mode;
  319.     int     remember_skin_count;
  320.     POINT   main_window_pos;
  321.     RECT    playlist_window_pos;
  322.     short   last_selected_skin_number;
  323.     unsigned char playlist_skin_file[MAX_PATH];
  324.     unsigned char main_skin_file[MAX_PATH];
  325.     unsigned int seconds_delay_after_track;
  326.     CPe_QuickFindTerm m_enQuickFindTerm;
  327. }
  328. options;
  329. struct
  330. {
  331.     BOOL    playlist_bool_addsong;
  332.     DWORD playlist_last_add_time;
  333.     char    main_text_frequency[33];
  334.     char    main_text_bitrate[33];
  335.     unsigned long main_long_track_duration;
  336.     int     main_int_skin_last_number;
  337.     CPe_PlayerState m_enPlayerState;
  338.     int     main_drag_anchor_point;
  339.     unsigned char main_text_last_browsed_dir[MAX_PATH];
  340.     int     main_int_track_total_seconds;
  341.     int     main_int_show_minimized;
  342.     int     playlist_int_last_searched_track;
  343.     int main_int_title_scroll_position;
  344.     int mail_int_title_scroll_max_position;
  345.     BOOL    cmdline_bool_clear_playlist_first;
  346.     BOOL    main_bool_wavwrite_dir_already_known;
  347.     BOOL    main_bool_skin_next_is_default;
  348.     BOOL    main_bool_slider_keep_focus;
  349.     BOOL    playlist_bool_force_skin_from_options;
  350.     int     main_int_track_position;
  351.     RECT    playlist_rect;
  352.     HMENU   main_menu_popup;
  353.     double  about_double_smiley_jump_pos;
  354.     double  about_double_smiley_jump_speed;
  355.     int     m_iVolume;
  356.     CP_HPLAYER m_hPlayer;
  357.     CP_HPLAYLIST m_hPlaylist;
  358.     BOOL m_bStreaming;
  359.     int m_iStreamingPortion;
  360.     int m_iLastPlaylistSortColoumn;
  361.     HIMAGELIST m_hPlaylistImages;
  362.     POINT m_ptQuickFindWindowPos;
  363.     BOOL m_bQuickFindWindowPos_Valid;
  364.     HHOOK m_hhkListView_Posted;
  365.     BOOL m_bIP_InhibitUpdates;
  366.     unsigned int m_iInPlaceSubItem;
  367.     CP_HLISTVIEW m_hPlaylistViewControl;
  368.     BOOL m_bOptions_ChangedSkin;
  369.     CP_HSYSICON m_hSysIcon;
  370.     CPe_MixerMode m_enMixerMode;
  371. } globals;
  372. CoolSkin Skin;
  373. #endif