/** * @class vetWindow32 * * @brief This class create a Window able to import and display VETLib * standard frames (vetFrameYUV420, vetFrameRGB24, vetFrameRGB) * Class doesn't require any external library, uses Windows GDI. * * @bug It's too slow for displaying video * @warning Require a Main Windows Application * @todo * * @see vetOutput * @example ../../tests/test_vetWindow32.cpp * @example ../../tests/app_vetDirectXLamePlayer.cpp * * @version 1.0.0 * @date 24/08/2005 * @author Alessandro Polo * * **************************************************************************** * VETLib Framework 1.0.2 * Copyright (C) Alessandro Polo 2006 * http://www.ewgate.net/vetlib * ****************************************************************************/ #ifndef __VETLIB_VETWINDOW32_H__ #define __VETLIB_VETWINDOW32_H__ #include "../vetDefs.h" #include "../vetOutput.h" #include "../vetFrameYUV420.h" #include "../vetFrameRGB24.h" #include "../vetFrameT.h" #include /** * @brief Deafult window's width. */ #define VETW32_DEF_WIDTH 320 /** * @brief Deafult window's height. */ #define VETW32_DEF_HEIGHT 240 #define VETW32_DEF_TITLE TEXT("VETLib Preview Window32 0.56\0") #define VETW32_DEF_CLSNAME TEXT("vetWindow32\0") class vetWindow32 : public vetOutput { protected: /** * @brief Parent Application's instance address. */ HINSTANCE parentHistance; /** * @brief Current window's handle. */ HWND myHandle; /** * @brief Canvas size and position. */ RECT myRect; /** * @brief Canvas. */ HDC hDisplay; unsigned int width; unsigned int height; public: /** * @brief Default constructor initializes variables; if present, set parent * instance and create window. * * @param[in] hInstance Main window (application) instance handle, required before * calling createWindow() */ vetWindow32(HINSTANCE hInstance = 0); /** * @brief Default destructor, release canvas. */ ~vetWindow32(); /** * @brief Get application's handle. * * @return address of application instance. */ void setParentHistance(HINSTANCE appHinstance) { parentHistance = appHinstance; }; /** * @brief Get application's handle. * * @return address of application instance. */ HINSTANCE getParentHistance() { return parentHistance; }; /** * @brief Initialize canvas, parent instance must be valid. * * @param[in] width window's width in pixel * @param[in] height window's height in pixel * * @return VETRET_ILLEGAL_USE if app handle is not valid, * VETRET_INTERNAL_ERR if window cannot be created, * VETRET_OK else. * * @note use setParentHistance() to update application's handle. */ VETRESULT createWindow(unsigned int width, unsigned int height); /** * @brief Display some text. * * @return VETRET_ILLEGAL_USE if app handle is not valid, VETRET_OK else. */ VETRESULT welcomeText(); /** * @brief Set window's position (passed to SetWindowPos(..) ) * * @param[in] X window's top-left x-axis position in screen. * @param[in] Y window's top-left y-axis position in screen. * @param[in] cx size * @param[in] cy size * * @return false if update has falied, true else. */ BOOL setWindowPos(int X, int Y, int cx, int cy) { return SetWindowPos(myHandle, HWND_NOTOPMOST, X, Y, cx, cy, SWP_SHOWWINDOW ); }; /** * @brief Set window's title. (passed to SetWindowText(..) ) * * @param[in] lpString long pointer to null terminated string (window's title) * * @return false if update has falied, true else. */ BOOL setWindowText(LPCTSTR lpString) { return SetWindowText(myHandle, lpString); }; /** * @brief Dump window's handle. * * @return address of window instance. */ HWND dump_handle() { return myHandle; }; /** * @brief Dump canvas' RECT. * * @return Canvas' rectancle (position and dimension) */ LPRECT dump_WindowRect() { return &myRect; }; /** * @brief Dump canvas' handle (DC). * * @return Canvas' handle (where data is displayed) */ HDC dump_DC() { return hDisplay; }; /** * @brief Show the window, state is customizable * * @param[in] default is SW_SHOW, argument is passed to ShowWindow() API. * * @return VETRET_ILLEGAL_USE if window handle is not valid, VETRET_OK else. */ VETRESULT show(int nCmdShow = SW_SHOW); /** * @brief Hide the window. * * @return VETRET_ILLEGAL_USE if window handle is not valid, VETRET_OK else. */ VETRESULT hide(); /** * @brief Currently not used. * @return VETRET_NOT_IMPLEMENTED */ VETRESULT run() { return VETRET_NOT_IMPLEMENTED; }; /** * @brief Set current canvas' height. * * @return height in pixel. */ VETRESULT setHeight(unsigned int value); /** * @brief Set current canvas' width. * * @return width in pixel. */ VETRESULT setWidth(unsigned int value); unsigned int getWidth() const { return width; }; unsigned int getHeight() const { return height; }; /** * @brief Display frame, single pixel routine. * * @param[in] img VETLib Cache Frame to be displayed. * * @return VETRET_OK if everything is fine, VETRET_INTERNAL_ERR else. * * @note Input operator (<<) call directly this function. * @see operator << (vetFrameYUV420&) */ VETRESULT importFrom(vetFrameYUV420& img); /** * @brief Display frame, single pixel routine. * * @param[in] img VETLib Cache24 Frame to be displayed. * * @return VETRET_OK if everything is fine, VETRET_INTERNAL_ERR else. * * @note Input operator (<<) call directly this function. * @see operator << (vetFrameRGB24&) */ VETRESULT importFrom(vetFrameRGB24& img); /** * @brief Display frame, conversion to vetFrameRGB24 and single pixel routine. * * @param[in] img VETLib Grey Frame to be displayed. * * @return VETRET_OK if everything is fine, VETRET_INTERNAL_ERR else. * * @note Input operator (<<) call directly this function. * @see operator << (vetFrameT&) */ VETRESULT importFrom(vetFrameT& img); }; #endif //__VETLIB_VETWINDOW32_H__