/*
 * ************************************************************************************************************
 * Author: Marcin Załęczny
 * Copyright (C)2011 Marcin Załęczny <mzaleczny@hotmail.com>
 * License: The GNU Lesser General Public License, version 3.0 (LGPLv3)
 * Library Name: mzstdimaging
 * Version: 1.02
 * First release date:   2011-02-03
 * Current release date: 2011-03-04
 *
 *
 * This file is part of mzstdimaging library
 * 
 * mzstdimaging library is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * mzstdimaging library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 * ************************************************************************************************************
 */

#ifndef __MZSTDIMAGING_CANVAS_H__
#define __MZSTDIMAGING_CANVAS_H__

#include "mzstdimagingCommon.h"
#include "mzBitmap.h"
#include "mzArrayList.h"
#include "mzFont.h"

class CStdObjectProperty;

class DECLSPEC_MZSTDIMAGING CCanvas : public CBitmap {
public:
    WINAPI CCanvas();
    WINAPI CCanvas(DWORD width, DWORD height, COLORREF bgcolor);
    WINAPI CCanvas(HDC hdc, DWORD width, DWORD height, COLORREF bgcolor, BOOL isPrintCanvas = FALSE);
    WINAPI CCanvas(HDC hdc, BOOL isPrintCanvas = FALSE);
    virtual WINAPI ~CCanvas();

    VOID WINAPI beginPrint();
    VOID WINAPI endPrint();
    
    inline BOOL WINAPI isPrintCanvas() { return this->_isPrintCanvas; }
    virtual VOID WINAPI drawBitmap(CBitmap *bmp, LONG x, LONG y);
    
    // Method necessary for drawing tiny font-size texts on printer canvas, because some printers does not draw
    // text of size < 8. Workaround is creating auxiliry bitmap, draw text of proper recalculated size onto it
    // and then blit it onto the printer canvas. Currently works only for vertical and horizontal drawed texts.
    LONG WINAPI drawTinyText(CFont *font, CString s, LONG x, LONG y, BOOL transparent = TRUE, LONG extraFormat = 0, LONG replacementFormat = -1, float rotationAngle = 0.0);

    VOID WINAPI drawDateFieldDDMMYYYY(CFont* font, CString year, CString month, CString day,
        LONG x, LONG y, LONG width, LONG height, LONG groupSpacing, LONG fieldHeight,
        COLORREF borderColor, LONG borderThickness, LONG borderStyle,
        COLORREF backgroundColor, ULONG backgroundStyle, ULONG_PTR backgroundHatch,
        float rotationAngle);
    VOID WINAPI drawLabeledTextField(CFont* font, CFont* labelFont, LONG x, LONG y, LONG width, LONG height,
        CString label, CString text, BOOL eachTextLetterInSeparateBox,
        LONG labelOffsetY, LONG labelPaddingLeft, LONG labelPaddingTop, LONG labelPaddingRight, LONG labelPaddingBottom,
        COLORREF labelLineBorderColor, LONG labelLineBorderThickness, LONG labelLineBorderStyle,
        COLORREF labelLineBackgroundColor, ULONG labelLineBackgroundStyle, ULONG_PTR labelLineBackgroundHatchStyle,
        COLORREF borderColor, LONG borderSize, LONG borderStyle,
        COLORREF backgroundColor, ULONG backgroundStyle, ULONG_PTR backgroundHatchStyle,
        COLORREF textFieldBackgroundColor,
        LONG textFieldBoxCount, LONG textFieldSeparatorHeight, LONG textFieldSeparatorThickness,
        float rotationAngle);
    VOID WINAPI drawTextInRectangles(CFont* font, LONG x, LONG y, LONG width, LONG height,
        CString text,
        COLORREF borderColor, LONG borderSize, LONG borderStyle,
        COLORREF backgroundColor, ULONG backgroundStyle, ULONG_PTR backgroundHatchStyle,
        COLORREF unitBorderColor, LONG unitBorderSize, LONG unitBorderStyle,
        COLORREF unitBackgroundColor, ULONG unitBackgroundStyle, ULONG_PTR unitBackgroundHatchStyle,
        LONG unitWidth, LONG unitHeight, LONG unitPadding, LONG spacing, BOOL drawEmptyFields,
        float rotationAngle);

    // gradientDirection can be 0, 1
    //VOID WINAPI drawGradientedRectangle(LONG x, LONG y, LONG width, LONG height, float borderThickness = 1.0, Color borderColor, Color startGradientColor = Color(0xff,0x99,0xcc,0xff), Color endGradientColor = Color(0xff,0x00,0x00,0x66), LONG gradientDirection = 0, float rotationAngle = 0.0);
    VOID WINAPI drawGradientedRectangle(LONG x, LONG y, LONG width, LONG height, LONG borderThickness = 1, COLORREF borderColor = 0, COLORREF startGradientColor= RGB(0x99,0xcc,0xff), COLORREF endGradientColor = RGB(0x00,0x00,0x66), LONG gradientDirection = 0, float rotationAngle = 0.0);
    
protected:
    // if this is a printer canvas
    BOOL _isPrintCanvas;
    
    VOID WINAPI _commonInit(BOOL isPrintCanvas);
    virtual VOID WINAPI _cleanup();
private:
};

typedef CCanvas* PCanvas;

#endif
