Beispiel #1
0
static void get_size(SsdWidget w, SsdSize * pack_size, RoadMapGuiRect * max_size){
	if (!(w->flags & SSD_VAR_SIZE) && w->children) {
		RoadMapGuiRect container_rect = *max_size;
		int container_width;
		int container_height;

		w->draw (w, max_size, SSD_GET_SIZE);

		container_width  = max_size->minx - container_rect.minx +
				container_rect.maxx - max_size->maxx;
		container_height = max_size->miny - container_rect.miny +
				container_rect.maxy - max_size->maxy;

		calc_pack_size (w->children, max_size, pack_size);

		pack_size->width  += container_width;
		pack_size->height += container_height;

	} else {
		w->draw (w, max_size, SSD_GET_SIZE);
		pack_size->width  = max_size->maxx - max_size->minx + 1;
		pack_size->height = max_size->maxy - max_size->miny + 1;
	}
}
Beispiel #2
0
void ssd_widget_get_size (SsdWidget w, SsdSize *size, const SsdSize *max) {

   SsdSize pack_size = {0, 0};

   RoadMapGuiRect max_size = {0, 0, 0, 0};
   int total_height_below = 0;

   *size = w->size;

   if ((w->size.height >= 0) && (w->size.width >= 0)) {
      return;
   }

   if (!max && (w->cached_size.width < 0)) {
       static SsdSize canvas_size;

       canvas_size.width   = roadmap_canvas_width();
#ifdef TOUCH_SCREEN
 	   canvas_size.height  = roadmap_canvas_height() ;
#else
       canvas_size.height  = roadmap_canvas_height() - roadmap_bar_bottom_height();
#endif
       max = &canvas_size;
   }
   else{
   	if (!max)
   		max = &w->cached_size;
   }



   if ((w->cached_size.width >= 0) && (w->cached_size.height >= 0)) {
      *size = w->cached_size;
      return;
   }
   /* Comment by AGA. THere is no assignment for this flag
   if (size->height == SSD_MAX_SIZE) {
      // Check if other siblings exists and should be placed below this one
      SsdWidget below_w = w->next;


      while (below_w) {

         if (below_w->flags & SSD_ORDER_LAST) {
            SsdSize s;
            ssd_widget_get_size (below_w, &s, max);

            total_height_below += s.height;
         }
         below_w = below_w->next;
      }

   }
   */

   if ((w->flags & SSD_DIALOG_FLOAT) && !(w->flags & SSD_DIALOG_TRANSPARENT)){
      if ((size->width == SSD_MAX_SIZE) && ((max->width >= roadmap_canvas_width()) || (max->width >= roadmap_canvas_height()))){
         if (roadmap_canvas_width() > roadmap_canvas_height())
            size->width = roadmap_canvas_height();
         else
            size->width = roadmap_canvas_width()- ADJ_SCALE(20);
#ifdef IPHONE
         size->width = ADJ_SCALE(320);
#endif

      }else
         if (size->width == SSD_MAX_SIZE) size->width = max->width -ADJ_SCALE(20);
      if (size->height== SSD_MAX_SIZE) size->height= max->height - total_height_below;

   } else {

      if (size->width == SSD_MAX_SIZE) size->width = max->width;
      if (size->height== SSD_MAX_SIZE) size->height= max->height - total_height_below;
   }

#ifdef IPHONE_NATIVE
   if (size->width > ADJ_SCALE(320))
      size->width = ADJ_SCALE(320);
#endif //IPHONE

   if ((size->height >= 0) && (size->width >= 0)) {
      w->cached_size = *size;
      return;
   }

   if (size->width >= 0)  {
      max_size.maxx = size->width - 1;
   } else {
      if (!max){
                static SsdSize canvas_size;
                canvas_size.width = roadmap_canvas_width();
#ifdef TOUCH_SCREEN
				canvas_size.height = roadmap_canvas_height();
#else
                canvas_size.height = roadmap_canvas_height() - roadmap_bar_bottom_height();
#endif
                max = &canvas_size;
      }
      max_size.maxx = max->width - 1;
   }

   if (size->height >= 0) {
      max_size.maxy = size->height - 1;
   } else {
      max_size.maxy = max->height - 1;
   }

   if (!(w->flags & SSD_VAR_SIZE) && w->children) {
      RoadMapGuiRect container_rect = max_size;
      int container_width;
      int container_height;

      w->draw (w, &max_size, SSD_GET_SIZE);

      container_width  = max_size.minx - container_rect.minx +
                         container_rect.maxx - max_size.maxx;
      container_height = max_size.miny - container_rect.miny +
                         container_rect.maxy - max_size.maxy;

      calc_pack_size (w->children, &max_size, &pack_size);

      pack_size.width  += container_width;
      pack_size.height += container_height;

   } else {
      w->draw (w, &max_size, SSD_GET_SIZE);
      pack_size.width  = max_size.maxx - max_size.minx + 1;
      pack_size.height = max_size.maxy - max_size.miny + 1;
   }

   if (size->height< 0) size->height = pack_size.height;
   if (size->width < 0) size->width  = pack_size.width;

   w->cached_size = *size;
}