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