예제 #1
0
/* 
 * StatsListDrawItem:  Message handler for stats list boxes.  Return TRUE iff
 *   message is handled.
 */
BOOL StatsListDrawItem(HWND hwnd, const DRAWITEMSTRUCT *lpdis)
{
   AREA stats_area;

   if (hList == NULL)
      return TRUE;

   switch (lpdis->itemAction)
   {
   case ODA_SELECT:
   case ODA_DRAWENTIRE:
      /* If box is empty, do nothing */
      if (lpdis->itemID == -1)
	 return TRUE;

      /* Draw window background at correct offset */
      StatsGetArea(&stats_area);
      DrawWindowBackgroundColor(pinventory_bkgnd(), lpdis->hDC, (RECT *) (&lpdis->rcItem),			//	was NULL
				stats_area.x + lpdis->rcItem.left,
				stats_area.y + lpdis->rcItem.top + StatsGetButtonBorder(), -1);

      /* Draw info on stat */
	  StatsListDrawStat(lpdis, (Bool) (lpdis->itemState & ODS_SELECTED), (Bool)( StatsGetCurrentGroup() == STATS_SPELLS ) );
      break;

   case ODA_FOCUS:
//      DrawFocusRect(lpdis->hDC, &lpdis->rcItem);
      break;
   }
   
   return TRUE;
}
예제 #2
0
/*
 * StatsListResize:  Called when main window resized.
 */
void StatsListResize(list_type stats)
{
   AREA stats_area;
   int y;

   StatsGetArea(&stats_area);

   y = StatsGetButtonBorder();
   MoveWindow(hList, 0, y, stats_area.cx, stats_area.cy - y, TRUE);

   // Hide scrollbar if not needed
   num_visible = (stats_area.cy - y) / max(ListBox_GetItemHeight(hList, 0), 1);
   if (num_visible >= ListBox_GetCount(hList))
     SetScrollRange(hList, SB_VERT, 0, 0, TRUE);
   else
     {
       SetScrollRange(hList, SB_VERT, 0, ListBox_GetCount(hList) - num_visible, TRUE);
       SetScrollPos(hList, SB_VERT, ListBox_GetTopIndex(hList), TRUE);
     }

	if( StatsGetCurrentGroup() != STATS_INVENTORY )			//	ajw
		ShowWindow(hList, SW_NORMAL);
}
예제 #3
0
/*
 * StatsNumCreate:  Create numeric stat controls for given stats.
 */
void StatsNumCreate(list_type stats)
{
   list_type l;
   int y, height;
   
   // Create graph controls for integer stats
   height = GetFontHeight(GetFont(FONT_STATS)) + STATUS_SPACING;	 
   y = StatsGetButtonBorder();
   for (l = stats; l != NULL; l = l->next)
   {
      Statistic *s = (Statistic *) (l->data);
      
      s->y = y;
      s->cy = height;
      y += height;
      
      if (s->numeric.tag != STAT_INT)
	 continue;
      
      s->hControl = CreateWindow(GraphCtlGetClassName(), NULL,
				 WS_CHILD | GCS_LIMITBAR | GCS_NUMBER,
				 0, 0, 0, 0, hStats,
				 NULL, hInst, NULL);
      
      StatsNumChangeStat(s);
   }
   
   stats_scrollbar_width = GetSystemMetrics(SM_CXVSCROLL);
   hStatsScroll = CreateWindow("scrollbar", NULL, WS_CHILD | SBS_VERT,
			       0, 0, 100, 100,  /* Make sure scrollbar drawn ok */
			       hStats, NULL, hInst, NULL);
   top_stat = 0;
   
   // Set colors of graphs
   StatsChangeColor();
}
예제 #4
0
/*
 * StatsNumResize:  Called when main window resized.
 */
void StatsNumResize(list_type stats)
{
   int x, y, height, count, num_stats;
   list_type l;
   AREA stats_area;
   Bool has_scrollbar = False;

   StatsGetArea(&stats_area);

   // First, see how many stats will fit
   y = StatsGetButtonBorder();
   num_visible = 0;
   num_stats = 0;
   for (l = stats; l != NULL; l = l->next)
   {
      Statistic *s = (Statistic *) (l->data);

      if (s->numeric.tag != STAT_INT)
         continue;

      num_stats++;

      if (y + s->cy <= stats_area.cy)
      {
         y += s->cy;
         num_visible++;
      }
   }

   if (num_visible < num_stats)
      has_scrollbar = True;

   top_stat = min(top_stat, num_stats - num_visible);

   // Move graph bars
   x = stats_area.cx / 2;
   stats_bar_width = has_scrollbar ? 
     stats_area.cx / 2 - stats_scrollbar_width - 1 : stats_area.cx / 2;
   stats_bar_width -= RIGHT_BORDER;
   num_visible = 0;
   count = 0;

   y = StatsGetButtonBorder();

   for (l = stats; l != NULL; l = l->next)
   {
      Statistic *s = (Statistic *) (l->data);

      if (s->numeric.tag != STAT_INT)
         continue;

      // Take into account position of scrollbar
      if (count++ < top_stat)
      {
         ShowWindow(s->hControl, SW_HIDE);
         continue;
      }

      // Center bar vertically
      s->y = y;
      y += s->cy;

      MoveWindow(s->hControl, x, s->y + (s->cy - STATS_BAR_HEIGHT) / 2,
         stats_bar_width, STATS_BAR_HEIGHT, TRUE);

      // Only show graph bar if it's completely visible
      // And Inventory is not selected.	ajw
      if (s->y + s->cy <= stats_area.cy && StatsGetCurrentGroup() != STATS_INVENTORY)
      {
         ShowWindow(s->hControl, SW_NORMAL);
         num_visible++;
      }
      else
         ShowWindow(s->hControl, SW_HIDE);
      height = s->cy;
   }

   // Show scrollbar if necessary
   if (has_scrollbar)
   {
      y = StatsGetButtonBorder();
      MoveWindow(hStatsScroll, stats_area.cx - stats_scrollbar_width, 
         y, stats_scrollbar_width, num_visible * height, FALSE);
      ShowWindow(hStatsScroll, SW_HIDE);
      SetScrollRange(hStatsScroll, SB_CTL, 0, num_stats - num_visible, TRUE);
      SetScrollPos(hStatsScroll, SB_CTL, top_stat, TRUE);
      if( StatsGetCurrentGroup() != STATS_INVENTORY )	//	ajw
         ShowWindow(hStatsScroll, SW_SHOWNORMAL);
   }
   else
      ShowWindow(hStatsScroll, SW_HIDE);

   StatsDraw();
}