예제 #1
0
//--------------------------------------------------------------------------------
CThreadObject* CThreadObjectPool::GetNextWaiting(DWORD nWait)
	{
	DWORD nStart = CTime::GetCurrentTime().GetTime();
	CThreadObject* pThread = NULL;
	
	CSyncObject* pLocks[2];
	pLocks[0] = &GetWaitingThreads()->m_mutex;
	pLocks[1] = &GetActiveThreads()->m_mutex;

	CMultiLock lock(pLocks, 2, false);

	for(;;)
		{
		// have we waited long enough?
		if(nWait != INFINITE && (DWORD) CTime::GetCurrentTime().GetTime() > nStart + nWait)
			return NULL;

		if(lock.Lock() == -1)
			return NULL;

		// no threads available?
		if(GetWaitingThreads()->GetCount() == 0)
			{
			ASSERT(GetMaxSize() != 0);

			// have we maxed out the pool?
			if(GetActiveThreads()->GetCount() == (long) GetMaxSize())
				{
				lock.Unlock();
				::Sleep(100);
				continue;
				}

			lock.Unlock();

			::Sleep(100);

			// cant add any more?
			if(! IncreasePool())
				continue;

			if(lock.Lock() == -1)
				return NULL;
			}

		break;
		}

	POSITION pos = GetWaitingThreads()->GetHeadPosition();
	if(pos == NULL)
		return NULL;

	pThread = GetWaitingThreads()->GetAt(pos);
	GetWaitingThreads()->RemoveAt(pos);
	lock.Unlock();

	SetThreadActive(pThread);

	return pThread;
	}
예제 #2
0
bool nsIMAPBodyShellCache::AddShellToCache(nsIMAPBodyShell *shell)
{
  // If it's already in the cache, then just return.
  // This has the side-effect of re-ordering the LRU list
  // to put this at the top, which is good, because it's what we want.
  if (FindShellForUID(shell->GetUID(), shell->GetFolderName(), shell->GetContentModified()))
    return true;

  // OK, so it's not in the cache currently.

  // First, for safety sake, remove any entry with the given UID,
  // just in case we have a collision between two messages in different
  // folders with the same UID.
  nsRefPtr<nsIMAPBodyShell> foundShell;
  m_shellHash.Get(shell->GetUID(), getter_AddRefs(foundShell));
  if (foundShell)
  {
    m_shellHash.Remove(foundShell->GetUID());
    m_shellList->RemoveElement(foundShell);
  }

  // Add the new one to the cache
  m_shellList->AppendElement(shell);

  m_shellHash.Put(shell->GetUID(), shell);
  shell->SetIsCached(true);

  // while we're not over our size limit, eject entries
  bool rv = true;
  while (GetSize() > GetMaxSize())
    rv = EjectEntry();

  return rv;

}
예제 #3
0
STDMETHODIMP 
CXRefreshToolbar::GetBandInfo(DWORD dwBandId, DWORD dwViewMode, DESKBANDINFO *pdbi)
{
	DT(TRACE_I(FS(_T("Toolbar[%08X]: GetBandInfo(...)"), this)));
	try
	{
		if( pdbi == NULL )
			return E_INVALIDARG;

		m_dwBandId = dwBandId;
		m_dwViewMode = dwViewMode;

		if( pdbi->dwMask & DBIM_MINSIZE )
		{
			pdbi->ptMinSize = GetMinSize();
		}

		if( pdbi->dwMask & DBIM_MAXSIZE )
		{
			pdbi->ptMaxSize = GetMaxSize();
		}

		if( pdbi->dwMask & DBIM_INTEGRAL )
		{
			pdbi->ptIntegral.x = 1;
			pdbi->ptIntegral.y = 1;
		}

		if( pdbi->dwMask & DBIM_ACTUAL )
		{
			pdbi->ptActual = GetActualSize();
		}

		if( pdbi->dwMask & DBIM_TITLE )
		{
			wcscpy_s(pdbi->wszTitle, GetTitle());
		}

		if( pdbi->dwMask & DBIM_MODEFLAGS )
		{
			pdbi->dwModeFlags = DBIMF_NORMAL | DBIMF_USECHEVRON;
		}

		if( pdbi->dwMask & DBIM_BKCOLOR )
		{
			// use the default background color by removing this flag
			pdbi->dwMask &= ~DBIM_BKCOLOR;
		}

		return S_OK;
	}
	catch (CXRefreshRuntimeError &ex)
	{
		HandleError(ex.ErrorMessage());
		return E_FAIL;
	}
}
예제 #4
0
void wxTopLevelWindowGTK::DoSetSizeHints( int minW, int minH,
                                          int maxW, int maxH,
                                          int incW, int incH )
{
    base_type::DoSetSizeHints(minW, minH, maxW, maxH, incW, incH);
    m_incWidth = incW;
    m_incHeight = incH;

    const wxSize minSize = GetMinSize();
    const wxSize maxSize = GetMaxSize();
    GdkGeometry hints;
    // always set both min and max hints, otherwise GTK will
    // make assumptions we don't want about the unset values
    int hints_mask = GDK_HINT_MIN_SIZE | GDK_HINT_MAX_SIZE;
    hints.min_width = 1;
    hints.min_height = 1;
    hints.max_width = INT_MAX;
    hints.max_height = INT_MAX;
    int decorSize_x;
    int decorSize_y;
#ifdef HAS_CLIENT_DECOR
    if (HasClientDecor(m_widget))
    {
        decorSize_x = 0;
        decorSize_y = 0;
    }
    else
#endif
    {
        decorSize_x = m_decorSize.left + m_decorSize.right;
        decorSize_y = m_decorSize.top + m_decorSize.bottom;
    }
    if (minSize.x > decorSize_x)
        hints.min_width = minSize.x - decorSize_x;
    if (minSize.y > decorSize_y)
        hints.min_height = minSize.y - decorSize_y;
    if (maxSize.x > 0)
    {
        hints.max_width = maxSize.x - decorSize_x;
        if (hints.max_width < hints.min_width)
            hints.max_width = hints.min_width;
    }
    if (maxSize.y > 0)
    {
        hints.max_height = maxSize.y - decorSize_y;
        if (hints.max_height < hints.min_height)
            hints.max_height = hints.min_height;
    }
    if (incW > 0 || incH > 0)
    {
        hints_mask |= GDK_HINT_RESIZE_INC;
        hints.width_inc  = incW > 0 ? incW : 1;
        hints.height_inc = incH > 0 ? incH : 1;
    }
    gtk_window_set_geometry_hints(
        (GtkWindow*)m_widget, NULL, &hints, (GdkWindowHints)hints_mask);
}
예제 #5
0
oexBOOL CDataPacket::VerifyPacket()
{
	// Do we already know there is a valid packet?
	if ( m_bValidPacket ) 
        return oexTRUE;

	oexUINT uAvailable = 0;

	do
	{
		// Attempt to find a packet in the buffer
		if ( !FindPacket( &m_ph, &uAvailable ) )
			return oexFALSE;

		// Verify the length of the packet is available
		if ( m_ph.dwLength > uAvailable ) 
            return oexFALSE;

		// Enforce maximum packet size
		if ( m_ph.dwLength <= GetMaxSize() )
		{
			oexUCHAR    *pBuf = oexNULL;
			oexUINT     uSize = 0, uView = 0;

			// Initialize the check sum
			oexGUID csCur, csBuf;
            oss::CMd5 md5;

			// Calculate the md5 hash
			while ( GetReadView( uView++, 0, m_ph.dwLength - sizeof( oexGUID ), &pBuf, &uSize ) )

				// Update the md5 hash
				md5.Update( pBuf, uSize );

			// What is our calculated checksum?
            md5.Final( &csCur );

			// Read the checksum from the buffer
			Peek( &csBuf, sizeof( csBuf ), oexNULL, m_ph.dwLength - sizeof( oexGUID ) );

			// Do the checksums match?
            if ( guid::CmpGuid( &csCur, &csBuf ) )
			{	m_bValidPacket = oexTRUE;
				return oexTRUE;
			} // end if

		} // end if

	// Skip over the id
	} while ( AdvanceReadPtr( 4 ) );

	return oexFALSE;
}
static bool
IsValidSizeForFormat(HDC hDC, int format, const gfxIntSize& requested)
{
    gfxIntSize max;
    if (!GetMaxSize(hDC, format, max))
        return true;

    if (requested.width > max.width)
        return false;
    if (requested.height > max.height)
        return false;

    return true;
}
예제 #7
0
void CMuleToolbarCtrl::UpdateIdealSize()
{
	if (theApp.emuledlg->m_ctlMainTopReBar.m_hWnd)
	{
		// let the rebar know what's our new current ideal size, so the chevron is handled correctly..
		CSize sizeBar;
		GetMaxSize(&sizeBar);
		ASSERT( sizeBar.cx != 0 && sizeBar.cy != 0 );

	    REBARBANDINFO rbbi = {0};
	    rbbi.cbSize = sizeof(rbbi);
	    rbbi.fMask = RBBIM_IDEALSIZE;
		rbbi.cxIdeal = sizeBar.cx;
	    VERIFY( theApp.emuledlg->m_ctlMainTopReBar.SetBandInfo(MULE_TOOLBAR_BAND_NR, &rbbi) );
	}
}
예제 #8
0
void CToolBarCtrlEx::UpdateReBarIdealSize()
{
	if(m_hReBarWnd == NULL || ::IsWindow(m_hReBarWnd))
	{
		return;
	}
	// let the rebar know what's our new current ideal size, so the chevron is handled correctly..
	CSize sizeBar;
	GetMaxSize(&sizeBar);
	ASSERT( sizeBar.cx != 0 && sizeBar.cy != 0 );
	
	REBARBANDINFO rbbi = {0};
	rbbi.cbSize = sizeof(rbbi);
	rbbi.fMask = RBBIM_IDEALSIZE;
	rbbi.cxIdeal = sizeBar.cx;
	VERIFY( ::SendMessage(m_hReBarWnd, RB_SETBANDINFO, REBAR_BAND_INDEX0, (LPARAM)&rbbi) );
}
예제 #9
0
STDMETHODIMP 
CUpgradrHelperbar::GetBandInfo(DWORD dwBandId, DWORD dwViewMode, DESKBANDINFO *pdbi)
{
	DT(TRACE_I(FS(_T("Helperbar[%08X]: GetBandInfo(...)"), this)));
	if (!pdbi) return E_INVALIDARG;
	m_BandId = dwBandId;
	m_ViewMode = dwViewMode;

	if( pdbi->dwMask & DBIM_MINSIZE )
	{
		pdbi->ptMinSize = GetMinSize();
	}

	if( pdbi->dwMask & DBIM_MAXSIZE )
	{
		pdbi->ptMaxSize = GetMaxSize();
	}

	if( pdbi->dwMask & DBIM_INTEGRAL )
	{
		pdbi->ptIntegral.x = 1;
		pdbi->ptIntegral.y = 1;
	}

	if( pdbi->dwMask & DBIM_ACTUAL )
	{
		pdbi->ptActual = GetActualSize();
	}

	if( pdbi->dwMask & DBIM_TITLE )
	{
		wcscpy_s(pdbi->wszTitle, GetTitle());
	}

	if( pdbi->dwMask & DBIM_MODEFLAGS )
	{
		pdbi->dwModeFlags = DBIMF_NORMAL | DBIMF_VARIABLEHEIGHT | DBIMF_DEBOSSED;
	}

	if( pdbi->dwMask & DBIM_BKCOLOR )
	{
		//Use the default background color by removing this flag.
		pdbi->dwMask &= ~DBIM_BKCOLOR;
	}
	return S_OK;
}
예제 #10
0
nsSize
nsBox::GetPrefSize(nsBoxLayoutState& aState)
{
  NS_ASSERTION(aState.GetRenderingContext(), "must have rendering context");

  nsSize pref(0,0);
  DISPLAY_PREF_SIZE(this, pref);

  if (IsCollapsed(aState))
    return pref;

  AddBorderAndPadding(pref);
  nsIBox::AddCSSPrefSize(aState, this, pref);

  nsSize minSize = GetMinSize(aState);
  nsSize maxSize = GetMaxSize(aState);
  return BoundsCheck(minSize, pref, maxSize);
}
예제 #11
0
void wxTopLevelWindowGTK::DoSetSizeHints( int minW, int minH,
                                          int maxW, int maxH,
                                          int incW, int incH )
{
    base_type::DoSetSizeHints(minW, minH, maxW, maxH, incW, incH);
    m_incWidth = incW;
    m_incHeight = incH;

    const wxSize minSize = GetMinSize();
    const wxSize maxSize = GetMaxSize();
    GdkGeometry hints;
    // always set both min and max hints, otherwise GTK will
    // make assumptions we don't want about the unset values
    int hints_mask = GDK_HINT_MIN_SIZE | GDK_HINT_MAX_SIZE;
    hints.min_width = 1;
    hints.min_height = 1;
    hints.max_width = INT_MAX;
    hints.max_height = INT_MAX;
    if (minSize.x > m_decorSize.x)
        hints.min_width = minSize.x - m_decorSize.x;
    if (minSize.y > m_decorSize.y)
        hints.min_height = minSize.y - m_decorSize.y;
    if (maxSize.x > 0)
    {
        hints.max_width = maxSize.x - m_decorSize.x;
        if (hints.max_width < hints.min_width)
            hints.max_width = hints.min_width;
    }
    if (maxSize.y > 0)
    {
        hints.max_height = maxSize.y - m_decorSize.y;
        if (hints.max_height < hints.min_height)
            hints.max_height = hints.min_height;
    }
    if (incW > 0 || incH > 0)
    {
        hints_mask |= GDK_HINT_RESIZE_INC;
        hints.width_inc  = incW > 0 ? incW : 1;
        hints.height_inc = incH > 0 ? incH : 1;
    }
    gtk_window_set_geometry_hints(
        (GtkWindow*)m_widget, NULL, &hints, (GdkWindowHints)hints_mask);
}
예제 #12
0
nsSize
nsMenuFrame::GetPrefSize(nsBoxLayoutState& aState)
{
  nsSize size = nsBoxFrame::GetPrefSize(aState);
  DISPLAY_PREF_SIZE(this, size);

  // If we are using sizetopopup="always" then
  // nsBoxFrame will already have enforced the minimum size
  if (!IsSizedToPopup(mContent, PR_TRUE) &&
      IsSizedToPopup(mContent, PR_FALSE) &&
      SizeToPopup(aState, size)) {
    // We now need to ensure that size is within the min - max range.
    nsSize minSize = nsBoxFrame::GetMinSize(aState);
    nsSize maxSize = GetMaxSize(aState);
    size = BoundsCheck(minSize, size, maxSize);
  }

  return size;
}
예제 #13
0
void TopWindow::SyncSizeHints()
{
	GuiLock __; 
	Size min = GetMinSize();
	Size max = GetMaxSize();
	if(!sizeable)
		min = max = GetRect().Size();
	Window w = GetWindow();
	if(w && (min != xminsize || max != xmaxsize) && !frameless) {
		xminsize = min;
		xmaxsize = max;
		size_hints->min_width = min.cx;
		size_hints->min_height = min.cy;
		size_hints->max_width = max.cx;
		size_hints->max_height = max.cy;
		size_hints->flags = PMinSize|PMaxSize;
		XSetWMNormalHints(Xdisplay, w, size_hints);
	}
}
예제 #14
0
gxLayoutStretch::gxLayoutStretch( const Type                     aType,
                                  const gxRect&                  aRect,
                                        gxViewElement::Iterator& aLayoutees,
                                  const bool                     onMajorAxis )
{
    gxPix  iSize = 0;
    
    switch ( aType )
    {
        case None: return;                                           break;
        case Full: iSize = aRect.GetSize( onMajorAxis );             break;
        case Max:  iSize = GetMaxSize( aLayoutees, onMajorAxis );    break;
    }
    
    for ( aLayoutees.First(); aLayoutees.Current(); aLayoutees.Next() )
    {
        aLayoutees.Current()->SetSize( iSize, onMajorAxis );
    }
    
}
예제 #15
0
/**
 * Ok return our dimensions
 */
nsSize
nsImageBoxFrame::GetPrefSize(nsBoxLayoutState& aState)
{
  nsSize size(0,0);
  DISPLAY_PREF_SIZE(this, size);
  if (DoesNeedRecalc(mImageSize))
     GetImageSize();

  if (!mUseSrcAttr && (mSubRect.width > 0 || mSubRect.height > 0))
    size = nsSize(mSubRect.width, mSubRect.height);
  else
    size = mImageSize;
  AddBorderAndPadding(size);
  nsIBox::AddCSSPrefSize(aState, this, size);

  nsSize minSize = GetMinSize(aState);
  nsSize maxSize = GetMaxSize(aState);  

  return BoundsCheck(minSize, size, maxSize);
}
예제 #16
0
nsSize
nsTextControlFrame::GetPrefSize(nsBoxLayoutState& aState)
{
  if (!DoesNeedRecalc(mPrefSize))
     return mPrefSize;

#ifdef DEBUG_LAYOUT
  PropagateDebug(aState);
#endif

  nsSize pref(0,0);

  // FIXME: This inflation parameter isn't correct; we should fix it if
  // we want font size inflation to work well in XUL.  If we do, we can
  // also re-enable the assertion in ComputeAutoSize when inflation is
  // enabled.
  nsresult rv = CalcIntrinsicSize(aState.GetRenderingContext(), pref, 1.0f);
  NS_ENSURE_SUCCESS(rv, pref);
  AddBorderAndPadding(pref);

  bool widthSet, heightSet;
  nsIBox::AddCSSPrefSize(this, pref, widthSet, heightSet);

  nsSize minSize = GetMinSize(aState);
  nsSize maxSize = GetMaxSize(aState);
  mPrefSize = BoundsCheck(minSize, pref, maxSize);

#ifdef DEBUG_rods
  {
    nsMargin borderPadding(0,0,0,0);
    GetBorderAndPadding(borderPadding);
    nsSize size(169, 24);
    nsSize actual(pref.width/15, 
                  pref.height/15);
    printf("nsGfxText(field) %d,%d  %d,%d  %d,%d\n", 
           size.width, size.height, actual.width, actual.height, actual.width-size.width, actual.height-size.height);  // text field
  }
#endif

  return mPrefSize;
}
예제 #17
0
HRESULT CMenuToolbarBase::GetSizes(SIZE* pMinSize, SIZE* pMaxSize, SIZE* pIntegralSize)
{
    if (pMinSize)
        *pMinSize = m_idealSize;
    if (pMaxSize)
        *pMaxSize = m_idealSize;
    if (pIntegralSize)
        *pIntegralSize = m_itemSize;

    if (m_hasSizes)
        return S_OK;

    TRACE("Sizes out of date, recalculating.\n");

    if (!m_hWnd)
    {
        return S_OK;
    }

    // Obtain the ideal size, to be used as min and max
    GetMaxSize(&m_idealSize);
    GetIdealSize((m_initFlags & SMINIT_VERTICAL) != 0, &m_idealSize);

    TRACE("Ideal Size: (%d, %d) for %d buttons\n", m_idealSize, GetButtonCount());

    // Obtain the button size, to be used as the integral size
    DWORD size = GetButtonSize();
    m_itemSize.cx = GET_X_LPARAM(size);
    m_itemSize.cy = GET_Y_LPARAM(size);
    m_hasSizes = TRUE;

    if (pMinSize)
        *pMinSize = m_idealSize;
    if (pMaxSize)
        *pMaxSize = m_idealSize;
    if (pIntegralSize)
        *pIntegralSize = m_itemSize;

    return S_OK;
}
예제 #18
0
void wxTopLevelWindowGTK::DoSetSizeHints( int minW, int minH,
                                          int maxW, int maxH,
                                          int incW, int incH )
{
    base_type::DoSetSizeHints(minW, minH, maxW, maxH, incW, incH);

    const wxSize minSize = GetMinSize();
    const wxSize maxSize = GetMaxSize();
    GdkGeometry hints;
    int hints_mask = 0;
    if (minSize.x > 0 || minSize.y > 0)
    {
        hints_mask |= GDK_HINT_MIN_SIZE;
        hints.min_width = minSize.x - m_decorSize.x;
        if (hints.min_width < 0)
            hints.min_width = 0;
        hints.min_height = minSize.y - m_decorSize.y;
        if (hints.min_height < 0)
            hints.min_height = 0;
    }
    if (maxSize.x > 0 || maxSize.y > 0)
    {
        hints_mask |= GDK_HINT_MAX_SIZE;
        hints.max_width = maxSize.x - m_decorSize.x;
        if (hints.max_width < 0)
            hints.max_width = INT_MAX;
        hints.max_height = maxSize.y - m_decorSize.y;
        if (hints.max_height < 0)
            hints.max_height = INT_MAX;
    }
    if (incW > 0 || incH > 0)
    {
        hints_mask |= GDK_HINT_RESIZE_INC;
        hints.width_inc  = incW > 0 ? incW : 1;
        hints.height_inc = incH > 0 ? incH : 1;
    }
    gtk_window_set_geometry_hints(
        (GtkWindow*)m_widget, NULL, &hints, (GdkWindowHints)hints_mask);
}
예제 #19
0
nsSize
nsTextControlFrame::GetPrefSize(nsBoxLayoutState& aState)
{
  if (!DoesNeedRecalc(mPrefSize))
     return mPrefSize;

#ifdef DEBUG_LAYOUT
  PropagateDebug(aState);
#endif

  nsSize pref(0,0);

  nsresult rv = CalcIntrinsicSize(aState.GetRenderingContext(), pref);
  NS_ENSURE_SUCCESS(rv, pref);
  AddBorderAndPadding(pref);

  PRBool widthSet, heightSet;
  nsIBox::AddCSSPrefSize(this, pref, widthSet, heightSet);

  nsSize minSize = GetMinSize(aState);
  nsSize maxSize = GetMaxSize(aState);
  mPrefSize = BoundsCheck(minSize, pref, maxSize);

#ifdef DEBUG_rods
  {
    nsMargin borderPadding(0,0,0,0);
    GetBorderAndPadding(borderPadding);
    nsSize size(169, 24);
    nsSize actual(pref.width/15, 
                  pref.height/15);
    printf("nsGfxText(field) %d,%d  %d,%d  %d,%d\n", 
           size.width, size.height, actual.width, actual.height, actual.width-size.width, actual.height-size.height);  // text field
  }
#endif

  return mPrefSize;
}
void CXTPDockingPaneSplitterContainer::GetMinMaxInfo(LPMINMAXINFO pMinMaxInfo) const
{
	CXTPDockingPaneBase::GetMinMaxInfo(pMinMaxInfo);

	int nCount = 0;

	POSITION pos = GetHeadPosition();
	while (pos)
	{
		CXTPDockingPaneBase* pPane = GetNext(pos);
		if (pPane->IsEmpty())
			continue;

		nCount++;

		MINMAXINFO info;
		pPane->GetMinMaxInfo(&info);

		if (nCount == 1)
		{
			*pMinMaxInfo = info;

		}
		else
		{
			GetMinSize(pMinMaxInfo, m_bHoriz) += GetMinSize(&info, m_bHoriz);
			GetMaxSize(pMinMaxInfo, m_bHoriz) += GetMaxSize(&info, m_bHoriz);

			GetMinSize(pMinMaxInfo, !m_bHoriz) = max(GetMinSize(pMinMaxInfo, !m_bHoriz), GetMinSize(&info, !m_bHoriz));
			GetMaxSize(pMinMaxInfo, !m_bHoriz) = min(GetMaxSize(pMinMaxInfo, !m_bHoriz), GetMaxSize(&info, !m_bHoriz));
		}
	}

	if (nCount > 0)
	{
		GetMinSize(pMinMaxInfo, m_bHoriz) += GetPaintManager()->m_nSplitterSize * (nCount - 1);
		GetMaxSize(pMinMaxInfo, m_bHoriz) += GetPaintManager()->m_nSplitterSize * (nCount - 1);
	}
}
예제 #21
0
//--------------------------------------------------------------------------------
CThreadObject* CThreadLoadBalancePool::GetNextWaiting(DWORD nWait)
	{
	DWORD nStart = CTime::GetCurrentTime().GetTime();
	CThreadObject* pThread = NULL;
	
	CSyncObject* pLocks[2];
	pLocks[0] = &GetWaitingThreads()->m_mutex;
	pLocks[1] = &GetActiveThreads()->m_mutex;

	CMultiLock lock(pLocks, 2, false);

	for(;;)
		{
		// have we waited long enough?
		if(nWait != INFINITE && (DWORD) CTime::GetCurrentTime().GetTime() > nStart + nWait)
			return NULL;

		if(lock.Lock() == -1)
			return NULL;

		// no threads available?
		if(GetWaitingThreads()->GetCount() == 0)
			{
			ASSERT(GetMaxSize() != 0);

			// have we maxed out the pool?
			if(GetActiveThreads()->GetCount() == (long) GetMaxSize())
				{
				lock.Unlock();
				::Sleep(100);
				continue;
				}

			lock.Unlock();

			::Sleep(100);

			// cant add any more?
			if(! IncreasePool())
				continue;

			if(lock.Lock() == -1)
				return NULL;
			}

		break;
		}

	POSITION pos = GetWaitingThreads()->GetHeadPosition();
	if(pos == NULL)
		return NULL;

	pThread = GetWaitingThreads()->GetAt(pos);
	GetWaitingThreads()->RemoveAt(pos);
	GetWaitingThreads()->AddTail(pThread);
	lock.Unlock();

	// here's the big difference between this function and the
	// version in the ThreadPool
	// the difference is that here we dont move the thread to the active list
	// it will move itself when it's load is "full"
	pThread->OnActivate();

	return pThread;
	}
예제 #22
0
void
nsLeafBoxFrame::Reflow(nsPresContext*   aPresContext,
                     nsHTMLReflowMetrics&     aDesiredSize,
                     const nsHTMLReflowState& aReflowState,
                     nsReflowStatus&          aStatus)
{
  // This is mostly a copy of nsBoxFrame::Reflow().
  // We aren't able to share an implementation because of the frame
  // class hierarchy.  If you make changes here, please keep
  // nsBoxFrame::Reflow in sync.

  DO_GLOBAL_REFLOW_COUNT("nsLeafBoxFrame");
  DISPLAY_REFLOW(aPresContext, this, aReflowState, aDesiredSize, aStatus);

  NS_ASSERTION(aReflowState.ComputedWidth() >=0 &&
               aReflowState.ComputedHeight() >= 0, "Computed Size < 0");

#ifdef DO_NOISY_REFLOW
  printf("\n-------------Starting LeafBoxFrame Reflow ----------------------------\n");
  printf("%p ** nsLBF::Reflow %d R: ", this, myCounter++);
  switch (aReflowState.reason) {
    case eReflowReason_Initial:
      printf("Ini");break;
    case eReflowReason_Incremental:
      printf("Inc");break;
    case eReflowReason_Resize:
      printf("Rsz");break;
    case eReflowReason_StyleChange:
      printf("Sty");break;
    case eReflowReason_Dirty:
      printf("Drt ");
      break;
    default:printf("<unknown>%d", aReflowState.reason);break;
  }
  
  printSize("AW", aReflowState.AvailableWidth());
  printSize("AH", aReflowState.AvailableHeight());
  printSize("CW", aReflowState.ComputedWidth());
  printSize("CH", aReflowState.ComputedHeight());

  printf(" *\n");

#endif

  aStatus = NS_FRAME_COMPLETE;

  // create the layout state
  nsBoxLayoutState state(aPresContext, aReflowState.rendContext);

  nsSize computedSize(aReflowState.ComputedWidth(),aReflowState.ComputedHeight());

  nsMargin m;
  m = aReflowState.ComputedPhysicalBorderPadding();

  //GetBorderAndPadding(m);

  // this happens sometimes. So lets handle it gracefully.
  if (aReflowState.ComputedHeight() == 0) {
    nsSize minSize = GetMinSize(state);
    computedSize.height = minSize.height - m.top - m.bottom;
  }

  nsSize prefSize(0,0);

  // if we are told to layout intrinic then get our preferred size.
  if (computedSize.width == NS_INTRINSICSIZE || computedSize.height == NS_INTRINSICSIZE) {
     prefSize = GetPrefSize(state);
     nsSize minSize = GetMinSize(state);
     nsSize maxSize = GetMaxSize(state);
     prefSize = BoundsCheck(minSize, prefSize, maxSize);
  }

  // get our desiredSize
  if (aReflowState.ComputedWidth() == NS_INTRINSICSIZE) {
    computedSize.width = prefSize.width;
  } else {
    computedSize.width += m.left + m.right;
  }

  if (aReflowState.ComputedHeight() == NS_INTRINSICSIZE) {
    computedSize.height = prefSize.height;
  } else {
    computedSize.height += m.top + m.bottom;
  }

  // handle reflow state min and max sizes
  // XXXbz the width handling here seems to be wrong, since
  // mComputedMin/MaxWidth is a content-box size, whole
  // computedSize.width is a border-box size...
  if (computedSize.width > aReflowState.ComputedMaxWidth())
    computedSize.width = aReflowState.ComputedMaxWidth();

  if (computedSize.width < aReflowState.ComputedMinWidth())
    computedSize.width = aReflowState.ComputedMinWidth();

  // Now adjust computedSize.height for our min and max computed
  // height.  The only problem is that those are content-box sizes,
  // while computedSize.height is a border-box size.  So subtract off
  // m.TopBottom() before adjusting, then readd it.
  computedSize.height = std::max(0, computedSize.height - m.TopBottom());
  computedSize.height = NS_CSS_MINMAX(computedSize.height,
                                      aReflowState.ComputedMinHeight(),
                                      aReflowState.ComputedMaxHeight());
  computedSize.height += m.TopBottom();

  nsRect r(mRect.x, mRect.y, computedSize.width, computedSize.height);

  SetBounds(state, r);
 
  // layout our children
  Layout(state);
  
  // ok our child could have gotten bigger. So lets get its bounds
  aDesiredSize.Width() = mRect.width;
  aDesiredSize.Height() = mRect.height;
  aDesiredSize.SetTopAscent(GetBoxAscent(state));

  // the overflow rect is set in SetBounds() above
  aDesiredSize.mOverflowAreas = GetOverflowAreas();

#ifdef DO_NOISY_REFLOW
  {
    printf("%p ** nsLBF(done) W:%d H:%d  ", this, aDesiredSize.Width(), aDesiredSize.Height());

    if (maxElementWidth) {
      printf("MW:%d\n", *maxElementWidth); 
    } else {
      printf("MW:?\n"); 
    }

  }
#endif
}
예제 #23
0
파일: Window.cpp 프로젝트: jjiezheng/urho3d
void Window::OnDragMove(const IntVector2& position, const IntVector2& screenPosition, int buttons, int qualifiers, Cursor* cursor)
{
    if (dragMode_ == DRAG_NONE)
        return;

    IntVector2 delta = screenPosition - dragBeginCursor_;

    const IntVector2& position_ = GetPosition();
    const IntVector2& size_ = GetSize();
    const IntVector2& minSize_ = GetMinSize();
    const IntVector2& maxSize_ = GetMaxSize();

    switch (dragMode_)
    {
    case DRAG_MOVE:
        SetPosition(dragBeginPosition_ + delta);
        break;

    case DRAG_RESIZE_TOPLEFT:
        SetPosition(Clamp(dragBeginPosition_.x_ + delta.x_, position_.x_ - (maxSize_.x_ - size_.x_), position_.x_ + (size_.x_ - minSize_.x_)),
            Clamp(dragBeginPosition_.y_ + delta.y_, position_.y_ - (maxSize_.y_ - size_.y_), position_.y_ + (size_.y_ - minSize_.y_)));
        SetSize(dragBeginSize_ - delta);
        break;

    case DRAG_RESIZE_TOP:
        SetPosition(dragBeginPosition_.x_, Clamp(dragBeginPosition_.y_ + delta.y_, position_.y_ - (maxSize_.y_ - size_.y_), position_.y_ + (size_.y_ - minSize_.y_)));
        SetSize(dragBeginSize_.x_, dragBeginSize_.y_ - delta.y_);
        break;

    case DRAG_RESIZE_TOPRIGHT:
        SetPosition(dragBeginPosition_.x_, dragBeginPosition_.y_ + delta.y_);
        SetSize(dragBeginSize_.x_ + delta.x_, dragBeginSize_.y_ - delta.y_);
        break;

    case DRAG_RESIZE_RIGHT:
        SetSize(dragBeginSize_.x_ + delta.x_, dragBeginSize_.y_);
        break;

    case DRAG_RESIZE_BOTTOMRIGHT:
        SetSize(dragBeginSize_ + delta);
        break;

    case DRAG_RESIZE_BOTTOM:
        SetSize(dragBeginSize_.x_, dragBeginSize_.y_ + delta.y_);
        break;

    case DRAG_RESIZE_BOTTOMLEFT:
        SetPosition(Clamp(dragBeginPosition_.x_ + delta.x_, position_.x_ - (maxSize_.x_ - size_.x_), position_.x_ + (size_.x_ - minSize_.x_)), dragBeginPosition_.y_);
        SetSize(dragBeginSize_.x_ - delta.x_, dragBeginSize_.y_ + delta.y_);
        break;

    case DRAG_RESIZE_LEFT:
        SetPosition(Clamp(dragBeginPosition_.x_ + delta.x_, position_.x_ - (maxSize_.x_ - size_.x_), position_.x_ + (size_.x_ - minSize_.x_)), dragBeginPosition_.y_);
        SetSize(dragBeginSize_.x_ - delta.x_, dragBeginSize_.y_);
        break;

    default:
        break;
    }

    ValidatePosition();
    SetCursorShape(dragMode_, cursor);
}
예제 #24
0
파일: toplvcmn.cpp 프로젝트: mark711/Cafu
void wxTopLevelWindowBase::SetMinSize(const wxSize& minSize)
{
    SetSizeHints(minSize, GetMaxSize());
}
예제 #25
0
void wxAuiFloatingFrame::SetPaneWindow(const wxAuiPaneInfo& pane)
{
    m_pane_window = pane.window;
    m_pane_window->Reparent(this);

    wxAuiPaneInfo contained_pane = pane;
    contained_pane.Dock().Center().Show().
                    CaptionVisible(false).
                    PaneBorder(false).
                    Layer(0).Row(0).Position(0);

    // Carry over the minimum size
    wxSize pane_min_size = pane.window->GetMinSize();

    // if the frame window's max size is greater than the min size
    // then set the max size to the min size as well
    wxSize cur_max_size = GetMaxSize();
    if (cur_max_size.IsFullySpecified() &&
          (cur_max_size.x < pane.min_size.x ||
           cur_max_size.y < pane.min_size.y)
       )
    {
        SetMaxSize(pane_min_size);
    }

    SetMinSize(pane.window->GetMinSize());

    m_mgr.AddPane(m_pane_window, contained_pane);
    m_mgr.Update();

    if (pane.min_size.IsFullySpecified())
    {
        // because SetSizeHints() calls Fit() too (which sets the window
        // size to its minimum allowed), we keep the size before calling
        // SetSizeHints() and reset it afterwards...
        wxSize tmp = GetSize();
        GetSizer()->SetSizeHints(this);
        SetSize(tmp);
    }

    SetTitle(pane.caption);

    if (pane.floating_size != wxDefaultSize)
    {
        SetSize(pane.floating_size);
    }
    else
    {
        wxSize size = pane.best_size;
        if (size == wxDefaultSize)
            size = pane.min_size;
        if (size == wxDefaultSize)
            size = m_pane_window->GetSize();
        if (m_owner_mgr && pane.HasGripper())
        {
            if (pane.HasGripperTop())
                size.y += m_owner_mgr->m_art->GetMetric(wxAUI_DOCKART_GRIPPER_SIZE);
            else
                size.x += m_owner_mgr->m_art->GetMetric(wxAUI_DOCKART_GRIPPER_SIZE);
        }

        SetClientSize(size);
    }

    if (pane.IsFixed())
    {
        SetWindowStyleFlag(GetWindowStyleFlag() & ~wxRESIZE_BORDER);
    }
}
예제 #26
0
/**
 * Ok return our dimensions
 */
nsSize
nsImageBoxFrame::GetPrefSize(nsBoxLayoutState& aState)
{
  nsSize size(0,0);
  DISPLAY_PREF_SIZE(this, size);
  if (DoesNeedRecalc(mImageSize))
     GetImageSize();

  if (!mUseSrcAttr && (mSubRect.width > 0 || mSubRect.height > 0))
    size = nsSize(mSubRect.width, mSubRect.height);
  else
    size = mImageSize;

  nsSize intrinsicSize = size;

  nsMargin borderPadding(0,0,0,0);
  GetBorderAndPadding(borderPadding);
  size.width += borderPadding.LeftRight();
  size.height += borderPadding.TopBottom();

  PRBool widthSet, heightSet;
  nsIBox::AddCSSPrefSize(this, size, widthSet, heightSet);
  NS_ASSERTION(size.width != NS_INTRINSICSIZE && size.height != NS_INTRINSICSIZE,
               "non-nintrinsic size expected");

  nsSize minSize = GetMinSize(aState);
  nsSize maxSize = GetMaxSize(aState);

  if (!widthSet && !heightSet) {
    if (minSize.width != NS_INTRINSICSIZE)
      minSize.width -= borderPadding.LeftRight();
    if (minSize.height != NS_INTRINSICSIZE)
      minSize.height -= borderPadding.TopBottom();
    if (maxSize.width != NS_INTRINSICSIZE)
      maxSize.width -= borderPadding.LeftRight();
    if (maxSize.height != NS_INTRINSICSIZE)
      maxSize.height -= borderPadding.TopBottom();

    size = nsLayoutUtils::ComputeAutoSizeWithIntrinsicDimensions(minSize.width, minSize.height,
                                                                 maxSize.width, maxSize.height,
                                                                 intrinsicSize.width, intrinsicSize.height);
    NS_ASSERTION(size.width != NS_INTRINSICSIZE && size.height != NS_INTRINSICSIZE,
                 "non-nintrinsic size expected");
    size.width += borderPadding.LeftRight();
    size.height += borderPadding.TopBottom();
    return size;
  }

  if (!widthSet) {
    if (intrinsicSize.height > 0) {
      // Subtract off the border and padding from the height because the
      // content-box needs to be used to determine the ratio
      nscoord height = size.height - borderPadding.TopBottom();
      size.width = nscoord(PRInt64(height) * PRInt64(intrinsicSize.width) /
                           PRInt64(intrinsicSize.height));
    }
    else {
      size.width = intrinsicSize.width;
    }

    size.width += borderPadding.LeftRight();
  }
  else if (!heightSet) {
    if (intrinsicSize.width > 0) {
      nscoord width = size.width - borderPadding.LeftRight();
      size.height = nscoord(PRInt64(width) * PRInt64(intrinsicSize.height) /
                            PRInt64(intrinsicSize.width));
    }
    else {
      size.height = intrinsicSize.height;
    }

    size.height += borderPadding.TopBottom();
  }

  return BoundsCheck(minSize, size, maxSize);
}
예제 #27
0
void CMuleToolbarCtrl::Refresh()
{
	SetAllButtonsWidth();
	AutoSize();	// Causes a toolbar to be resized.

	if (theApp.emuledlg->m_ctlMainTopReBar.m_hWnd)
	{
	    theApp.emuledlg->RemoveAnchor(theApp.emuledlg->m_ctlMainTopReBar.m_hWnd);

	    REBARBANDINFO rbbi = {0};
	    CSize sizeBar;
	    GetMaxSize(&sizeBar);
		ASSERT( sizeBar.cx != 0 && sizeBar.cy != 0 );
	    rbbi.cbSize = sizeof(rbbi);
	    rbbi.fMask = RBBIM_CHILDSIZE | RBBIM_IDEALSIZE;
	    rbbi.cxMinChild = sizeBar.cy;
	    rbbi.cyMinChild = sizeBar.cy;
	    rbbi.cxIdeal = sizeBar.cx;
	    VERIFY( theApp.emuledlg->m_ctlMainTopReBar.SetBandInfo(MULE_TOOLBAR_BAND_NR, &rbbi) );

	    theApp.emuledlg->AddAnchor(theApp.emuledlg->m_ctlMainTopReBar.m_hWnd, TOP_LEFT, TOP_RIGHT);
	}

	CRect rToolbarRect;
	GetWindowRect(&rToolbarRect);

	if (m_iPreviousHeight == rToolbarRect.Height())
	{
		Invalidate();
		RedrawWindow();
	}
	else
	{
		m_iPreviousHeight = rToolbarRect.Height();

		CRect rClientRect;
		theApp.emuledlg->GetClientRect(&rClientRect);

		CRect rStatusbarRect;
		theApp.emuledlg->statusbar->GetWindowRect(&rStatusbarRect);

		rClientRect.top += rToolbarRect.Height();
		rClientRect.bottom -= rStatusbarRect.Height();

		CWnd* wnds[] =
		{
			theApp.emuledlg->serverwnd,
			theApp.emuledlg->kademliawnd,
			theApp.emuledlg->transferwnd,
			theApp.emuledlg->sharedfileswnd,
			theApp.emuledlg->searchwnd,
			theApp.emuledlg->chatwnd,
#ifdef IRC
			theApp.emuledlg->ircwnd,
#endif
			theApp.emuledlg->statisticswnd
		};
		for (int i = 0; i < _countof(wnds); i++)
		{
			wnds[i]->SetWindowPos(NULL, rClientRect.left, rClientRect.top, rClientRect.Width(), rClientRect.Height(), SWP_NOZORDER);
			theApp.emuledlg->RemoveAnchor(wnds[i]->m_hWnd);
			theApp.emuledlg->AddAnchor(wnds[i]->m_hWnd, TOP_LEFT, BOTTOM_RIGHT);
		}
		theApp.emuledlg->Invalidate();
		theApp.emuledlg->RedrawWindow();
	}
}
예제 #28
0
void CMuleToolbarCtrl::Dump()
{
	TRACE("---\n");
	CRect rcWnd;
	GetWindowRect(&rcWnd);
	TRACE("Wnd =%4d,%4d-%4d,%4d (%4d x %4d)\n", rcWnd.left, rcWnd.top, rcWnd.right, rcWnd.bottom, rcWnd.Width(), rcWnd.Height());

	CRect rcClnt;
	GetClientRect(&rcClnt);
	TRACE("Clnt=%4d,%4d-%4d,%4d (%4d x %4d)\n", rcClnt.left, rcClnt.top, rcClnt.right, rcClnt.bottom, rcClnt.Width(), rcClnt.Height());

	// Total size of all of the visible buttons and separators in the toolbar.
	CSize siz;
	GetMaxSize(&siz);
	TRACE("MaxSize=                  %4d x %4d\n", siz.cx, siz.cy);

	int iButtons = GetButtonCount();	// Count of the buttons currently in the toolbar.
	int iRows = GetRows();				// Number of rows of buttons in a toolbar with the TBSTYLE_WRAPABLE style
	int iMaxTextRows = GetMaxTextRows();// Maximum number of text rows that can be displayed on a toolbar button.
	TRACE("ButtonCount=%d  Rows=%d  MaxTextRows=%d\n", iButtons, iRows, iMaxTextRows);

	// Current width and height of toolbar buttons, in pixels.
	DWORD dwButtonSize = GetButtonSize();
	TRACE("ButtonSize=%dx%d\n", LOWORD(dwButtonSize), HIWORD(dwButtonSize));

	// Padding for a toolbar control.
	DWORD dwPadding = SendMessage(TB_GETPADDING);
	TRACE("Padding=%dx%d\n", LOWORD(dwPadding), HIWORD(dwPadding));

	DWORD dwBitmapFlags = GetBitmapFlags(); // TBBF_LARGE=0x0001
	TRACE("BitmapFlags=%u\n", dwBitmapFlags);

	// Bounding rectangle of a button in a toolbar.
	TRACE("ItemRects:");
	for (int i = 0; i < iButtons; i++)
	{
		CRect rcButton(0,0,0,0);
		GetItemRect(i, &rcButton);
		TRACE(" %2dx%2d", rcButton.Width(), rcButton.Height());
	}
	TRACE("\n");

	// Bounding rectangle for a specified toolbar button.
	TRACE("Rects    :");
	for (int i = 0; i < iButtons; i++)
	{
		CRect rcButton(0,0,0,0);
		GetRect(IDC_TOOLBARBUTTON + i, &rcButton);
		TRACE(" %2dx%2d", rcButton.Width(), rcButton.Height());
	}
	TRACE("\n");

	TRACE("Info     :");
	for (int i = 0; i < iButtons; i++)
	{
		TCHAR szLabel[256];
		TBBUTTONINFO tbi = {0};
		tbi.cbSize = sizeof(tbi);
		tbi.dwMask |= TBIF_BYINDEX | TBIF_COMMAND | TBIF_IMAGE | TBIF_LPARAM | TBIF_SIZE | TBIF_STATE | TBIF_STYLE | TBIF_TEXT;
		tbi.cchText = _countof(szLabel);
		tbi.pszText = szLabel;
		GetButtonInfo(i, &tbi);
		szLabel[_countof(szLabel) - 1] = _T('\0');
		TRACE(" %2d ", tbi.cx);
	}
	TRACE("\n");
}
예제 #29
0
파일: floatpane.cpp 프로젝트: mark711/Cafu
void wxAuiFloatingFrame::SetPaneWindow(const wxAuiPaneInfo& pane)
{
    m_pane_window = pane.window;
    m_pane_window->Reparent(this);

    wxAuiPaneInfo contained_pane = pane;
    contained_pane.Dock().Center().Show().
                    CaptionVisible(false).
                    PaneBorder(false).
                    Layer(0).Row(0).Position(0);

    // Carry over the minimum size
    wxSize pane_min_size = pane.window->GetMinSize();

    // if the frame window's max size is greater than the min size
    // then set the max size to the min size as well
    wxSize cur_max_size = GetMaxSize();
    if (cur_max_size.IsFullySpecified() &&
          (cur_max_size.x < pane.min_size.x ||
           cur_max_size.y < pane.min_size.y)
       )
    {
        SetMaxSize(pane_min_size);
    }

    SetMinSize(pane.window->GetMinSize());

    m_mgr.AddPane(m_pane_window, contained_pane);
    m_mgr.Update();

    if (pane.min_size.IsFullySpecified())
    {
        // because SetSizeHints() calls Fit() too (which sets the window
        // size to its minimum allowed), we keep the size before calling
        // SetSizeHints() and reset it afterwards...
        wxSize tmp = GetSize();
        GetSizer()->SetSizeHints(this);
        SetSize(tmp);
    }

    SetTitle(pane.caption);

    // This code is slightly awkward because we need to reset wxRESIZE_BORDER
    // before calling SetClientSize() below as doing it after setting the
    // client size would actually change it, at least under MSW, where the
    // total window size doesn't change and hence, as the borders size changes,
    // the client size does change.
    //
    // So we must call it first but doing it generates a size event and updates
    // pane.floating_size from inside it so we must also record its original
    // value before doing it.
    const bool hasFloatingSize = pane.floating_size != wxDefaultSize;
    if (pane.IsFixed())
    {
        SetWindowStyleFlag(GetWindowStyleFlag() & ~wxRESIZE_BORDER);
    }

    if ( hasFloatingSize )
    {
        SetSize(pane.floating_size);
    }
    else
    {
        wxSize size = pane.best_size;
        if (size == wxDefaultSize)
            size = pane.min_size;
        if (size == wxDefaultSize)
            size = m_pane_window->GetSize();
        if (m_owner_mgr && pane.HasGripper())
        {
            if (pane.HasGripperTop())
                size.y += m_owner_mgr->m_art->GetMetric(wxAUI_DOCKART_GRIPPER_SIZE);
            else
                size.x += m_owner_mgr->m_art->GetMetric(wxAUI_DOCKART_GRIPPER_SIZE);
        }

        SetClientSize(size);
    }
}
예제 #30
0
bool Tribe::ShouldGrow() const
{
    return members.GetSize() < (size_t)GetMaxSize();
}