// void rowPositioning(pROWCELL cell, int &dist)
//
// Вычисляет прямоугольники элементов контакта, учитывая выравнивание в контейнере
// cell - указатель на корневой узел дерева описания контакта
// dist - новая ширина контакта
//
void rowPositioning(pROWCELL cell, int &dist)
{
	ROWCELL* curchild = NULL;

	int x = cell->r.left;
	int y = cell->r.top;

	int h = cell->r.bottom;
	int w = dist;

	int valign = 0;
	int halign = 0;

	int r = 0;
	int size = 0;
	int cw = 0;
  int fixedsized=0;
  int autosized=0;
	int dummy = 0;
	
	// Коррректировка назначаемой ширины dist
	if (w < cell->r.right && (cell->type < TC_TEXT1 || cell->type > TC_TEXT3 && cell->type!=TC_SPACE) || !cell->sizing) 
		dist = w = cell->r.right;

	cell->r.right= dist;
    dummy=dist;
	if (!(curchild = cell->child)) 
	{
		rowPlacing(cell);
		return;
	}

	// Позиционирование контейнеров в строке
	if (cell->cont == TC_ROW)
	{
    fixedsized=cell->fixed_width;
		while (curchild)
		{
			// Контейнеры layer не должны влиять на позиционирование контейнеров tc
			if (curchild->layer)
			{
				curchild = curchild->next;
				continue;
			}

			cw += curchild->r.right;
			
			if (curchild->sizing) 
			{
				autosized+=max(curchild->w,curchild->full_width);
				r++;
			}
			else 
				size += curchild->r.right;

			curchild = curchild->next;
		}
			
		w -= size;
    fixedsized-=size;

		if (r == 0)
		{
			switch(cell->halign)
			{
				case TC_HCENTER:
					x += (dist - cw)/2;// - 1;
					break;
				case TC_RIGHT:
					x += dist - cw; 
					break;
			}
		}
		

		curchild = cell->child;
			
		size = 0;
		while(curchild)
		{		
			if (curchild->layer)
			{
				//int dummy = 0;
				rowLayerProc(curchild, cell);
				rowPositioning(curchild, dummy);
			}
			else
			{
				curchild->r.top = cell->r.top;
				curchild->r.left = x;		
				

				w -= size;
				if (curchild->sizing) 
				{
          if ((0&!curchild->fitwidth) || r>1)  //пока отключено -проблемы с выравниванием
          {
            if (curchild->hasfixed)
                fixedsized-=curchild->fixed_width;
            switch (cell->halign)
						{
						case TC_RIGHT:
               size=(w-fixedsized)-(autosized-max(curchild->full_width,curchild->w));
               break;
            case TC_LEFT:
               size=min(w-fixedsized,max(curchild->full_width,curchild->w));         
               break;
            case TC_HCENTER:
              if (autosized) {size=max(curchild->full_width,curchild->w)*w/autosized; break;}
						default:
							size = w / r;
            }
            autosized-=(max(curchild->full_width,curchild->w));
            if (autosized<0) autosized=0;
            if (size<0) size=0;
          }
					else size = w;
          /*  пока отключено ибо параметр влияет на выравнивание включается по левому краю
           if (0 &&!curchild->fitwidth)
            if(size>max(curchild->full_width,curchild->w))
              size=max(curchild->full_width,curchild->w);
           */
          r--;
				}
				else 
					size = curchild->r.right;

				rowPositioning(curchild, size);
				x += size;
			
				if (!curchild->sizing) 
					size=0;
			}

			curchild = curchild->next;
		}
	}

	// Позиционирование контейнеров в столбце
	if (cell->cont == TC_COL)
	{
		while (curchild)
		{
			// Контейнеры layer не должны влиять на позиционирование контейнеров tr
			if (curchild->layer)
			{
				curchild = curchild->next;
				continue;
			}

			size += curchild->r.bottom;
			curchild = curchild->next;
		}

		if (h > size)
		{
			switch(cell->valign)
			{
				case TC_VCENTER:
					y += (h - size) / 2; 
					break;
				case TC_BOTTOM:
					y += (h - size);
					break;
			}
		}
			
		curchild = cell->child;
		while(curchild)
		{
			if (curchild->layer)
			{
				rowLayerProc(curchild, cell);
				rowPositioning(curchild, dummy);
			}
			else
			{
				curchild->r.top = y;
				y += curchild->r.bottom;

				curchild->r.left  = cell->r.left;
				curchild->r.right = dist;

				rowPositioning(curchild, size);

			}
			
			curchild = curchild->next;
		}
	}

	rowPlacing(cell);

}
Example #2
0
// void rowPositioning(pROWCELL cell, int &dist)
//
// Вычисляет прямоугольники элементов контакта, учитывая выравнивание в контейнере
// cell - указатель на корневой узел дерева описания контакта
// dist - новая ширина контакта
//
void rowPositioning(pROWCELL cell, int &dist)
{
	ROWCELL* curchild = NULL;

	int x = cell->r.left;
	int y = cell->r.top;

	int h = cell->r.bottom;
	int w = dist;

	int r = 0;
	int size = 0;
	int cw = 0;
	int fixedsized = 0;
	int autosized = 0;
	int dummy = 0;

	// Коррректировка назначаемой ширины dist
	if (w < cell->r.right && (cell->type < TC_TEXT1 || cell->type > TC_TEXT3 && cell->type != TC_SPACE) || !cell->sizing)
		dist = w = cell->r.right;

	cell->r.right = dist;
	dummy = dist;
	if (!(curchild = cell->child))
	{
		rowPlacing(cell);
		return;
	}

	// Позиционирование контейнеров в строке
	if (cell->cont == TC_ROW)
	{
		fixedsized = cell->fixed_width;
		while (curchild)
		{
			// Контейнеры layer не должны влиять на позиционирование контейнеров tc
			if (curchild->layer)
			{
				curchild = curchild->next;
				continue;
			}

			cw += curchild->r.right;

			if (curchild->sizing)
			{
				autosized += max(curchild->w,curchild->full_width);
				r++;
			}
			else
				size += curchild->r.right;

			curchild = curchild->next;
		}

		w -= size;
		fixedsized -= size;

		if (r == 0)
		{
			switch(cell->halign)
			{
			case TC_HCENTER:
				x += (dist - cw)/2;// - 1;
				break;
			case TC_RIGHT:
				x += dist - cw;
				break;
			}
		}


		curchild = cell->child;

		size = 0;
		while(curchild)
		{
			if (curchild->layer)
			{
				//int dummy = 0;
				rowLayerProc(curchild, cell);
				rowPositioning(curchild, dummy);
			}
			else
			{
				curchild->r.top = cell->r.top;
				curchild->r.left = x;


				w -= size;
				if (curchild->sizing)
				{
					size = w;
					r--;
				}
				else
					size = curchild->r.right;

				rowPositioning(curchild, size);
				x += size;

				if (!curchild->sizing)
					size = 0;
			}

			curchild = curchild->next;
		}
	}

	// Позиционирование контейнеров в столбце
	if (cell->cont == TC_COL)
	{
		while (curchild)
		{
			// Контейнеры layer не должны влиять на позиционирование контейнеров tr
			if (curchild->layer)
			{
				curchild = curchild->next;
				continue;
			}

			size += curchild->r.bottom;
			curchild = curchild->next;
		}

		if (h > size)
		{
			switch(cell->valign)
			{
			case TC_VCENTER:
				y += (h - size) / 2;
				break;
			case TC_BOTTOM:
				y += (h - size);
				break;
			}
		}

		curchild = cell->child;
		while(curchild)
		{
			if (curchild->layer)
			{
				rowLayerProc(curchild, cell);
				rowPositioning(curchild, dummy);
			}
			else
			{
				curchild->r.top = y;
				y += curchild->r.bottom;

				curchild->r.left  = cell->r.left;
				curchild->r.right = dist;

				rowPositioning(curchild, size);

			}

			curchild = curchild->next;
		}
	}

	rowPlacing(cell);

}