MCUXpresso_LPC55S69/boards/lpcxpresso55s69/ew_gui_examples/ew_gui_animated_list/GeneratedCode/Views.c
2022-04-08 22:42:47 +08:00

1124 lines
37 KiB
C

/*******************************************************************************
*
* E M B E D D E D W I Z A R D P R O J E C T
*
* Copyright (c) TARA Systems GmbH
* written by Paul Banach and Manfred Schweyer
*
********************************************************************************
*
* This software is delivered "as is" and shows the usage of other software
* components. It is provided as an example software which is intended to be
* modified and extended according to particular requirements.
*
* TARA Systems hereby disclaims all warranties and conditions with regard to the
* software, including all implied warranties and conditions of merchantability
* and non-infringement of any third party IPR or other rights which may result
* from the use or the inability to use the software.
*
* This file was generated automatically by Embedded Wizard Studio.
*
* Please do not make any modifications of this file! The modifications are lost
* when the file is generated again by Embedded Wizard Studio!
*
* Version : 10.0
* Date : 17.02.2021 8:00:50
* Profile : NxpLpc
* Platform : NXP.LPC.RGB565
*
*******************************************************************************/
#include "ewlocale.h"
#include "_CoreGroup.h"
#include "_GraphicsCanvas.h"
#include "_ResourcesFont.h"
#include "_ViewsRectangle.h"
#include "_ViewsText.h"
#include "Core.h"
#include "Views.h"
/* Strings for the language 'Default'. */
static const unsigned short _StringsDefault0[] =
{
0xFFFF, 0xFFFF, 0xC557, 0xFEFF, 0x0000
};
/* Constant values used in this 'C' module only. */
static const XColor _Const0000 = { 0xFF, 0xFF, 0xFF, 0xFF };
static const XPoint _Const0001 = { 0, 0 };
static const XStringRes _Const0002 = { _StringsDefault0, 0x0003 };
static const XRect _Const0003 = {{ 0, 0 }, { 0, 0 }};
/* Initializer for the class 'Views::Rectangle' */
void ViewsRectangle__Init( ViewsRectangle _this, XObject aLink, XHandle aArg )
{
/* At first initialize the super class ... */
CoreRectView__Init( &_this->_Super, aLink, aArg );
/* Allow the Immediate Garbage Collection to evalute the members of this class. */
_this->_GCT = EW_CLASS_GCT( ViewsRectangle );
/* Setup the VMT pointer */
_this->_VMT = EW_CLASS( ViewsRectangle );
/* ... and initialize objects, variables, properties, etc. */
_this->ColorBL = _Const0000;
_this->ColorBR = _Const0000;
_this->ColorTR = _Const0000;
_this->ColorTL = _Const0000;
}
/* Re-Initializer for the class 'Views::Rectangle' */
void ViewsRectangle__ReInit( ViewsRectangle _this )
{
/* At first re-initialize the super class ... */
CoreRectView__ReInit( &_this->_Super );
}
/* Finalizer method for the class 'Views::Rectangle' */
void ViewsRectangle__Done( ViewsRectangle _this )
{
/* Finalize this class */
_this->_Super._VMT = EW_CLASS( CoreRectView );
/* Don't forget to deinitialize the super class ... */
CoreRectView__Done( &_this->_Super );
}
/* The method Draw() is invoked automatically if parts of the view should be redrawn
on the screen. This can occur when e.g. the view has been moved or the appearance
of the view has changed before.
Draw() is invoked automatically by the framework, you never will need to invoke
this method directly. However you can request an invocation of this method by
calling the method InvalidateArea() of the views @Owner. Usually this is also
unnecessary unless you are developing your own view.
The passed parameters determine the drawing destination aCanvas and the area
to redraw aClip in the coordinate space of the canvas. The parameter aOffset
contains the displacement between the origin of the views owner and the origin
of the canvas. You will need it to convert views coordinates into these of the
canvas.
The parameter aOpacity contains the opacity descended from this view's @Owner.
It lies in range 0 .. 255. If the view implements its own 'Opacity', 'Color',
etc. properties, the Draw() method should calculate the resulting real opacity
by mixing the values of these properties with the one passed in aOpacity parameter.
The parameter aBlend contains the blending mode descended from this view's @Owner.
It determines, whether the view should be drawn with alpha-blending active or
not. If aBlend is false, the outputs of the view should overwrite the corresponding
pixel in the drawing destination aCanvas. If aBlend is true, the outputs should
be mixed with the pixel already stored in aCanvas. For this purpose all Graphics
Engine functions provide a parameter to specify the mode for the respective drawing
operation. If the view implements its own 'Blend' property, the Draw() method
should calculate the resulting real blend mode by using logical AND operation
of the value of the property and the one passed in aBlend parameter. */
void ViewsRectangle_Draw( ViewsRectangle _this, GraphicsCanvas aCanvas, XRect aClip,
XPoint aOffset, XInt32 aOpacity, XBool aBlend )
{
aBlend = (XBool)( aBlend && (( _this->Super2.viewState & CoreViewStateAlphaBlended )
== CoreViewStateAlphaBlended ));
aOpacity = aOpacity + 1;
if ( aOpacity < 256 )
{
XColor ctl = _this->ColorTL;
XColor ctr = _this->ColorTR;
XColor cbl = _this->ColorBL;
XColor cbr = _this->ColorBR;
ctl.Alpha = (XUInt8)(( aOpacity * ctl.Alpha ) >> 8 );
ctr.Alpha = (XUInt8)(( aOpacity * ctr.Alpha ) >> 8 );
cbl.Alpha = (XUInt8)(( aOpacity * cbl.Alpha ) >> 8 );
cbr.Alpha = (XUInt8)(( aOpacity * cbr.Alpha ) >> 8 );
GraphicsCanvas_FillRectangle( aCanvas, aClip, EwMoveRectPos( _this->Super1.Bounds,
aOffset ), ctl, ctr, cbr, cbl, aBlend );
}
else
GraphicsCanvas_FillRectangle( aCanvas, aClip, EwMoveRectPos( _this->Super1.Bounds,
aOffset ), _this->ColorTL, _this->ColorTR, _this->ColorBR, _this->ColorBL, aBlend );
}
/* 'C' function for method : 'Views::Rectangle.OnSetColor()' */
void ViewsRectangle_OnSetColor( ViewsRectangle _this, XColor value )
{
if ((( !EwCompColor( value, _this->ColorTL ) && !EwCompColor( value, _this->ColorTR ))
&& !EwCompColor( value, _this->ColorBL )) && !EwCompColor( value, _this->ColorBR ))
return;
_this->ColorTL = value;
_this->ColorTR = value;
_this->ColorBL = value;
_this->ColorBR = value;
if (( _this->Super2.Owner != 0 ) && (( _this->Super2.viewState & CoreViewStateVisible )
== CoreViewStateVisible ))
CoreGroup__InvalidateArea( _this->Super2.Owner, _this->Super1.Bounds );
}
/* Variants derived from the class : 'Views::Rectangle' */
EW_DEFINE_CLASS_VARIANTS( ViewsRectangle )
EW_END_OF_CLASS_VARIANTS( ViewsRectangle )
/* Virtual Method Table (VMT) for the class : 'Views::Rectangle' */
EW_DEFINE_CLASS( ViewsRectangle, CoreRectView, _None, _None, _None, _None, _None,
_None, "Views::Rectangle" )
CoreRectView_initLayoutContext,
CoreView_GetRoot,
ViewsRectangle_Draw,
CoreView_HandleEvent,
CoreView_CursorHitTest,
CoreRectView_ArrangeView,
CoreRectView_MoveView,
CoreRectView_GetExtent,
CoreView_ChangeViewState,
CoreRectView_OnSetBounds,
EW_END_OF_CLASS( ViewsRectangle )
/* Initializer for the class 'Views::Text' */
void ViewsText__Init( ViewsText _this, XObject aLink, XHandle aArg )
{
/* At first initialize the super class ... */
CoreRectView__Init( &_this->_Super, aLink, aArg );
/* Allow the Immediate Garbage Collection to evalute the members of this class. */
_this->_GCT = EW_CLASS_GCT( ViewsText );
/* Setup the VMT pointer */
_this->_VMT = EW_CLASS( ViewsText );
/* ... and initialize objects, variables, properties, etc. */
_this->Orientation = ViewsOrientationNormal;
_this->ColorBL = _Const0000;
_this->ColorBR = _Const0000;
_this->ColorTR = _Const0000;
_this->ColorTL = _Const0000;
_this->Alignment = ViewsTextAlignmentAlignHorzCenter | ViewsTextAlignmentAlignVertCenter;
_this->Opacity = 255;
}
/* Re-Initializer for the class 'Views::Text' */
void ViewsText__ReInit( ViewsText _this )
{
/* At first re-initialize the super class ... */
CoreRectView__ReInit( &_this->_Super );
}
/* Finalizer method for the class 'Views::Text' */
void ViewsText__Done( ViewsText _this )
{
/* Call the user defined destructor of the class */
ViewsText_Done( _this );
/* Finalize this class */
_this->_Super._VMT = EW_CLASS( CoreRectView );
/* Don't forget to deinitialize the super class ... */
CoreRectView__Done( &_this->_Super );
}
/* 'C' function for method : 'Views::Text.Done()' */
void ViewsText_Done( ViewsText _this )
{
if ( _this->bidiContext != 0 )
{
ViewsText_freeBidi( _this, _this->bidiContext );
_this->bidiContext = 0;
}
}
/* The method Draw() is invoked automatically if parts of the view should be redrawn
on the screen. This can occur when e.g. the view has been moved or the appearance
of the view has changed before.
Draw() is invoked automatically by the framework, you never will need to invoke
this method directly. However you can request an invocation of this method by
calling the method InvalidateArea() of the views @Owner. Usually this is also
unnecessary unless you are developing your own view.
The passed parameters determine the drawing destination aCanvas and the area
to redraw aClip in the coordinate space of the canvas. The parameter aOffset
contains the displacement between the origin of the views owner and the origin
of the canvas. You will need it to convert views coordinates into these of the
canvas.
The parameter aOpacity contains the opacity descended from this view's @Owner.
It lies in range 0 .. 255. If the view implements its own 'Opacity', 'Color',
etc. properties, the Draw() method should calculate the resulting real opacity
by mixing the values of these properties with the one passed in aOpacity parameter.
The parameter aBlend contains the blending mode descended from this view's @Owner.
It determines, whether the view should be drawn with alpha-blending active or
not. If aBlend is false, the outputs of the view should overwrite the corresponding
pixel in the drawing destination aCanvas. If aBlend is true, the outputs should
be mixed with the pixel already stored in aCanvas. For this purpose all Graphics
Engine functions provide a parameter to specify the mode for the respective drawing
operation. If the view implements its own 'Blend' property, the Draw() method
should calculate the resulting real blend mode by using logical AND operation
of the value of the property and the one passed in aBlend parameter. */
void ViewsText_Draw( ViewsText _this, GraphicsCanvas aCanvas, XRect aClip, XPoint
aOffset, XInt32 aOpacity, XBool aBlend )
{
XSet align;
XEnum orient;
ResourcesFont font;
XRect rd;
XColor ctl;
XColor ctr;
XColor cbr;
XColor cbl;
XInt32 opacity;
XInt32 noOfRows;
XRect area;
XPoint ofs;
XInt32 leading;
XInt32 rowHeight;
XInt32 clipY1;
XInt32 clipY2;
XInt32 areaW;
XInt32 y;
XInt32 i;
XInt32 c;
/* Dummy expressions to avoid the 'C' warning 'unused argument'. */
EW_UNUSED_ARG( aBlend );
if ( !EwCompString( _this->flowString, 0 ) || ( _this->Font == 0 ))
return;
align = _this->Alignment;
orient = _this->Orientation;
font = _this->Font;
rd = EwMoveRectPos( _this->Super1.Bounds, aOffset );
ctl = _this->ColorTL;
ctr = _this->ColorTR;
cbr = _this->ColorBR;
cbl = _this->ColorBL;
opacity = ((( aOpacity + 1 ) * _this->Opacity ) >> 8 ) + 1;
noOfRows = EwGetStringChar( _this->flowString, 0 );
area = EwMoveRectPos( ViewsText_GetContentArea( _this ), aOffset );
ofs = EwNewPoint( rd.Point1.X - area.Point1.X, ( rd.Point1.Y - area.Point1.Y )
- font->Ascent );
if ( noOfRows < 1 )
return;
if ( opacity < 256 )
{
ctl.Alpha = (XUInt8)(( ctl.Alpha * opacity ) >> 8 );
ctr.Alpha = (XUInt8)(( ctr.Alpha * opacity ) >> 8 );
cbr.Alpha = (XUInt8)(( cbr.Alpha * opacity ) >> 8 );
cbl.Alpha = (XUInt8)(( cbl.Alpha * opacity ) >> 8 );
}
if ((( align & ViewsTextAlignmentAlignHorzAuto ) == ViewsTextAlignmentAlignHorzAuto ))
{
if ( ViewsText_IsBaseDirectionRTL( _this ))
align = ( align & ~ViewsTextAlignmentAlignHorzAuto ) | ViewsTextAlignmentAlignHorzRight;
else
align = ( align & ~ViewsTextAlignmentAlignHorzAuto ) | ViewsTextAlignmentAlignHorzLeft;
}
if ((( noOfRows == 1 ) && !(( align & ViewsTextAlignmentAlignHorzJustified ) ==
ViewsTextAlignmentAlignHorzJustified )) && ( orient == ViewsOrientationNormal ))
{
GraphicsCanvas_DrawText( aCanvas, aClip, font, _this->flowString, 2, EwGetStringChar(
_this->flowString, 1 ) - 1, rd, ofs, 0, orient, ctl, ctr, cbr, cbl, 1 );
return;
}
leading = font->Leading;
if ( _this->RowDistance > 0 )
leading = ( _this->RowDistance - font->Ascent ) - font->Descent;
rowHeight = ( font->Ascent + font->Descent ) + leading;
clipY1 = aClip.Point1.Y - area.Point1.Y;
clipY2 = aClip.Point2.Y - area.Point1.Y;
areaW = EwGetRectW( area );
y = 0;
i = 1;
c = EwGetStringChar( _this->flowString, i );
if ( orient == ViewsOrientationRotated_90 )
{
ofs = EwNewPoint( area.Point2.Y - rd.Point2.Y, ( rd.Point1.X - area.Point1.X )
- font->Ascent );
clipY1 = aClip.Point1.X - area.Point1.X;
clipY2 = aClip.Point2.X - area.Point1.X;
areaW = EwGetRectH( area );
}
else
if ( orient == ViewsOrientationRotated_180 )
{
ofs = EwNewPoint( area.Point2.X - rd.Point2.X, ( area.Point2.Y - rd.Point2.Y )
- font->Ascent );
clipY1 = area.Point2.Y - aClip.Point2.Y;
clipY2 = area.Point2.Y - aClip.Point1.Y;
}
else
if ( orient == ViewsOrientationRotated_270 )
{
ofs = EwNewPoint( rd.Point1.Y - area.Point1.Y, ( area.Point2.X - rd.Point2.X )
- font->Ascent );
clipY1 = area.Point2.X - aClip.Point2.X;
clipY2 = area.Point2.X - aClip.Point1.X;
areaW = EwGetRectH( area );
}
while ((( y + rowHeight ) < clipY1 ) && ( c > 0 ))
{
i = i + c;
y = y + rowHeight;
c = EwGetStringChar( _this->flowString, i );
}
while (( y < clipY2 ) && ( c > 0 ))
{
XPoint ofs2 = EwMovePointNeg( ofs, EwNewPoint( 0, y ));
XInt32 rw = 0;
XBool justified = 0;
if ((((( align & ViewsTextAlignmentAlignHorzJustified ) == ViewsTextAlignmentAlignHorzJustified )
&& ( EwGetStringChar( _this->flowString, ( i + c ) - 1 ) != 0x000A )) &&
( EwGetStringChar( _this->flowString, i + 1 ) != 0x000A )) && ( EwGetStringChar(
_this->flowString, i + c ) != 0x0000 ))
justified = 1;
if ( justified && !!( align & ( ViewsTextAlignmentAlignHorzCenter | ViewsTextAlignmentAlignHorzRight )))
{
XInt32 rowEnd = i + c;
XInt32 blank1 = EwStringFindChar( _this->flowString, 0x0020, i + 1 );
XInt32 blank2 = EwStringFindChar( _this->flowString, 0x00A0, i + 1 );
if ((( blank1 < 0 ) || ( blank1 >= rowEnd )) && (( blank2 < 0 ) || ( blank2
>= rowEnd )))
justified = 0;
}
if ( justified )
rw = areaW;
else
if ((( align & ViewsTextAlignmentAlignHorzRight ) == ViewsTextAlignmentAlignHorzRight ))
ofs2.X = (( ofs2.X - areaW ) + ResourcesFont_GetTextAdvance( font, _this->flowString,
i + 1, c - 1 ));
else
if ((( align & ViewsTextAlignmentAlignHorzCenter ) == ViewsTextAlignmentAlignHorzCenter ))
ofs2.X = (( ofs2.X - ( areaW / 2 )) + ( ResourcesFont_GetTextAdvance(
font, _this->flowString, i + 1, c - 1 ) / 2 ));
GraphicsCanvas_DrawText( aCanvas, aClip, font, _this->flowString, i + 1, c -
1, rd, ofs2, rw, orient, ctl, ctr, cbr, cbl, 1 );
i = i + c;
y = y + rowHeight;
c = EwGetStringChar( _this->flowString, i );
}
}
/* 'C' function for method : 'Views::Text.OnSetBounds()' */
void ViewsText_OnSetBounds( ViewsText _this, XRect value )
{
XBool resized;
if ( !EwCompRect( value, _this->Super1.Bounds ))
return;
if (( _this->Orientation == ViewsOrientationNormal ) || ( _this->Orientation ==
ViewsOrientationRotated_180 ))
resized = (XBool)( EwGetRectW( _this->Super1.Bounds ) != EwGetRectW( value ));
else
resized = (XBool)( EwGetRectH( _this->Super1.Bounds ) != EwGetRectH( value ));
if (((( resized && ( _this->WrapWidth == 0 )) && _this->WrapText ) && _this->reparsed )
&& !(( _this->Super2.viewState & CoreViewStateUpdatingLayout ) == CoreViewStateUpdatingLayout ))
{
_this->flowString = 0;
_this->reparsed = 0;
EwPostSignal( EwNewSlot( _this, ViewsText_preReparseSlot ), ((XObject)_this ));
}
if ((( _this->Ellipsis && _this->reparsed ) && EwCompPoint( EwGetRectSize( _this->Super1.Bounds ),
EwGetRectSize( value ))) && !(( _this->Super2.viewState & CoreViewStateUpdatingLayout )
== CoreViewStateUpdatingLayout ))
{
_this->flowString = 0;
_this->reparsed = 0;
EwPostSignal( EwNewSlot( _this, ViewsText_preReparseSlot ), ((XObject)_this ));
}
CoreRectView_OnSetBounds((CoreRectView)_this, value );
EwPostSignal( EwNewSlot( _this, ViewsText_preOnUpdateSlot ), ((XObject)_this ));
}
/* 'C' function for method : 'Views::Text.freeBidi()' */
void ViewsText_freeBidi( ViewsText _this, XHandle aBidi )
{
/* Dummy expressions to avoid the 'C' warning 'unused argument'. */
EW_UNUSED_ARG( _this );
if ( aBidi == 0 )
return;
EwFreeBidi( aBidi );
}
/* 'C' function for method : 'Views::Text.createBidi()' */
XHandle ViewsText_createBidi( ViewsText _this, XInt32 aSize )
{
XHandle bidi;
/* Dummy expressions to avoid the 'C' warning 'unused argument'. */
EW_UNUSED_ARG( _this );
bidi = 0;
bidi = EwCreateBidi( aSize );
return bidi;
}
/* 'C' function for method : 'Views::Text.preOnUpdateSlot()' */
void ViewsText_preOnUpdateSlot( ViewsText _this, XObject sender )
{
/* Dummy expressions to avoid the 'C' warning 'unused argument'. */
EW_UNUSED_ARG( sender );
EwPostSignal( _this->OnUpdate, ((XObject)_this ));
}
/* 'C' function for method : 'Views::Text.preReparseSlot()' */
void ViewsText_preReparseSlot( ViewsText _this, XObject sender )
{
/* Dummy expressions to avoid the 'C' warning 'unused argument'. */
EW_UNUSED_ARG( sender );
EwPostSignal( EwNewSlot( _this, ViewsText_reparseSlot ), ((XObject)_this ));
}
/* 'C' function for method : 'Views::Text.reparseSlot()' */
void ViewsText_reparseSlot( ViewsText _this, XObject sender )
{
XEnum orient;
XInt32 width;
XInt32 height;
XInt32 maxWidth;
/* Dummy expressions to avoid the 'C' warning 'unused argument'. */
EW_UNUSED_ARG( sender );
if ( _this->reparsed )
return;
orient = _this->Orientation;
width = EwGetRectW( _this->Super1.Bounds );
height = EwGetRectH( _this->Super1.Bounds );
maxWidth = -1;
if (( orient == ViewsOrientationRotated_90 ) || ( orient == ViewsOrientationRotated_270 ))
{
width = height;
height = EwGetRectW( _this->Super1.Bounds );
}
if ( _this->WrapText )
{
if ( _this->WrapWidth > 0 )
maxWidth = _this->WrapWidth;
else
if ( !_this->AutoSize )
maxWidth = width - ( _this->Padding * 2 );
else
maxWidth = width;
if ( maxWidth < 0 )
maxWidth = 1;
}
if ( _this->bidiContext != 0 )
{
ViewsText_freeBidi( _this, _this->bidiContext );
_this->bidiContext = 0;
}
_this->reparsed = 1;
if (( EwCompString( _this->String, 0 ) != 0 ) && ( _this->Font != 0 ))
{
XInt32 length = EwGetStringLength( _this->String );
if ( _this->EnableBidiText )
_this->bidiContext = ViewsText_createBidi( _this, length );
_this->flowString = EwShareString( ResourcesFont_ParseFlowString( _this->Font,
_this->String, 0, maxWidth, length, _this->bidiContext ));
if (( _this->bidiContext != 0 ) && !ViewsText_IsBidiText( _this ))
{
ViewsText_freeBidi( _this, _this->bidiContext );
_this->bidiContext = 0;
}
}
else
_this->flowString = 0;
_this->textSize = _Const0001;
if ((( _this->Ellipsis && ( EwCompString( _this->flowString, 0 ) != 0 )) && !_this->AutoSize )
&& ( _this->Font != 0 ))
{
XSet align = _this->Alignment;
ResourcesFont font = _this->Font;
XInt32 leading = font->Leading;
XString res = _this->flowString;
XBool rtl = ViewsText_IsBaseDirectionRTL( _this );
XInt32 rh;
XInt32 noOfRows;
XInt32 maxNoOfRows;
XBool clipF;
XBool clipL;
XInt32 row;
XInt32 inx;
XInt32 maxW;
if ((( align & ViewsTextAlignmentAlignHorzAuto ) == ViewsTextAlignmentAlignHorzAuto ))
{
if ( rtl )
align = ( align & ~ViewsTextAlignmentAlignHorzAuto ) | ViewsTextAlignmentAlignHorzRight;
else
align = ( align & ~ViewsTextAlignmentAlignHorzAuto ) | ViewsTextAlignmentAlignHorzLeft;
}
if ( _this->RowDistance > 0 )
leading = ( _this->RowDistance - font->Ascent ) - font->Descent;
rh = ( font->Ascent + font->Descent ) + leading;
noOfRows = EwGetStringChar( res, 0 );
maxNoOfRows = ( height + leading ) / rh;
clipF = 0;
clipL = 0;
if ( maxNoOfRows <= 0 )
maxNoOfRows = 1;
if ( noOfRows > maxNoOfRows )
{
XInt32 row = 0;
XInt32 rowF = 0;
XInt32 rowL = noOfRows - 1;
XInt32 inxF = 0;
XInt32 inxL = EwGetStringLength( res );
XString tmp = 0;
if ((( align & ViewsTextAlignmentAlignVertBottom ) == ViewsTextAlignmentAlignVertBottom ))
rowF = noOfRows - maxNoOfRows;
else
if ((( align & ViewsTextAlignmentAlignVertCenter ) == ViewsTextAlignmentAlignVertCenter ))
{
rowF = ( noOfRows - maxNoOfRows ) / 2;
rowL = ( rowF + maxNoOfRows ) - 1;
}
else
rowL = maxNoOfRows - 1;
clipF = (XBool)( rowF > 0 );
clipL = (XBool)( rowL < ( noOfRows - 1 ));
for ( inxF = 1; row < rowF; row = row + 1 )
inxF = inxF + EwGetStringChar( res, inxF );
if ( clipL )
for ( inxL = inxF; row < rowL; row = row + 1 )
inxL = inxL + EwGetStringChar( res, inxL );
if ( clipF )
{
XInt32 len = EwGetStringChar( res, inxF );
tmp = EwShareString( EwConcatString( EwConcatString( EwLoadString( &_Const0002 ),
EwStringMiddle( res, inxF, len )), EwLoadString( &_Const0002 )));
tmp = EwSetStringChar( tmp, 0, (XChar)( len + 2 ));
inxF = inxF + len;
if ( EwGetStringChar( tmp, len ) == 0x000A )
{
tmp = EwSetStringChar( tmp, len, 0xFEFF );
tmp = EwSetStringChar( tmp, len + 1, 0x000A );
}
if ( EwGetStringChar( tmp, 2 ) == 0x000A )
{
tmp = EwSetStringChar( tmp, 2, 0xFEFF );
tmp = EwSetStringChar( tmp, 1, 0x000A );
}
else
tmp = EwSetStringChar( tmp, 1, 0xFEFF );
}
tmp = EwShareString( EwConcatString( tmp, EwStringMiddle( res, inxF, inxL
- inxF )));
if ( clipL && ( inxL >= inxF ))
{
XInt32 len = EwGetStringChar( res, inxL );
XString tmp2 = EwShareString( EwConcatString( EwConcatString( EwLoadString(
&_Const0002 ), EwStringMiddle( res, inxL, len )), EwLoadString( &_Const0002 )));
tmp2 = EwSetStringChar( tmp2, 0, (XChar)( len + 2 ));
tmp2 = EwSetStringChar( tmp2, 1, 0xFEFF );
if ( EwGetStringChar( tmp2, len ) == 0x000A )
{
tmp2 = EwSetStringChar( tmp2, len, 0xFEFF );
tmp2 = EwSetStringChar( tmp2, len + 1, 0x000A );
}
if ( EwGetStringChar( tmp2, 2 ) == 0x000A )
{
tmp2 = EwSetStringChar( tmp2, 2, 0xFEFF );
tmp2 = EwSetStringChar( tmp2, 1, 0x000A );
}
else
tmp2 = EwSetStringChar( tmp2, 1, 0xFEFF );
tmp = EwShareString( EwConcatString( tmp, tmp2 ));
}
res = EwShareString( EwConcatCharString((XChar)maxNoOfRows, tmp ));
}
row = 0;
inx = 1;
maxW = width - ( _this->Padding * 2 );
if ( _this->WrapText && ( _this->WrapWidth > 0 ))
maxW = _this->WrapWidth;
noOfRows = EwGetStringChar( res, 0 );
for ( ; row < noOfRows; row = row + 1 )
{
XBool rowEllipF = (XBool)( clipF && ( row == 0 ));
XBool rowEllipL = (XBool)( clipL && ( row == ( noOfRows - 1 )));
XBool colEllipF = 0;
XBool colEllipL = 0;
XBool rtl2 = rtl;
XInt32 start;
XInt32 len;
XInt32 inxF;
XInt32 inxL;
XInt32 inxF2;
XInt32 inxL2;
if (( rtl && rowEllipF ) && !rowEllipL )
{
rowEllipF = 0;
rowEllipL = 1;
}
else
if (( rtl && rowEllipL ) && !rowEllipF )
{
rowEllipL = 0;
rowEllipF = 1;
}
start = inx + 1;
len = EwGetStringChar( res, inx );
inxF = start;
inxL = ( start + len ) - 2;
inxF2 = -1;
inxL2 = -1;
if ( !_this->WrapText && ( ResourcesFont_GetTextAdvance( font, res, start,
len - 1 ) > maxW ))
{
if ((( align & ViewsTextAlignmentAlignHorzRight ) == ViewsTextAlignmentAlignHorzRight ))
colEllipF = 1;
else
if ((( align & ViewsTextAlignmentAlignHorzCenter ) == ViewsTextAlignmentAlignHorzCenter ))
{
colEllipF = 1;
colEllipL = 1;
}
else
colEllipL = 1;
}
if ( EwGetStringChar( res, inxF ) == 0x000A )
inxF = inxF + 1;
if ( EwGetStringChar( res, inxL ) == 0x000A )
inxL = inxL - 1;
while ( colEllipF && ( EwGetStringChar( res, inxF ) == 0xFEFF ))
inxF = inxF + 1;
while ( colEllipL && ( EwGetStringChar( res, inxL ) == 0xFEFF ))
inxL = inxL - 1;
colEllipF = (XBool)( colEllipF && !rowEllipL );
colEllipL = (XBool)( colEllipL && !rowEllipF );
while (((( colEllipF || colEllipL ) || rowEllipF ) || rowEllipL ) && ( inxF
< inxL ))
{
if (( colEllipF && ( rtl2 || !colEllipL )) || rowEllipF )
{
if ( inxF2 > 0 )
res = EwSetStringChar( res, inxF2, 0xFEFF );
res = EwSetStringChar( res, inxF, 0x2026 );
inxF2 = inxF;
inxF = inxF + 1;
rtl2 = (XBool)!rtl2;
rowEllipF = 0;
if ( ResourcesFont_GetTextAdvance( font, res, start, len - 1 ) <= maxW )
{
colEllipF = 0;
colEllipL = 0;
}
else
colEllipF = (XBool)( colEllipF || !colEllipL );
}
if (( colEllipL && ( !rtl2 || !colEllipF )) || rowEllipL )
{
if ( inxL2 > 0 )
res = EwSetStringChar( res, inxL2, 0xFEFF );
res = EwSetStringChar( res, inxL, 0x2026 );
inxL2 = inxL;
inxL = inxL - 1;
rtl2 = (XBool)!rtl2;
rowEllipL = 0;
if ( ResourcesFont_GetTextAdvance( font, res, start, len - 1 ) <= maxW )
{
colEllipF = 0;
colEllipL = 0;
}
else
colEllipL = (XBool)( colEllipL || !colEllipF );
}
}
inx = inx + len;
}
_this->textSize = EwNewPoint( ResourcesFont_GetFlowTextAdvance( font, res ),
( EwGetStringChar( res, 0 ) * rh ) - leading );
_this->flowString = EwShareString( res );
}
if ( _this->AutoSize && ( EwCompString( _this->flowString, 0 ) != 0 ))
{
XPoint padding = EwNewPoint( _this->Padding, 0 );
if (( orient == ViewsOrientationRotated_90 ) || ( orient == ViewsOrientationRotated_270 ))
{
padding.Y = padding.X;
padding.X = 0;
}
_this->Super2.viewState = _this->Super2.viewState | CoreViewStateUpdatingLayout;
CoreRectView__OnSetBounds( _this, EwMoveRectNeg( EwInflateRect( ViewsText_GetContentArea(
_this ), padding ), _this->ScrollOffset ));
_this->Super2.viewState = _this->Super2.viewState & ~CoreViewStateUpdatingLayout;
}
if (( _this->Super2.Owner != 0 ) && (( _this->Super2.viewState & CoreViewStateVisible )
== CoreViewStateVisible ))
CoreGroup__InvalidateArea( _this->Super2.Owner, _this->Super1.Bounds );
EwPostSignal( EwNewSlot( _this, ViewsText_preOnUpdateSlot ), ((XObject)_this ));
}
/* 'C' function for method : 'Views::Text.OnSetWrapText()' */
void ViewsText_OnSetWrapText( ViewsText _this, XBool value )
{
if ( value == _this->WrapText )
return;
_this->WrapText = value;
if ( _this->reparsed )
{
_this->flowString = 0;
_this->reparsed = 0;
EwPostSignal( EwNewSlot( _this, ViewsText_preReparseSlot ), ((XObject)_this ));
}
if ( value && ( _this->WrapWidth == 0 ))
_this->Super2.viewState = _this->Super2.viewState & ~CoreViewStateFastReshape;
else
_this->Super2.viewState = _this->Super2.viewState | CoreViewStateFastReshape;
}
/* 'C' function for method : 'Views::Text.OnSetAlignment()' */
void ViewsText_OnSetAlignment( ViewsText _this, XSet value )
{
if ( value == _this->Alignment )
return;
_this->Alignment = value;
if (( _this->Super2.Owner != 0 ) && (( _this->Super2.viewState & CoreViewStateVisible )
== CoreViewStateVisible ))
CoreGroup__InvalidateArea( _this->Super2.Owner, _this->Super1.Bounds );
if ( _this->Ellipsis )
{
_this->flowString = 0;
_this->reparsed = 0;
EwPostSignal( EwNewSlot( _this, ViewsText_preReparseSlot ), ((XObject)_this ));
}
if ( _this->reparsed )
EwPostSignal( EwNewSlot( _this, ViewsText_preOnUpdateSlot ), ((XObject)_this ));
}
/* 'C' function for method : 'Views::Text.OnSetString()' */
void ViewsText_OnSetString( ViewsText _this, XString value )
{
if ( !EwCompString( value, _this->String ))
return;
_this->String = EwShareString( value );
_this->flowString = 0;
_this->reparsed = 0;
EwPostSignal( EwNewSlot( _this, ViewsText_preReparseSlot ), ((XObject)_this ));
}
/* 'C' function for method : 'Views::Text.OnSetFont()' */
void ViewsText_OnSetFont( ViewsText _this, ResourcesFont value )
{
if ( value == _this->Font )
return;
_this->Font = value;
_this->flowString = 0;
_this->reparsed = 0;
EwPostSignal( EwNewSlot( _this, ViewsText_preReparseSlot ), ((XObject)_this ));
}
/* 'C' function for method : 'Views::Text.OnSetColor()' */
void ViewsText_OnSetColor( ViewsText _this, XColor value )
{
if ((( !EwCompColor( value, _this->ColorTL ) && !EwCompColor( value, _this->ColorTR ))
&& !EwCompColor( value, _this->ColorBL )) && !EwCompColor( value, _this->ColorBR ))
return;
_this->ColorTL = value;
_this->ColorTR = value;
_this->ColorBL = value;
_this->ColorBR = value;
if (( _this->Super2.Owner != 0 ) && (( _this->Super2.viewState & CoreViewStateVisible )
== CoreViewStateVisible ))
CoreGroup__InvalidateArea( _this->Super2.Owner, _this->Super1.Bounds );
}
/* 'C' function for method : 'Views::Text.OnSetOpacity()' */
void ViewsText_OnSetOpacity( ViewsText _this, XInt32 value )
{
if ( value > 255 )
value = 255;
if ( value < 0 )
value = 0;
if ( value == _this->Opacity )
return;
_this->Opacity = value;
if (( _this->Super2.Owner != 0 ) && (( _this->Super2.viewState & CoreViewStateVisible )
== CoreViewStateVisible ))
CoreGroup__InvalidateArea( _this->Super2.Owner, _this->Super1.Bounds );
}
/* The method IsBaseDirectionRTL() returns 'true' if the text specified in @String
starts with an RTL (right-to-left) character. This implies the base direction
of the entire text paragraph. If the text starts with an LTR (left-to-right)
sign or the property @EnableBidiText is 'false', this method returns 'false'. */
XBool ViewsText_IsBaseDirectionRTL( ViewsText _this )
{
XBool result;
XHandle bidi;
if ( !_this->reparsed )
EwSignal( EwNewSlot( _this, ViewsText_reparseSlot ), ((XObject)_this ));
if ( _this->bidiContext == 0 )
return 0;
result = 0;
bidi = _this->bidiContext;
result = EwBidiIsRTL( bidi );
return result;
}
/* The method IsBidiText() returns 'true' if the text specified in the property
@String contains any right-to-left contents or any other Bidi algorithm specific
control codes requiring the Bidi processing of this text. Please note, if the
property @EnableBidiText is false, the text is not processed by the Bidi algorithm
and this method returns 'false'. */
XBool ViewsText_IsBidiText( ViewsText _this )
{
XBool result;
XHandle bidi;
if ( !_this->reparsed )
EwSignal( EwNewSlot( _this, ViewsText_reparseSlot ), ((XObject)_this ));
if ( _this->bidiContext == 0 )
return 0;
result = 0;
bidi = _this->bidiContext;
result = EwBidiIsNeeded( bidi );
return result;
}
/* The method GetContentArea() returns the position and the size of an area where
the view will show the text. This area is expressed in coordinates relative to
the top-left corner of the view's @Owner. The method takes in account all properties
which do affect the position and the alignment of the text, e.g. @Alignment,
@Orientation, @ScrollOffset, @WrapText, etc. */
XRect ViewsText_GetContentArea( ViewsText _this )
{
XInt32 leading;
XInt32 rh;
XSet align;
XEnum orient;
XRect bounds;
XInt32 padding;
XInt32 width;
XInt32 height;
XRect rd;
XRect rs;
if ( !EwCompString( _this->String, 0 ) || ( _this->Font == 0 ))
return _Const0003;
if ( !_this->reparsed )
EwSignal( EwNewSlot( _this, ViewsText_reparseSlot ), ((XObject)_this ));
if ( !EwCompString( _this->flowString, 0 ))
return _Const0003;
leading = _this->Font->Leading;
rh = ( _this->Font->Ascent + _this->Font->Descent ) + _this->Font->Leading;
if ( _this->RowDistance > 0 )
{
leading = ( _this->RowDistance - _this->Font->Ascent ) - _this->Font->Descent;
rh = _this->RowDistance;
}
if ( !EwCompPoint( _this->textSize, _Const0001 ))
_this->textSize.X = ResourcesFont_GetFlowTextAdvance( _this->Font, _this->flowString );
_this->textSize.Y = (( EwGetStringChar( _this->flowString, 0 ) * rh ) - leading );
align = _this->Alignment;
orient = _this->Orientation;
bounds = _this->Super1.Bounds;
padding = _this->Padding;
width = EwGetRectW( bounds );
height = EwGetRectH( bounds );
if (( orient == ViewsOrientationRotated_90 ) || ( orient == ViewsOrientationRotated_270 ))
{
width = height;
height = EwGetRectW( bounds );
}
rd = EwNewRect( padding, 0, width - padding, height );
rs = EwNewRect2Point( rd.Point1, EwMovePointPos( rd.Point1, _this->textSize ));
if ((( align & ViewsTextAlignmentAlignHorzAuto ) == ViewsTextAlignmentAlignHorzAuto ))
{
if ( ViewsText_IsBaseDirectionRTL( _this ))
align = ( align & ~ViewsTextAlignmentAlignHorzAuto ) | ViewsTextAlignmentAlignHorzRight;
else
align = ( align & ~ViewsTextAlignmentAlignHorzAuto ) | ViewsTextAlignmentAlignHorzLeft;
}
if ((( align & ViewsTextAlignmentAlignHorzJustified ) == ViewsTextAlignmentAlignHorzJustified ))
{
XInt32 maxWidth = _this->WrapWidth;
if ( maxWidth <= 0 )
maxWidth = width - ( _this->Padding * 2 );
if ( maxWidth < 0 )
maxWidth = 0;
if ( maxWidth > EwGetRectW( rs ))
rs = EwSetRectW( rs, maxWidth );
}
if ( EwGetRectW( rs ) != EwGetRectW( rd ))
{
if ((( align & ViewsTextAlignmentAlignHorzRight ) == ViewsTextAlignmentAlignHorzRight ))
rs = EwSetRectX( rs, rd.Point2.X - EwGetRectW( rs ));
else
if ((( align & ViewsTextAlignmentAlignHorzCenter ) == ViewsTextAlignmentAlignHorzCenter ))
rs = EwSetRectX( rs, ( rd.Point1.X + ( EwGetRectW( rd ) / 2 )) - ( EwGetRectW(
rs ) / 2 ));
}
if ( EwGetRectH( rs ) != EwGetRectH( rd ))
{
if ((( align & ViewsTextAlignmentAlignVertBottom ) == ViewsTextAlignmentAlignVertBottom ))
rs = EwSetRectY( rs, rd.Point2.Y - EwGetRectH( rs ));
else
if ((( align & ViewsTextAlignmentAlignVertCenter ) == ViewsTextAlignmentAlignVertCenter ))
rs = EwSetRectY( rs, ( rd.Point1.Y + ( EwGetRectH( rd ) / 2 )) - ( EwGetRectH(
rs ) / 2 ));
}
if ( orient == ViewsOrientationNormal )
rs = EwMoveRectPos( rs, bounds.Point1 );
else
if ( orient == ViewsOrientationRotated_90 )
{
XPoint org = EwNewPoint( bounds.Point1.X + rs.Point1.Y, bounds.Point2.Y -
rs.Point2.X );
rs = EwNewRect2Point( org, EwMovePointPos( org, EwNewPoint( _this->textSize.Y,
_this->textSize.X )));
}
else
if ( orient == ViewsOrientationRotated_180 )
{
XPoint org = EwNewPoint( bounds.Point2.X - rs.Point2.X, bounds.Point2.Y
- rs.Point2.Y );
rs = EwNewRect2Point( org, EwMovePointPos( org, _this->textSize ));
}
else
if ( orient == ViewsOrientationRotated_270 )
{
XPoint org = EwNewPoint( bounds.Point2.X - rs.Point2.Y, bounds.Point1.Y
+ rs.Point1.X );
rs = EwNewRect2Point( org, EwMovePointPos( org, EwNewPoint( _this->textSize.Y,
_this->textSize.X )));
}
return EwMoveRectPos( rs, _this->ScrollOffset );
}
/* Default onget method for the property 'Opacity' */
XInt32 ViewsText_OnGetOpacity( ViewsText _this )
{
return _this->Opacity;
}
/* Variants derived from the class : 'Views::Text' */
EW_DEFINE_CLASS_VARIANTS( ViewsText )
EW_END_OF_CLASS_VARIANTS( ViewsText )
/* Virtual Method Table (VMT) for the class : 'Views::Text' */
EW_DEFINE_CLASS( ViewsText, CoreRectView, Font, OnUpdate, flowString, flowString,
flowString, bidiContext, "Views::Text" )
CoreRectView_initLayoutContext,
CoreView_GetRoot,
ViewsText_Draw,
CoreView_HandleEvent,
CoreView_CursorHitTest,
CoreRectView_ArrangeView,
CoreRectView_MoveView,
CoreRectView_GetExtent,
CoreView_ChangeViewState,
ViewsText_OnSetBounds,
EW_END_OF_CLASS( ViewsText )
/* Embedded Wizard */