Beispiel #1
0
LOCAL void SelectBegin(HWND hWindow, int x, int y)
/***********************************************************************/
{
RECT rect;

// get the listbox data pointer, if we don't have one, get out
LPLISTBOXDATA lpData = ListBox_GetData(hWindow);
if (!lpData)
	return;

// the number of items in the list box
lpData->iCount = ListBox_GetCount(hWindow);         

// get the client area
GetClientRect(hWindow, &rect);        
  
// the height of each item   
lpData->iItemHeight = ListBox_GetItemHeight(hWindow, 0);          

// the number of visible items                  
lpData->iVisible = (rect.bottom - rect.top) / lpData->iItemHeight;

// setup a timer for scrolling the list
lpData->idTimer = NULL;
lpData->idTimer = SetTimer(hWindow, 1, 100, NULL);  

// make sure we get all messages
SetCapture(hWindow);

// init values for dragging
lpData->fCapture = TRUE;
lpData->iCurPos = -1;
lpData->fSuccess = FALSE;
}
Beispiel #2
0
/*
 * StatsListLButton:  User clicked left button on stats list.
 */
void StatsListLButton(HWND hwnd, BOOL fDoubleClick, int x, int y, UINT keyFlags)
{
   int index;

   SetFocus(hwnd);
   index = y / ListBox_GetItemHeight(hwnd, 0) + ListBox_GetTopIndex(hwnd);

   if (index >= ListBox_GetCount(hwnd))
      return;

   ListBox_SetCurSel(hwnd, index);	
}
Beispiel #3
0
/*
 * StatsListRButton:  User clicked right button on stats list.
 */
void StatsListRButton(HWND hwnd, BOOL fDoubleClick, int x, int y, UINT keyFlags)
{
   int index;
   Statistic *s;

   SetFocus(hwnd);
   index = y / ListBox_GetItemHeight(hwnd, 0) + ListBox_GetTopIndex(hwnd);

   if (index >= ListBox_GetCount(hwnd))
      return;

   ListBox_SetCurSel(hwnd, index);	

   s = (Statistic *) ListBox_GetItemData(hwnd, index);
   if (s == NULL)
      return;
 
   SetDescParams(cinfo->hMain, DESC_NONE);
   RequestLook(s->list.id);
}
Beispiel #4
0
/* Give a mouse coordinate, this function returns the index of
 * the item under the mouse cursor.
 */
int FASTCALL ItemFromPoint( HWND hwndList, short x, short y )
{
   int cVisibleItems;
   int nItemHeight;
   int nTopIndex;

   /* Get the height of each item in the list box. This assumes that
    * each item the listbox is the same height. It will fail if the listbox
    * has the LBS_OWNERDRAWVARIABLE style.
    */
   nItemHeight = ListBox_GetItemHeight( hwndList, 0 );
   if( 0 == nItemHeight )
      return( LB_ERR );

   /* We're now sure that the cursor is in the listbox, so compute the index
    * of the item under the cursor.
    */
   nTopIndex = ListBox_GetTopIndex( hwndList );
   cVisibleItems = ListBox_GetCount( hwndList ) - nTopIndex;
   return( min( y / nItemHeight, cVisibleItems - 1 ) + nTopIndex );
}
Beispiel #5
0
/*
 * StatsListLButtonDblClk:  User double-clicked left button on stats list.			ajw
 */
void StatsListLButtonDblClk(HWND hwnd, BOOL fDoubleClick, int x, int y, UINT keyFlags)
{
   char pszLabel[256];
   char pszCommand[256];
   int iLabelLen;
   int index = y / ListBox_GetItemHeight(hwnd, 0) + ListBox_GetTopIndex(hwnd);
   
   if (index >= ListBox_GetCount(hwnd))
      return;

   if ((GetPlayerInfo()->viewID != 0) && (GetPlayerInfo()->viewID != GetPlayerInfo()->id))
   {
      if (!(GetPlayerInfo()->viewFlags & REMOTE_VIEW_CAST))
         return;
   }
   ListBox_SetCurSel(hwnd, index);
   iLabelLen = ListBox_GetTextLen( hwnd, index );

   if( ListBox_GetText( hwnd, index, pszLabel ) != LB_ERR )
   {
      if( StatsGetCurrentGroup() == STATS_SPELLS )
      {
	 strcpy( pszCommand, "zaubern " );
      }
      else if (StatsGetCurrentGroup() == STATS_SKILLS)
      {
	 strcpy( pszCommand, "perform " );
	 return; // not implimented yet
      }
      else
      {
	 return;  // not going to do anything for non skills/stats
      }
      strcat( pszCommand, pszLabel );
      PerformAction( A_GOTOMAIN, NULL );	//	For targeting icon to appear, focus must be on main view window.
      PerformAction( A_TEXTCOMMAND, pszCommand );
   }
}
Beispiel #6
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);
}
Beispiel #7
0
LOCAL void Select_OnKeyDown(HWND hWindow, UINT vk, BOOL fDown, int cRepeat, UINT flags)
/***********************************************************************/
{
int iCaretIndex, iTopItem, nItems;

// get the listbox data pointer
LPLISTBOXDATA lpData = ListBox_GetData(hWindow);
if (!lpData)
	{
	FORWARD_WM_KEYDOWN(hWindow, vk, cRepeat, flags, ListBox_CallWindowProc);
	}
else
if (vk == VK_UP)
	{
	iTopItem = ListBox_GetTopIndex(hWindow);
	iCaretIndex = ListBox_GetCaretIndex(hWindow);
	--iCaretIndex;
	if (iCaretIndex < 0)
		return;
	// make sure the new top item is selected
	SelectItems(hWindow, iCaretIndex);
	// scroll the listbox and make sure it gets repainted
	if (iCaretIndex < iTopItem)
		ListBox_SetTopIndex(hWindow, iCaretIndex);
	UpdateWindow(hWindow);
	FORWARD_WM_COMMAND(GetParent(hWindow), GetDlgCtrlID(hWindow),
					hWindow, LBN_SELCHANGE, SendMessage);
	}
else
if (vk == VK_DOWN)
	{
	RECT rect;
	int iItemHeight, iVisible;

	iTopItem = ListBox_GetTopIndex(hWindow);
	iCaretIndex = ListBox_GetCaretIndex(hWindow);
	++iCaretIndex;
	nItems = ListBox_GetCount(hWindow);
	if (iCaretIndex >= nItems)
		return;
	// make sure the new top item is selected
	SelectItems(hWindow, iCaretIndex);

	// get the client area
	GetClientRect(hWindow, &rect);        
  
	// the height of each item   
	iItemHeight = ListBox_GetItemHeight(hWindow, 0);          

	// the number of visible items                  
	iVisible = (rect.bottom - rect.top) / iItemHeight;

	// see if there is anything to scroll
	if (iCaretIndex >= (iTopItem+iVisible))	
		{
		++iTopItem;
		ListBox_SetTopIndex(hWindow, iTopItem);
		}
	UpdateWindow(hWindow);
	FORWARD_WM_COMMAND(GetParent(hWindow), GetDlgCtrlID(hWindow),
					hWindow, LBN_SELCHANGE, SendMessage);
	}
// ignore all other keystrokes
}