55 lines
1.2 KiB
C++
55 lines
1.2 KiB
C++
#ifdef _COUNTRY_ME_
|
|
|
|
#pragma once
|
|
|
|
//#include <string>
|
|
#include "Pango/PangoCairo.h"
|
|
#include "KTextParagraph.h"
|
|
#include "KTypes.h"
|
|
|
|
class KTextParagraph;
|
|
|
|
class KTextLayout
|
|
{
|
|
public:
|
|
KTextLayout( int nWidth, int nHeight = -1, int nSpacing = 3, DWORD dwAlign = 0 );
|
|
~KTextLayout();
|
|
|
|
KSize GetLayoutSize( KTextParagraph* pParagraph );
|
|
void Render( KTextParagraph* pParagraph );
|
|
void SplitLine( std::vector< std::string > & vecLineList, const std::string& strOriginal, const char* szFontName, int nFontSize, bool bBold );
|
|
|
|
int GetImageStride()
|
|
{
|
|
assert( m_surface );
|
|
return cairo_image_surface_get_stride( m_surface );
|
|
}
|
|
void* GetImage()
|
|
{
|
|
assert( m_surface );
|
|
return cairo_image_surface_get_data( m_surface );
|
|
}
|
|
static bool InitLayoutEngine();
|
|
static void DestroyLayoutEngine();
|
|
|
|
protected:
|
|
void _Render( LPCSTR szText, double r, double g, double b, double a, double dX = 0, double dY = 0 );
|
|
void Layout( KTextParagraph* pParagraph );
|
|
|
|
private:
|
|
cairo_t *m_cr;
|
|
cairo_surface_t *m_surface;
|
|
PangoContext* m_context;
|
|
PangoLayout* m_layout;
|
|
|
|
int m_nWidth;
|
|
int m_nHeight;
|
|
int m_nSpacing;
|
|
DWORD m_dwAlign;
|
|
|
|
public:
|
|
static PangoFontMap* s_pFontMap;
|
|
static PangoContext* s_pPangoContext;
|
|
};
|
|
|
|
#endif |