cosmetic changes : indentation etc.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@4398 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Václav Slavík
1999-11-06 15:41:14 +00:00
parent 5c172c1788
commit 01325161d5
2 changed files with 235 additions and 275 deletions

View File

@@ -73,8 +73,7 @@ wxHtmlImageMapAreaCell::wxHtmlImageMapAreaCell( wxHtmlImageMapAreaCell::celltype
wxString x = incoords, y; wxString x = incoords, y;
type = t; type = t;
while ((i = x.Find( ',' )) != -1) while ((i = x.Find( ',' )) != -1) {
{
coords.Add( wxAtoi( x.Left( i ).c_str() ) ); coords.Add( wxAtoi( x.Left( i ).c_str() ) );
x = x.Mid( i + 1 ); x = x.Mid( i + 1 );
} }
@@ -83,8 +82,7 @@ wxHtmlImageMapAreaCell::wxHtmlImageMapAreaCell( wxHtmlImageMapAreaCell::celltype
wxString wxHtmlImageMapAreaCell::GetLink( int x, int y ) const wxString wxHtmlImageMapAreaCell::GetLink( int x, int y ) const
{ {
switch (type) switch (type) {
{
case RECT: case RECT:
{ {
int l, t, r, b; int l, t, r, b;
@@ -93,8 +91,7 @@ wxString wxHtmlImageMapAreaCell::GetLink( int x, int y ) const
t = coords[ 1 ]; t = coords[ 1 ];
r = coords[ 2 ]; r = coords[ 2 ];
b = coords[ 3 ]; b = coords[ 3 ];
if (x >= l && x <= r && y >= t && y <= b) if (x >= l && x <= r && y >= t && y <= b) {
{
return m_Link; return m_Link;
} }
break; break;
@@ -108,16 +105,14 @@ wxString wxHtmlImageMapAreaCell::GetLink( int x, int y ) const
t = coords[ 1 ]; t = coords[ 1 ];
r = coords[ 2 ]; r = coords[ 2 ];
d = sqrt( (double) (((x - l) * (x - l)) + ((y - t) * (y - t))) ); d = sqrt( (double) (((x - l) * (x - l)) + ((y - t) * (y - t))) );
if (d < (double)r) if (d < (double)r) {
{
return m_Link; return m_Link;
} }
} }
break; break;
case POLY: case POLY:
{ {
if (coords.GetCount() >= 6) if (coords.GetCount() >= 6) {
{
int intersects = 0; int intersects = 0;
int wherex = x; int wherex = x;
int wherey = y; int wherey = y;
@@ -128,64 +123,46 @@ wxString wxHtmlImageMapAreaCell::GetLink( int x, int y ) const
int end = totalc; int end = totalc;
int pointer = 1; int pointer = 1;
if ((yval >= wherey) != (coords[pointer] >= wherey)) if ((yval >= wherey) != (coords[pointer] >= wherey)) {
{ if ((xval >= wherex) == (coords[0] >= wherex)) {
if ((xval >= wherex) == (coords[0] >= wherex))
{
intersects += (xval >= wherex) ? 1 : 0; intersects += (xval >= wherex) ? 1 : 0;
} } else {
else
{
intersects += ((xval - (yval - wherey) * intersects += ((xval - (yval - wherey) *
(coords[0] - xval) / (coords[0] - xval) /
(coords[pointer] - yval)) >= wherex) ? 1 : 0; (coords[pointer] - yval)) >= wherex) ? 1 : 0;
} }
} }
while (pointer < end) while (pointer < end) {
{
yval = coords[pointer]; yval = coords[pointer];
pointer += 2; pointer += 2;
if (yval >= wherey) if (yval >= wherey) {
{ while ((pointer < end) && (coords[pointer] >= wherey)) {
while((pointer < end) && (coords[pointer] >= wherey))
{
pointer += 2; pointer += 2;
} }
if (pointer >= end) if (pointer >= end) {
{
break; break;
} }
if ((coords[pointer - 3] >= wherex) == if ((coords[pointer - 3] >= wherex) ==
(coords[pointer-1] >= wherex)) (coords[pointer - 1] >= wherex)) {
{
intersects += (coords[pointer - 3] >= wherex) ? 1 : 0; intersects += (coords[pointer - 3] >= wherex) ? 1 : 0;
} } else {
else
{
intersects += intersects +=
((coords[pointer - 3] - (coords[pointer - 2] - wherey) * ((coords[pointer - 3] - (coords[pointer - 2] - wherey) *
(coords[pointer - 1] - coords[pointer - 3]) / (coords[pointer - 1] - coords[pointer - 3]) /
(coords[pointer] - coords[pointer - 2])) >= wherex) ? 1 : 0; (coords[pointer] - coords[pointer - 2])) >= wherex) ? 1 : 0;
} }
} } else {
else while ((pointer < end) && (coords[pointer] < wherey)) {
{
while((pointer < end) && (coords[pointer] < wherey))
{
pointer += 2; pointer += 2;
} }
if (pointer >= end) if (pointer >= end) {
{
break; break;
} }
if ((coords[pointer - 3] >= wherex) == if ((coords[pointer - 3] >= wherex) ==
(coords[pointer-1] >= wherex)) (coords[pointer - 1] >= wherex)) {
{
intersects += (coords[pointer - 3] >= wherex) ? 1 : 0; intersects += (coords[pointer - 3] >= wherex) ? 1 : 0;
} } else {
else
{
intersects += intersects +=
((coords[pointer - 3] - (coords[pointer - 2] - wherey) * ((coords[pointer - 3] - (coords[pointer - 2] - wherey) *
(coords[pointer - 1] - coords[pointer - 3]) / (coords[pointer - 1] - coords[pointer - 3]) /
@@ -193,16 +170,14 @@ wxString wxHtmlImageMapAreaCell::GetLink( int x, int y ) const
} }
} }
} }
if ((intersects & 1) != 0) if ((intersects & 1) != 0) {
{
return m_Link; return m_Link;
} }
} }
} }
break; break;
} }
if (m_Next) if (m_Next) {
{
wxHtmlImageMapAreaCell *a = (wxHtmlImageMapAreaCell*)m_Next; wxHtmlImageMapAreaCell *a = (wxHtmlImageMapAreaCell*)m_Next;
return a->GetLink( x, y ); return a->GetLink( x, y );
} }
@@ -251,8 +226,7 @@ wxString wxHtmlImageMapCell::GetLink( int x, int y ) const
const wxHtmlCell *wxHtmlImageMapCell::Find( int cond, const void *param ) const const wxHtmlCell *wxHtmlImageMapCell::Find( int cond, const void *param ) const
{ {
if (cond == wxHTML_COND_ISIMAGEMAP) if (cond == wxHTML_COND_ISIMAGEMAP) {
{
if (m_Name == *((wxString*)(param))) if (m_Name == *((wxString*)(param)))
return this; return this;
} }
@@ -305,18 +279,21 @@ wxHtmlImageCell::wxHtmlImageCell(wxFSFile *input, int w, int h, int align, wxStr
if ((m_Width != ww) || (m_Height != hh)) { if ((m_Width != ww) || (m_Height != hh)) {
wxImage img2 = img -> Scale(m_Width, m_Height); wxImage img2 = img -> Scale(m_Width, m_Height);
m_Image = new wxBitmap(img2.ConvertToBitmap()); m_Image = new wxBitmap(img2.ConvertToBitmap());
} } else
else
m_Image = new wxBitmap(img -> ConvertToBitmap()); m_Image = new wxBitmap(img -> ConvertToBitmap());
delete img; delete img;
} }
switch (align) { switch (align) {
case wxHTML_ALIGN_TOP : case wxHTML_ALIGN_TOP :
m_Descent = m_Height; break; m_Descent = m_Height;
break;
case wxHTML_ALIGN_CENTER : case wxHTML_ALIGN_CENTER :
m_Descent = m_Height / 2; break; m_Descent = m_Height / 2;
case wxHTML_ALIGN_BOTTOM : default : break;
m_Descent = 0; break; case wxHTML_ALIGN_BOTTOM :
default :
m_Descent = 0;
break;
} }
m_ImageMap = NULL; m_ImageMap = NULL;
@@ -337,19 +314,16 @@ wxString wxHtmlImageCell::GetLink( int x, int y ) const
{ {
if (m_MapName.IsEmpty()) if (m_MapName.IsEmpty())
return wxHtmlCell::GetLink( x, y ); return wxHtmlCell::GetLink( x, y );
if (!m_ImageMap) if (!m_ImageMap) {
{
wxHtmlContainerCell *p, *op; wxHtmlContainerCell *p, *op;
op = p = GetParent(); op = p = GetParent();
while (p) while (p) {
{
op = p; op = p;
p = p->GetParent(); p = p->GetParent();
} }
p = op; p = op;
wxHtmlCell *cell = (wxHtmlCell*)p->Find( wxHTML_COND_ISIMAGEMAP, (const void*)(&m_MapName)); wxHtmlCell *cell = (wxHtmlCell*)p->Find( wxHTML_COND_ISIMAGEMAP, (const void*)(&m_MapName));
if (!cell) if (!cell) {
{
((wxString&)m_MapName).Clear(); ((wxString&)m_MapName).Clear();
return wxHtmlCell::GetLink( x, y ); return wxHtmlCell::GetLink( x, y );
} }
@@ -372,8 +346,7 @@ TAG_HANDLER_BEGIN(IMG, "IMG, MAP, AREA")
TAG_HANDLER_PROC(tag) TAG_HANDLER_PROC(tag)
{ {
if (tag.GetName() == "IMG") if (tag.GetName() == "IMG") {
{
if (tag.HasParam("SRC")) { if (tag.HasParam("SRC")) {
int w = -1, h = -1; int w = -1, h = -1;
int al; int al;
@@ -391,11 +364,9 @@ TAG_HANDLER_BEGIN(IMG, "IMG, MAP, AREA")
if (alstr == "TEXTTOP") al = wxHTML_ALIGN_TOP; if (alstr == "TEXTTOP") al = wxHTML_ALIGN_TOP;
else if ((alstr == "CENTER") || (alstr == "ABSCENTER")) al = wxHTML_ALIGN_CENTER; else if ((alstr == "CENTER") || (alstr == "ABSCENTER")) al = wxHTML_ALIGN_CENTER;
} }
if (tag.HasParam("USEMAP")) if (tag.HasParam("USEMAP")) {
{
mn = tag.GetParam( "USEMAP" ); mn = tag.GetParam( "USEMAP" );
if (mn[ 0 ] == '#') if (mn[ 0 ] == '#') {
{
mn = mn.Mid( 1 ); mn = mn.Mid( 1 );
} }
} }
@@ -408,12 +379,10 @@ TAG_HANDLER_BEGIN(IMG, "IMG, MAP, AREA")
} }
} }
} }
if (tag.GetName() == "MAP") if (tag.GetName() == "MAP") {
{
m_WParser->CloseContainer(); m_WParser->CloseContainer();
m_WParser->OpenContainer(); m_WParser->OpenContainer();
if (tag.HasParam("NAME")) if (tag.HasParam("NAME")) {
{
wxString tmp = tag.GetParam("NAME"); wxString tmp = tag.GetParam("NAME");
wxHtmlImageMapCell *cel = new wxHtmlImageMapCell( tmp ); wxHtmlImageMapCell *cel = new wxHtmlImageMapCell( tmp );
m_WParser->GetContainer()->InsertCell( cel ); m_WParser->GetContainer()->InsertCell( cel );
@@ -422,32 +391,23 @@ TAG_HANDLER_BEGIN(IMG, "IMG, MAP, AREA")
m_WParser->CloseContainer(); m_WParser->CloseContainer();
m_WParser->OpenContainer(); m_WParser->OpenContainer();
} }
if (tag.GetName() == "AREA") if (tag.GetName() == "AREA") {
{ if (tag.HasParam("SHAPE")) {
if (tag.HasParam("SHAPE"))
{
wxString tmp = tag.GetParam("SHAPE"); wxString tmp = tag.GetParam("SHAPE");
wxString coords; wxString coords;
tmp.MakeUpper(); tmp.MakeUpper();
wxHtmlImageMapAreaCell *cel = NULL; wxHtmlImageMapAreaCell *cel = NULL;
if (tag.HasParam("COORDS")) if (tag.HasParam("COORDS")) {
{
coords = tag.GetParam("COORDS"); coords = tag.GetParam("COORDS");
} }
if (tmp == "POLY") if (tmp == "POLY") {
{
cel = new wxHtmlImageMapAreaCell( wxHtmlImageMapAreaCell::POLY, coords ); cel = new wxHtmlImageMapAreaCell( wxHtmlImageMapAreaCell::POLY, coords );
} } else if (tmp == "CIRCLE") {
else if (tmp == "CIRCLE")
{
cel = new wxHtmlImageMapAreaCell( wxHtmlImageMapAreaCell::CIRCLE, coords ); cel = new wxHtmlImageMapAreaCell( wxHtmlImageMapAreaCell::CIRCLE, coords );
} } else if (tmp == "RECT") {
else if (tmp == "RECT")
{
cel = new wxHtmlImageMapAreaCell( wxHtmlImageMapAreaCell::RECT, coords ); cel = new wxHtmlImageMapAreaCell( wxHtmlImageMapAreaCell::RECT, coords );
} }
if (cel != NULL && tag.HasParam("HREF")) if (cel != NULL && tag.HasParam("HREF")) {
{
wxString tmp = tag.GetParam("HREF"); wxString tmp = tag.GetParam("HREF");
cel->SetLink( tmp ); cel->SetLink( tmp );
} }
@@ -458,7 +418,7 @@ TAG_HANDLER_BEGIN(IMG, "IMG, MAP, AREA")
return FALSE; return FALSE;
} }
TAG_HANDLER_END(IMAGE) TAG_HANDLER_END(IMG)