コード例 #1
0
ファイル: 20.cpp プロジェクト: hellolintong/interview
int GetMaxHeight(int height, Node *pNode){
	if(!pNode){
		return height;
	}
	int leftHeight = height;
	int rightHeight = height;

	leftHeight = GetMaxHeight(height, pNode->pLeft);
	rightHeight =  GetMaxHeight(height, pNode->pRight);
	return (leftHeight > rightHeight ? leftHeight : rightHeight) + 1;
}
コード例 #2
0
ファイル: Roidlg.cpp プロジェクト: vinnie38170/klImageCore
void CRoiDlg::UpdateRange()
{
    m_SpinX.SetRange(0,GetMaxX());
    m_SpinY.SetRange(0,GetMaxY());
    m_SpinWidth.SetRange(1,GetMaxWidth());
    m_SpinHeight.SetRange(1,GetMaxHeight());
}
コード例 #3
0
FVector2D FWhiteSpaceTextRun::Measure( int32 StartIndex, int32 EndIndex, float Scale, const FRunTextContext& TextContext) const
{
	const FVector2D ShadowOffsetToApply((EndIndex == Range.EndIndex) ? FMath::Abs(Style.ShadowOffset.X * Scale) : 0.0f, FMath::Abs(Style.ShadowOffset.Y * Scale));

	if ( EndIndex - StartIndex == 0 )
	{
		return FVector2D( ShadowOffsetToApply.X * Scale, GetMaxHeight( Scale ) );
	}

	// count tabs
	int32 TabCount = 0;
	for(int32 Index = StartIndex; Index < EndIndex; Index++)
	{
		if((*Text)[Index] == TEXT('\t'))
		{
			TabCount++;
		}
	}

	const TSharedRef< FSlateFontMeasure > FontMeasure = FSlateApplication::Get().GetRenderer()->GetFontMeasureService();
	FVector2D Size = FontMeasure->Measure( **Text, StartIndex, EndIndex, Style.Font, true, Scale ) + ShadowOffsetToApply;

	Size.X -= TabWidth * (float)TabCount * Scale;
	Size.X += SpaceWidth * (float)(TabCount * NumSpacesPerTab) * Scale;

	return Size;
}
コード例 #4
0
ファイル: htmlsection.cpp プロジェクト: F5000/spree
void CHTMLSection::OnDraw( GS::CDrawContext &dc )
{
	HBRUSH hbr = NULL;
	if( GetBackgroundColours( dc.GetSafeHdc(), hbr ) )
	{
		FillRect( dc.GetSafeHdc(), *this, hbr );
	}
	else if( !IsTransparent() )
	{
		if( m_pDocument )
		{
			if( !m_pDocument->m_back.Draw( dc, *this ) )
			{
				dc.FillRect( *this, m_pDefaults->m_crBackground );
			}

			if( m_pDocument->m_pimgBackground )
			{
				const int nPosX = left - GetScrollPosH();
				const int nPosY = top - GetScrollPos();
				DrawTiledBitmap( nPosX, nPosY, max( GetMaxWidth(), (UINT)Width() ), max( GetMaxHeight(), (UINT)Height() ), dc.GetSafeHdc(), m_pDocument->m_pimgBackground, m_nBackgroundFrame );
			}
		}
		else
		{
			dc.FillRect( *this, m_pDefaults->m_crBackground );
		}
	}
	CScrollContainer::OnDraw( dc );
}
コード例 #5
0
bool CBitmapControl::Refresh(Window* wnd, bool captrue, bool mirror)
{
	int item_w = m_rcItem.right - m_rcItem.left;
	int item_h = m_rcItem.bottom - m_rcItem.top;
	if (auto_size_)
	{
		item_w = GetMaxWidth();
		item_h = GetMaxHeight();
	}
	bool ret = false;
	if (item_w > 0 && item_h > 0)
	{
		parent_wnd_ = wnd;
		data_.resize(item_w * item_h * 4);

		ret = video_frame_mng_->GetVideoFrame((captrue ? "" : account_), timestamp_, (char*)data_.c_str(), item_w, item_h, mirror);
		if (ret)
		{
			width_ = item_w;
			height_ = item_h;
			if (auto_size_)
			{
				SetFixedWidth(width_);
				SetFixedHeight(height_);
			}
			Invalidate();
		}
	}
	return ret;
}
コード例 #6
0
std::string
ConventionalVideoMode::ToString() const
{
   dc1394video_mode_t libdc1394mode = GetLibDC1394Mode();
   int formatNr = -1, modeNr = -1;
   if (libdc1394mode >= DC1394_VIDEO_MODE_160x120_YUV444 &&
         libdc1394mode <= DC1394_VIDEO_MODE_640x480_MONO16)
   {
      formatNr = 0;
      modeNr = libdc1394mode - DC1394_VIDEO_MODE_160x120_YUV444;
   }
   else if (libdc1394mode >= DC1394_VIDEO_MODE_800x600_YUV422 &&
         libdc1394mode <= DC1394_VIDEO_MODE_1024x768_MONO16)
   {
      formatNr = 1;
      modeNr = libdc1394mode - DC1394_VIDEO_MODE_800x600_YUV422;
   }
   else if (libdc1394mode >= DC1394_VIDEO_MODE_1280x960_YUV422 &&
         libdc1394mode <= DC1394_VIDEO_MODE_1600x1200_MONO16)
   {
      formatNr = 2;
      modeNr = libdc1394mode - DC1394_VIDEO_MODE_1280x960_YUV422;
   }
   std::string formatModeStr = (formatNr >= 0 && modeNr >= 0) ?
      "[f" + boost::lexical_cast<std::string>(formatNr) + "-m" +
      boost::lexical_cast<std::string>(modeNr) + "]" :
      "[?-?]";

   return formatModeStr + " " +
      boost::lexical_cast<std::string>(GetMaxWidth()) + "x" +
      boost::lexical_cast<std::string>(GetMaxHeight()) + " " +
      GetColorCodingName();
}
コード例 #7
0
ファイル: Roidlg.cpp プロジェクト: vinnie38170/klImageCore
void CRoiDlg::OnKillfocusRoiY()
{
    m_Roi.height = GetInt(&m_HeightEdit);
    m_Roi.y = GetInt(&m_YEdit);
    UpdateValue(m_Roi.y, 0, GetMaxY());
    UpdateValue(m_Roi.height, 1, GetMaxHeight(), &m_SpinHeight);
    UpdateData(FALSE);
}
コード例 #8
0
FVector2D FSlateImageRun::Measure( int32 BeginIndex, int32 EndIndex, float Scale ) const 
{
	if ( EndIndex - BeginIndex == 0 )
	{
		return FVector2D( 0, GetMaxHeight( Scale ) );
	}

	return Image->ImageSize * Scale;
}
コード例 #9
0
FVector2D FSlateWidgetRun::Measure( int32 StartIndex, int32 EndIndex, float Scale, const FRunTextContext& TextContext ) const 
{
	if ( EndIndex - StartIndex == 0 )
	{
		return FVector2D( 0, GetMaxHeight( Scale ) );
	}

	return Info.Size.Get( Info.Widget->GetDesiredSize() ) * Scale;
}
コード例 #10
0
std::string
Format7VideoMode::ToString() const
{
   int modeNr = static_cast<int>(GetLibDC1394Mode()) - DC1394_VIDEO_MODE_FORMAT7_MIN;

   return "[f7-m" + boost::lexical_cast<std::string>(modeNr) + "] " +
      boost::lexical_cast<std::string>(GetMaxWidth()) + "x" +
      boost::lexical_cast<std::string>(GetMaxHeight()) + " " +
      GetColorCodingName();
}
コード例 #11
0
ファイル: MathCell.cpp プロジェクト: BigMcLargeHuge/wxmaxima
/*! Get the rectangle around this cell

  \param all
   - true  return the rectangle around the whole line.
   - false return the rectangle around this cell. 
 */
wxRect MathCell::GetRect(bool all)
{
  if (m_isBroken)
    return wxRect( -1, -1, 0, 0);
  if (all)
    return wxRect(m_currentPoint.x, m_currentPoint.y - GetMaxCenter(),
                  GetLineWidth(1.0), GetMaxHeight());
  return wxRect(m_currentPoint.x, m_currentPoint.y - m_center,
                m_width, m_height);
}
コード例 #12
0
ファイル: Player.cpp プロジェクト: Allanis/LibD
void Player::Update(float dt) {
  Actor::Update(dt);
  
  if(_distanceTraveled > 32.0f) {
    Warp* warp = _level->CheckWarp(x, y, GetMaxWidth(), GetMaxHeight());
    if(warp) {
      _level->GetGame()->Warp(warp->GetTargetMap(), warp->GetTargetX(), warp->GetTargetY());
      _distanceTraveled = 0;
    }
  }
}
コード例 #13
0
FVector2D FSlateHyperlinkRun::Measure( int32 StartIndex, int32 EndIndex, float Scale ) const 
{
	const FVector2D ShadowOffsetToApply((EndIndex == Range.EndIndex) ? FMath::Abs(Style.TextStyle.ShadowOffset.X * Scale) : 0.0f, FMath::Abs(Style.TextStyle.ShadowOffset.Y * Scale));

	if ( EndIndex - StartIndex == 0 )
	{
		return FVector2D( ShadowOffsetToApply.X * Scale, GetMaxHeight( Scale ) );
	}

	const TSharedRef< FSlateFontMeasure > FontMeasure = FSlateApplication::Get().GetRenderer()->GetFontMeasureService();
	return FontMeasure->Measure( **Text, StartIndex, EndIndex, Style.TextStyle.Font, true, Scale ) + ShadowOffsetToApply;
}
コード例 #14
0
FVector2D FSlateHyperlinkRun::Measure( int32 StartIndex, int32 EndIndex, float Scale, const FRunTextContext& TextContext ) const 
{
	const FVector2D ShadowOffsetToApply((EndIndex == Range.EndIndex) ? FMath::Abs(Style.TextStyle.ShadowOffset.X * Scale) : 0.0f, FMath::Abs(Style.TextStyle.ShadowOffset.Y * Scale));

	if ( EndIndex - StartIndex == 0 )
	{
		return FVector2D( ShadowOffsetToApply.X * Scale, GetMaxHeight( Scale ) );
	}

	// Use the full text range (rather than the run range) so that text that spans runs will still be shaped correctly
	return ShapedTextCacheUtil::MeasureShapedText(TextContext.ShapedTextCache, FCachedShapedTextKey(FTextRange(0, Text->Len()), Scale, TextContext, Style.TextStyle.Font), FTextRange(StartIndex, EndIndex), **Text) + ShadowOffsetToApply;
}
コード例 #15
0
ファイル: toplevel.cpp プロジェクト: EdgarTx/wx
void wxTopLevelWindowGTK::DoSetSizeHints( int minW, int minH,
        int maxW, int maxH,
        int incW, int incH )
{
    wxTopLevelWindowBase::DoSetSizeHints( minW, minH, maxW, maxH, incW, incH );

    if (m_widget)
    {
        int minWidth = GetMinWidth(),
            minHeight = GetMinHeight(),
            maxWidth = GetMaxWidth(),
            maxHeight = GetMaxHeight();

        // set size hints
        gint            flag = 0; // GDK_HINT_POS;
        GdkGeometry     geom;

        if ((minWidth != -1) || (minHeight != -1)) flag |= GDK_HINT_MIN_SIZE;
        if ((maxWidth != -1) || (maxHeight != -1)) flag |= GDK_HINT_MAX_SIZE;

        geom.min_width = minWidth;
        geom.min_height = minHeight;

        // Because of the way we set GDK_HINT_MAX_SIZE above, if either of
        // maxHeight or maxWidth is set, we must set them both, else the
        // remaining -1 will be taken literally.

        // I'm certain this also happens elsewhere, and is the probable
        // cause of other such things as:
        // Gtk-WARNING **: gtk_widget_size_allocate():
        //       attempt to allocate widget with width 65535 and height 600
        // but I don't have time to track them all now..
        //
        // Really we need to encapulate all this height/width business and
        // stop any old method from ripping at the members directly and
        // scattering -1's without regard for who might resolve them later.

        geom.max_width = ( maxHeight == -1 ) ? maxWidth
                         : ( maxWidth == -1 ) ? wxGetDisplaySize().GetWidth()
                         : maxWidth ;

        geom.max_height = ( maxWidth == -1 ) ? maxHeight    // ( == -1 here )
                          : ( maxHeight == -1 ) ? wxGetDisplaySize().GetHeight()
                          : maxHeight ;

        gtk_window_set_geometry_hints( GTK_WINDOW(m_widget),
                                       (GtkWidget*) NULL,
                                       &geom,
                                       (GdkWindowHints) flag );
    }
}
コード例 #16
0
void wxNonOwnedWindow::HandleResizing( double WXUNUSED(timestampsec), wxRect* rect )
{
    wxRect r = *rect ;

    // this is a EVT_SIZING not a EVT_SIZE type !
    wxSizeEvent wxevent( r , GetId() ) ;
    wxevent.SetEventObject( this ) ;
    if ( HandleWindowEvent(wxevent) )
        r = wxevent.GetRect() ;

    if ( GetMaxWidth() != -1 && r.GetWidth() > GetMaxWidth() )
        r.SetWidth( GetMaxWidth() ) ;
    if ( GetMaxHeight() != -1 && r.GetHeight() > GetMaxHeight() )
        r.SetHeight( GetMaxHeight() ) ;
    if ( GetMinWidth() != -1 && r.GetWidth() < GetMinWidth() )
        r.SetWidth( GetMinWidth() ) ;
    if ( GetMinHeight() != -1 && r.GetHeight() < GetMinHeight() )
        r.SetHeight( GetMinHeight() ) ;

    *rect = r;
    // TODO actuall this is too early, in case the window extents are adjusted
    wxWindowMac::MacSuperChangedPosition() ; // like this only children will be notified
}
コード例 #17
0
wxSize wxTopLevelWindowBase::GetMaxSize() const
{
    wxSize  size( GetMaxWidth(), GetMaxHeight() );
    int     w, h;

    wxClientDisplayRect( 0, 0, &w, &h );

    if( size.GetWidth() == wxDefaultCoord )
        size.SetWidth( w );

    if( size.GetHeight() == wxDefaultCoord )
        size.SetHeight( h );

    return size;
}
コード例 #18
0
ファイル: Roidlg.cpp プロジェクト: vinnie38170/klImageCore
void CRoiDlg::DoDataExchange(CDataExchange* pDX)
{
   CDialog::DoDataExchange(pDX);
   //{{AFX_DATA_MAP(CRoiDlg)
   DDX_Control(pDX, IDC_ROI_Y, m_YEdit);
   DDX_Control(pDX, IDC_ROI_X, m_XEdit);
   DDX_Control(pDX, IDC_ROI_Width, m_WidthEdit);
   DDX_Control(pDX, IDC_ROI_Height, m_HeightEdit);
   DDX_Control(pDX, IDC_SPIN_Y, m_SpinY);
   DDX_Control(pDX, IDC_SPIN_X, m_SpinX);
   DDX_Control(pDX, IDC_SPIN_Width, m_SpinWidth);
   DDX_Control(pDX, IDC_SPIN_Height, m_SpinHeight);
   //}}AFX_DATA_MAP
   DDX_Text(pDX, IDC_ROI_X,      m_Roi.x     );
   DDX_Text(pDX, IDC_ROI_Y,      m_Roi.y     );
   DDX_Text(pDX, IDC_ROI_Width,  m_Roi.width );
   DDX_Text(pDX, IDC_ROI_Height, m_Roi.height);
   DDV_MinMaxInt(pDX, m_Roi.x     , 0, GetMaxX());
   DDV_MinMaxInt(pDX, m_Roi.y     , 0, GetMaxY());
   DDV_MinMaxInt(pDX, m_Roi.width , 1, GetMaxWidth());
   DDV_MinMaxInt(pDX, m_Roi.height, 1, GetMaxHeight());
}
コード例 #19
0
bool SelectLanguage()
{
    if (InstallInfo.languages.size() == 1)
    {
        InstallInfo.cur_lang = InstallInfo.languages.front();
        if (!ReadLang()) throwerror(true, "Could not load language file for %s", InstallInfo.cur_lang.c_str());
        return true;
    }
    
    char title[] = "<C></B/29>Please select a language<!29!B>";
    std::vector<char *> LangItems;
    
    ButtonBar.Clear();
    ButtonBar.AddButton("Arrows", "Navigate menu");
    ButtonBar.AddButton("A", "About");
    ButtonBar.AddButton("ESC", "Exit program");
    ButtonBar.Draw();
    
    for (std::list<std::string>::iterator p=InstallInfo.languages.begin();p!=InstallInfo.languages.end();p++)
        LangItems.push_back(MakeCString(*p));

    CCDKScroll ScrollList(CDKScreen, CENTER, CENTER, GetMaxHeight(20), GetMaxWidth(45), RIGHT, title, &LangItems[0],
                          LangItems.size());
    ScrollList.SetBgColor(5);
    ScrollList.Bind('a', ShowAboutK);

    int selection = ScrollList.Activate();
    
    if (ScrollList.ExitType() == vNORMAL)
    {
        InstallInfo.cur_lang = LangItems[selection];
        ReadLang();
    }
    else return false;
    
    return true;
}
コード例 #20
0
    void CVerticalLayoutUI::DoEvent(TEventUI& event)
    {
		bool bBubble = false; //<By Jackie 2013-6-13>默认不冒泡.
		bool bHandled = false; //是否被处理
        //<By Jackie 2013-6-9> || true 处理消息不收m_iSepHeight的限制.
        //if( m_iSepHeight != 0 || true)
        //{
        if( event.Type == UIEVENT_BUTTONDOWN && IsEnabled() )
        {
			bHandled = true;
            RECT rcSeparator = GetThumbRect(false);
            if( ::PtInRect(&rcSeparator, event.ptMouse) )
            {
                m_uButtonState |= UISTATE_CAPTURED;
                ptLastMouse = event.ptMouse;
                m_rcNewPos = m_rcItem;
                if( !m_bImmMode && m_pManager ) m_pManager->AddPostPaint(this);
                return;
            }
        }
        else if( event.Type == UIEVENT_BUTTONUP )
        {
			bHandled = true;
            if( (m_uButtonState & UISTATE_CAPTURED) != 0 )
            {
                m_uButtonState &= ~UISTATE_CAPTURED;
                m_rcItem = m_rcNewPos;
                if( !m_bImmMode && m_pManager ) m_pManager->RemovePostPaint(this);
                NeedParentUpdate();
                return;
            }
        }
        else if( event.Type == UIEVENT_MOUSEMOVE )
        {
			bBubble = true;
			bHandled = true;
            //<By Jackie 2013-6-9> 支持Layout接收鼠标移动消息.
            m_pManager->SendNotify(this, DUI_MSGTYPE_MOUSEMOVE, event.wParam, event.lParam);
            //////////////////////////////////////////////////////////////////////////

            if( (m_uButtonState & UISTATE_CAPTURED) != 0 )
            {
                LONG cy = event.ptMouse.y - ptLastMouse.y;
                ptLastMouse = event.ptMouse;
                RECT rc = m_rcNewPos;
                if( m_iSepHeight >= 0 )
                {
                    if( cy > 0 && event.ptMouse.y < m_rcNewPos.bottom + m_iSepHeight ) return;
                    if( cy < 0 && event.ptMouse.y > m_rcNewPos.bottom ) return;
                    rc.bottom += cy;
                    if( rc.bottom - rc.top <= GetMinHeight() )
                    {
                        if( m_rcNewPos.bottom - m_rcNewPos.top <= GetMinHeight() ) return;
                        rc.bottom = rc.top + GetMinHeight();
                    }
                    if( rc.bottom - rc.top >= GetMaxHeight() )
                    {
                        if( m_rcNewPos.bottom - m_rcNewPos.top >= GetMaxHeight() ) return;
                        rc.bottom = rc.top + GetMaxHeight();
                    }
                }
                else
                {
                    if( cy > 0 && event.ptMouse.y < m_rcNewPos.top ) return;
                    if( cy < 0 && event.ptMouse.y > m_rcNewPos.top + m_iSepHeight ) return;
                    rc.top += cy;
                    if( rc.bottom - rc.top <= GetMinHeight() )
                    {
                        if( m_rcNewPos.bottom - m_rcNewPos.top <= GetMinHeight() ) return;
                        rc.top = rc.bottom - GetMinHeight();
                    }
                    if( rc.bottom - rc.top >= GetMaxHeight() )
                    {
                        if( m_rcNewPos.bottom - m_rcNewPos.top >= GetMaxHeight() ) return;
                        rc.top = rc.bottom - GetMaxHeight();
                    }
                }

                CDuiRect rcInvalidate = GetThumbRect(true);
                m_rcNewPos = rc;
                m_cxyFixed.cy = m_rcNewPos.bottom - m_rcNewPos.top;

                if( m_bImmMode )
                {
                    m_rcItem = m_rcNewPos;
                    NeedParentUpdate();
                }
                else
                {
                    rcInvalidate.Join(GetThumbRect(true));
                    rcInvalidate.Join(GetThumbRect(false));
                    if( m_pManager ) m_pManager->Invalidate(rcInvalidate);
                }
                return;
            }
        }
        else if(event.Type == UIEVENT_MOUSELEAVE)
        {
			bHandled = true;
            m_pManager->SendNotify(this, DUI_MSGTYPE_MOUSELEAVE, event.wParam, event.lParam);
        }
        else if(event.Type == UIEVENT_MOUSEENTER)
        {
			bHandled = true;
            m_pManager->SendNotify(this, DUI_MSGTYPE_MOUSEENTER, event.wParam, event.lParam);
        }
        else if( event.Type == UIEVENT_SETCURSOR )
        {
			bHandled = true;
            RECT rcSeparator = GetThumbRect(false);
            if( IsEnabled() && ::PtInRect(&rcSeparator, event.ptMouse) )
            {
                ::SetCursor(::LoadCursor(NULL, MAKEINTRESOURCE(IDC_SIZENS)));
                return;
            }
        }
		else if(event.Type == UIEVENT_SCROLLWHEEL)
		{
			bHandled = true;
			bBubble = true;
			m_pManager->SendNotify(this, DUI_MSGTYPE_MOUSEWHEEL, event.wParam, event.lParam);
			
		}

		if(bBubble && m_pParent) m_pParent->DoEvent(event);

        if(!bHandled)CContainerUI::DoEvent(event);
    }
コード例 #21
0
ファイル: popupwin.cpp プロジェクト: 3v1n0/wxWidgets
void wxPopupWindow::DoSetSize( int x, int y, int width, int height, int sizeFlags )
{
    wxASSERT_MSG( (m_widget != NULL), wxT("invalid dialog") );
    wxASSERT_MSG( (m_wxwindow != NULL), wxT("invalid dialog") );

    if (m_resizing) return; /* I don't like recursions */
    m_resizing = true;

    int old_x = m_x;
    int old_y = m_y;

    int old_width = m_width;
    int old_height = m_height;

    if ((sizeFlags & wxSIZE_ALLOW_MINUS_ONE) == 0)
    {
        if (x != -1) m_x = x;
        if (y != -1) m_y = y;
        if (width != -1) m_width = width;
        if (height != -1) m_height = height;
    }
    else
    {
        m_x = x;
        m_y = y;
        m_width = width;
        m_height = height;
    }

/*
    if ((sizeFlags & wxSIZE_AUTO_WIDTH) == wxSIZE_AUTO_WIDTH)
    {
        if (width == -1) m_width = 80;
    }

    if ((sizeFlags & wxSIZE_AUTO_HEIGHT) == wxSIZE_AUTO_HEIGHT)
    {
       if (height == -1) m_height = 26;
    }
*/

    int minWidth = GetMinWidth(),
        minHeight = GetMinHeight(),
        maxWidth = GetMaxWidth(),
        maxHeight = GetMaxHeight();

    if ((minWidth != -1) && (m_width < minWidth)) m_width = minWidth;
    if ((minHeight != -1) && (m_height < minHeight)) m_height = minHeight;
    if ((maxWidth != -1) && (m_width > maxWidth)) m_width = maxWidth;
    if ((maxHeight != -1) && (m_height > maxHeight)) m_height = maxHeight;

    if ((m_x != -1) || (m_y != -1))
    {
        if ((m_x != old_x) || (m_y != old_y))
        {
            /* we set the position here and when showing the dialog
               for the first time in idle time */
            gtk_widget_set_uposition( m_widget, m_x, m_y );
        }
    }

    if ((m_width != old_width) || (m_height != old_height))
    {
        gtk_widget_set_usize( m_widget, m_width, m_height );

        /* actual resizing is deferred to GtkOnSize in idle time and
           when showing the dialog */
        m_sizeSet = false;

    }

    m_resizing = false;
}
コード例 #22
0
ファイル: window.cpp プロジェクト: beanhome/dev
// set the size of the window: if the dimensions are positive, just use them,
// but if any of them is equal to -1, it means that we must find the value for
// it ourselves (unless sizeFlags contains wxSIZE_ALLOW_MINUS_ONE flag, in
// which case -1 is a valid value for x and y)
//
// If sizeFlags contains wxSIZE_AUTO_WIDTH/HEIGHT flags (default), we calculate
// the width/height to best suit our contents, otherwise we reuse the current
// width/height
void wxWindowDFB::DoSetSize(int x, int y, int width, int height, int sizeFlags)
{
    // get the current size and position...
    int currentX, currentY;
    GetPosition(&currentX, &currentY);
    int currentW,currentH;
    GetSize(&currentW, &currentH);

    if ( x == -1 && !(sizeFlags & wxSIZE_ALLOW_MINUS_ONE) )
        x = currentX;
    if ( y == -1 && !(sizeFlags & wxSIZE_ALLOW_MINUS_ONE) )
        y = currentY;

    // ... and don't do anything (avoiding flicker) if it's already ok
    if ( x == currentX && y == currentY &&
         width == currentW && height == currentH )
    {
        return;
    }

    wxSize size(-1, -1);
    if ( width == -1 )
    {
        if ( sizeFlags & wxSIZE_AUTO_WIDTH )
        {
            size = DoGetBestSize();
            width = size.x;
        }
        else
        {
            // just take the current one
            width = currentW;
        }
    }

    if ( height == -1 )
    {
        if ( sizeFlags & wxSIZE_AUTO_HEIGHT )
        {
            if ( size.x == -1 )
            {
                size = DoGetBestSize();
            }
            //else: already called DoGetBestSize() above

            height = size.y;
        }
        else
        {
            // just take the current one
            height = currentH;
        }
    }

    int maxWidth = GetMaxWidth(),
        minWidth = GetMinWidth(),
        maxHeight = GetMaxHeight(),
        minHeight = GetMinHeight();

    if ( minWidth != -1 && width < minWidth ) width = minWidth;
    if ( maxWidth != -1 && width > maxWidth ) width = maxWidth;
    if ( minHeight != -1 && height < minHeight ) height = minHeight;
    if ( maxHeight != -1 && height > maxHeight ) height = maxHeight;

    if ( m_rect.x != x || m_rect.y != y ||
         m_rect.width != width || m_rect.height != height )
    {
        AdjustForParentClientOrigin(x, y, sizeFlags);
        DoMoveWindow(x, y, width, height);

        wxSize newSize(width, height);
        wxSizeEvent event(newSize, GetId());
        event.SetEventObject(this);
        HandleWindowEvent(event);
    }
}
コード例 #23
0
ファイル: RSBmFont.cpp プロジェクト: MagistrAVSH/node3d
int RSBmFont::PutsWithClip( LPBYTE pTarget, long lPitch, int nX, int nY, DWORD color, char *string )
{
	int Bpp=RSPixelFormat==RS_PIXELFORMAT_X888 ? 4 : 2;

	int nTSkipX, nTLenX, nTSkipY = 0, nTLenY1 = -1, nTLenY2 = -1, nTemp, nTotalLength = 0;
	int nSkipX = 0, nLenX = 0;
	bool binit_k = false, binit_e = false;

	if(m_pEngFnt == NULL) return -1;

	if(nX > m_rcClip.right || nY > m_rcClip.bottom) return (0);

	m_pEngFnt->SetColor(color);
	m_pEngFnt->SetlPitch(lPitch);

	if(m_pKorFnt){
		m_pKorFnt->SetColor(color);
		m_pKorFnt->SetlPitch(lPitch);
	}

	nTSkipX = max(m_rcClip.left - nX, 0);
	nTemp = nX + GetStringWidth(string);
	nTLenX = GetStringWidth(string) - max(nTemp - m_rcClip.right, 0);

	nSkipX = nTSkipX;
	nLenX = nTLenX;
	int i,nLength=strlen(string);

	nTemp = 0;

	for(i=0;i<nLength;i++)
	{
		if((unsigned char)string[i]>127)	//한글
		{
			if(m_pKorFnt)
			{
				int yoffset = nY+(GetMaxHeight()-m_pKorFnt->GetHeight()+1)/2;
				nTSkipY = max(m_rcClip.top - yoffset, 0);

				if(!binit_k)
				{
					if(yoffset+m_pKorFnt->GetHeight() < m_rcClip.top) return nTotalLength;
					nTLenY1 = m_pKorFnt->GetHeight() - max(yoffset + m_pKorFnt->GetHeight() - m_rcClip.bottom, 0);
					binit_k = true;
				}

				nSkipX = 0; nLenX = -1;
				
				if(nTSkipX > 0)
				{
					if(nTSkipX >= m_pKorFnt->GetWidth(0))
					{
						nTSkipX -= m_pKorFnt->GetWidth(0);
						nX += m_pKorFnt->GetWidth(0);
						nTLenX -= m_pKorFnt->GetWidth(0);
						i++;
						continue;
					}
					else 
					{
						nSkipX = nTSkipX;
						nTSkipX = 0;
					}
				}

				if(nTLenX > m_pKorFnt->GetWidth(0)){
					nLenX = m_pKorFnt->GetWidth(0);
					nTLenX -= m_pKorFnt->GetWidth(0);
				} else {
					nLenX = nTLenX;
					nTLenX = 0;
					if(nLenX <= 0) return nTotalLength;
				}

				WORD hcode=GetKsIndex(((BYTE)string[i]),((BYTE)string[i+1]));
				m_pKorFnt->Draw(hcode,pTarget+yoffset*lPitch+(nX+nSkipX)*Bpp,nSkipX,nLenX,nTSkipY,nTLenY1);
				nX += m_pKorFnt->GetWidth(0);
				nTotalLength++;
				i++;
			}
		}
		else								//영문
		{
			nSkipX = 0;

			int yoffset = nY+(GetMaxHeight()-m_pEngFnt->GetHeight()+1)/2;
			nTSkipY = max(m_rcClip.top - yoffset, 0);

			if(!binit_e)
			{
				if(yoffset+m_pEngFnt->GetHeight()<m_rcClip.top){
					return nTotalLength;
				}
				nTLenY2 = m_pEngFnt->GetHeight() - max(yoffset + m_pEngFnt->GetHeight() - m_rcClip.bottom, 0);
				binit_e = true;
			}
			
			if(nTSkipX > 0)
			{
				if(m_pEngFnt->GetWidth(string[i]) <= nTSkipX)
				{
					nTSkipX -= m_pEngFnt->GetWidth(string[i]);
					nX += m_pEngFnt->GetWidth(string[i]);
					nTLenX -= m_pEngFnt->GetWidth(string[i]);
					continue;
				}
				else 
				{
					nSkipX = nTSkipX;
					nTSkipX = 0;
				}
			}

			if(nTLenX > m_pEngFnt->GetWidth(string[i])){
				nLenX = m_pEngFnt->GetWidth(string[i]);
				nTLenX -= m_pEngFnt->GetWidth(string[i]);
			} else {
				nLenX = nTLenX;
				nTLenX = 0;
				if(nLenX <= 0) return nTotalLength;
			}

			m_pEngFnt->Draw(string[i],pTarget+yoffset*lPitch+(nX+nSkipX)*Bpp,nSkipX,nLenX,nTSkipY,nTLenY2);
			nTotalLength++;
			nX += m_pEngFnt->GetWidth(string[i]);
		}
	}
	return nTotalLength;
}
コード例 #24
0
ファイル: toplevel.cpp プロジェクト: EdgarTx/wx
void wxTopLevelWindowGTK::GtkOnSize()
{
    // avoid recursions
    if (m_resizing) return;
    m_resizing = true;

    if ( m_wxwindow == NULL ) return;

    /* wxMDIChildFrame derives from wxFrame but it _is_ a wxWindow as it uses
       wxWindow::Create to create it's GTK equivalent. m_mainWidget is only
       set in wxFrame::Create so it is used to check what kind of frame we
       have here. if m_mainWidget is NULL it is a wxMDIChildFrame and so we
       skip the part which handles m_frameMenuBar, m_frameToolBar and (most
       importantly) m_mainWidget */

    int minWidth = GetMinWidth(),
        minHeight = GetMinHeight(),
        maxWidth = GetMaxWidth(),
        maxHeight = GetMaxHeight();

#ifdef __WXGPE__
    // GPE's window manager doesn't like size hints
    // at all, esp. when the user has to use the
    // virtual keyboard.
    minWidth = -1;
    minHeight = -1;
    maxWidth = -1;
    maxHeight = -1;
#endif

    if ((minWidth != -1) && (m_width < minWidth)) m_width = minWidth;
    if ((minHeight != -1) && (m_height < minHeight)) m_height = minHeight;
    if ((maxWidth != -1) && (m_width > maxWidth)) m_width = maxWidth;
    if ((maxHeight != -1) && (m_height > maxHeight)) m_height = maxHeight;

    if (m_mainWidget)
    {
        // m_mainWidget holds the menubar, the toolbar and the client area,
        // which is represented by m_wxwindow.
        int client_x = m_miniEdge;
        int client_y = m_miniEdge + m_miniTitle;
        int client_w = m_width - 2*m_miniEdge;
        int client_h = m_height - 2*m_miniEdge - m_miniTitle;
        if (client_w < 0)
            client_w = 0;
        if (client_h < 0)
            client_h = 0;

        // Let the parent perform the resize
        gtk_pizza_set_size( GTK_PIZZA(m_mainWidget),
                            m_wxwindow,
                            client_x, client_y, client_w, client_h );
    }
    else
    {
        // If there is no m_mainWidget between m_widget and m_wxwindow there
        // is no need to set the size or position of m_wxwindow.
    }

    m_sizeSet = true;

    // send size event to frame
    wxSizeEvent event( wxSize(m_width,m_height), GetId() );
    event.SetEventObject( this );
    GetEventHandler()->ProcessEvent( event );

    m_resizing = false;
}
コード例 #25
0
ファイル: frame.cpp プロジェクト: 3v1n0/wxWidgets
void wxFrame::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y),
                         int width, int height )
{
    // due to a bug in gtk, x,y are always 0
    // m_x = x;
    // m_y = y;

    // avoid recursions
    if (m_resizing) return;
    m_resizing = true;

    // this shouldn't happen: wxFrame, wxMDIParentFrame and wxMDIChildFrame have m_wxwindow
    wxASSERT_MSG( (m_wxwindow != NULL), wxT("invalid frame") );

    m_width = width;
    m_height = height;

    // space occupied by m_frameToolBar and m_frameMenuBar
    int client_area_x_offset = 0,
        client_area_y_offset = 0;

    /* wxMDIChildFrame derives from wxFrame but it _is_ a wxWindow as it uses
       wxWindow::Create to create it's GTK equivalent. m_mainWidget is only
       set in wxFrame::Create so it is used to check what kind of frame we
       have here. if m_mainWidget is NULL it is a wxMDIChildFrame and so we
       skip the part which handles m_frameMenuBar, m_frameToolBar and (most
       importantly) m_mainWidget */

    int minWidth = GetMinWidth(),
        minHeight = GetMinHeight(),
        maxWidth = GetMaxWidth(),
        maxHeight = GetMaxHeight();

    if ((minWidth != -1) && (m_width < minWidth)) m_width = minWidth;
    if ((minHeight != -1) && (m_height < minHeight)) m_height = minHeight;
    if ((maxWidth != -1) && (m_width > maxWidth)) m_width = maxWidth;
    if ((maxHeight != -1) && (m_height > maxHeight)) m_height = maxHeight;

    if (m_mainWidget)
    {
        // set size hints
        gint flag = 0; // GDK_HINT_POS;
        if ((minWidth != -1) || (minHeight != -1)) flag |= GDK_HINT_MIN_SIZE;
        if ((maxWidth != -1) || (maxHeight != -1)) flag |= GDK_HINT_MAX_SIZE;
        GdkGeometry geom;
        geom.min_width = minWidth;
        geom.min_height = minHeight;
        geom.max_width = maxWidth;
        geom.max_height = maxHeight;
        gtk_window_set_geometry_hints( GTK_WINDOW(m_widget),
                                       NULL,
                                       &geom,
                                       (GdkWindowHints) flag );

        // I revert back to wxGTK's original behaviour. m_mainWidget holds
        // the menubar, the toolbar and the client area, which is represented
        // by m_wxwindow.
        // This hurts in the eye, but I don't want to call SetSize()
        // because I don't want to call any non-native functions here.

#if wxUSE_MENUS_NATIVE
        if (m_frameMenuBar)
        {
            int xx = m_miniEdge;
            int yy = m_miniEdge + m_miniTitle;
            int ww = m_width  - 2*m_miniEdge;
            int hh = m_menuBarHeight;
            if (m_menuBarDetached) hh = wxPLACE_HOLDER;
            m_frameMenuBar->m_x = xx;
            m_frameMenuBar->m_y = yy;
            m_frameMenuBar->m_width = ww;
            m_frameMenuBar->m_height = hh;
            gtk_pizza_set_size( GTK_PIZZA(m_mainWidget),
                                  m_frameMenuBar->m_widget,
                                  xx, yy, ww, hh );
            client_area_y_offset += hh;
        }
#endif // wxUSE_MENUS_NATIVE

#if wxUSE_TOOLBAR
        if ((m_frameToolBar) && m_frameToolBar->IsShown() &&
            (m_frameToolBar->m_widget->parent == m_mainWidget))
        {
            int xx = m_miniEdge;
            int yy = m_miniEdge + m_miniTitle;
#if wxUSE_MENUS_NATIVE
            if (m_frameMenuBar)
            {
                if (!m_menuBarDetached)
                    yy += m_menuBarHeight;
                else
                    yy += wxPLACE_HOLDER;
            }
#endif // wxUSE_MENUS_NATIVE

            m_frameToolBar->m_x = xx;
            m_frameToolBar->m_y = yy;

            // don't change the toolbar's reported height/width
            int ww, hh;
            if ( m_frameToolBar->GetWindowStyle() & wxTB_VERTICAL )
            {
                ww = m_toolBarDetached ? wxPLACE_HOLDER
                                       : m_frameToolBar->m_width;
                hh = m_height - 2*m_miniEdge;

                client_area_x_offset += ww;
            }
            else
            {
                ww = m_width - 2*m_miniEdge;
                hh = m_toolBarDetached ? wxPLACE_HOLDER
                                       : m_frameToolBar->m_height;

                client_area_y_offset += hh;
            }

            gtk_pizza_set_size( GTK_PIZZA(m_mainWidget),
                                  m_frameToolBar->m_widget,
                                  xx, yy, ww, hh );
        }
#endif // wxUSE_TOOLBAR

        int client_x = client_area_x_offset + m_miniEdge;
        int client_y = client_area_y_offset + m_miniEdge + m_miniTitle;
        int client_w = m_width - client_area_x_offset - 2*m_miniEdge;
        int client_h = m_height - client_area_y_offset- 2*m_miniEdge - m_miniTitle;
        gtk_pizza_set_size( GTK_PIZZA(m_mainWidget),
                              m_wxwindow,
                              client_x, client_y, client_w, client_h );
    }
    else
    {
        // If there is no m_mainWidget between m_widget and m_wxwindow there
        // is no need to set the size or position of m_wxwindow.
    }

#if wxUSE_STATUSBAR
    if (m_frameStatusBar && m_frameStatusBar->IsShown())
    {
        int xx = 0 + m_miniEdge;
        int yy = m_height - wxSTATUS_HEIGHT - m_miniEdge - client_area_y_offset;
        int ww = m_width - 2*m_miniEdge;
        int hh = wxSTATUS_HEIGHT;
        m_frameStatusBar->m_x = xx;
        m_frameStatusBar->m_y = yy;
        m_frameStatusBar->m_width = ww;
        m_frameStatusBar->m_height = hh;
        gtk_pizza_set_size( GTK_PIZZA(m_wxwindow),
                            m_frameStatusBar->m_widget,
                            xx, yy, ww, hh );
        gtk_widget_draw( m_frameStatusBar->m_widget, NULL );
    }
#endif // wxUSE_STATUSBAR

    m_sizeSet = true;

    // send size event to frame
    wxSizeEvent event( wxSize(m_width,m_height), GetId() );
    event.SetEventObject( this );
    HandleWindowEvent( event );

#if wxUSE_STATUSBAR
    // send size event to status bar
    if (m_frameStatusBar)
    {
        wxSizeEvent event2( wxSize(m_frameStatusBar->m_width,m_frameStatusBar->m_height), m_frameStatusBar->GetId() );
        event2.SetEventObject( m_frameStatusBar );
        m_frameStatusBar->HandleWindowEvent( event2 );
    }
#endif // wxUSE_STATUSBAR

    m_resizing = false;
}
コード例 #26
0
ファイル: UIVerticalLayout.cpp プロジェクト: hgl888/TeamTalk
	void CVerticalLayoutUI::DoEvent(TEventUI& event)
	{
		if( m_iSepHeight != 0 ) {
			if( event.Type == UIEVENT_BUTTONDOWN && IsEnabled() )
			{
				RECT rcSeparator = GetThumbRect(false);
				if( ::PtInRect(&rcSeparator, event.ptMouse) ) {
					m_uButtonState |= UISTATE_CAPTURED;
					ptLastMouse = event.ptMouse;
					m_rcNewPos = m_rcItem;
					if( !m_bImmMode && m_pManager ) m_pManager->AddPostPaint(this);
					return;
				}
			}
			if( event.Type == UIEVENT_BUTTONUP )
			{
				if( (m_uButtonState & UISTATE_CAPTURED) != 0 ) {
					m_uButtonState &= ~UISTATE_CAPTURED;
					m_rcItem = m_rcNewPos;
					if( !m_bImmMode && m_pManager ) m_pManager->RemovePostPaint(this);
					NeedParentUpdate();
					return;
				}
			}
			if( event.Type == UIEVENT_MOUSEMOVE )
			{
				if( (m_uButtonState & UISTATE_CAPTURED) != 0 ) {
					LONG cy = event.ptMouse.y - ptLastMouse.y;
					ptLastMouse = event.ptMouse;
					RECT rc = m_rcNewPos;
					if( m_iSepHeight >= 0 ) {
						if( cy > 0 && event.ptMouse.y < m_rcNewPos.bottom + m_iSepHeight ) return;
						if( cy < 0 && event.ptMouse.y > m_rcNewPos.bottom ) return;
						rc.bottom += cy;
						if( rc.bottom - rc.top <= GetMinHeight() ) {
							if( m_rcNewPos.bottom - m_rcNewPos.top <= GetMinHeight() ) return;
							rc.bottom = rc.top + GetMinHeight();
						}
						if( rc.bottom - rc.top >= GetMaxHeight() ) {
							if( m_rcNewPos.bottom - m_rcNewPos.top >= GetMaxHeight() ) return;
							rc.bottom = rc.top + GetMaxHeight();
						}
					}
					else {
						if( cy > 0 && event.ptMouse.y < m_rcNewPos.top ) return;
						if( cy < 0 && event.ptMouse.y > m_rcNewPos.top + m_iSepHeight ) return;
						rc.top += cy;
						if( rc.bottom - rc.top <= GetMinHeight() ) {
							if( m_rcNewPos.bottom - m_rcNewPos.top <= GetMinHeight() ) return;
							rc.top = rc.bottom - GetMinHeight();
						}
						if( rc.bottom - rc.top >= GetMaxHeight() ) {
							if( m_rcNewPos.bottom - m_rcNewPos.top >= GetMaxHeight() ) return;
							rc.top = rc.bottom - GetMaxHeight();
						}
					}

					CDuiRect rcInvalidate = GetThumbRect(true);
					m_rcNewPos = rc;
					m_cxyFixed.cy = m_rcNewPos.bottom - m_rcNewPos.top;

					if( m_bImmMode ) {
						m_rcItem = m_rcNewPos;
						NeedParentUpdate();
					}
					else {
						rcInvalidate.Join(GetThumbRect(true));
						rcInvalidate.Join(GetThumbRect(false));
						if( m_pManager ) m_pManager->Invalidate(rcInvalidate);
					}
					return;
				}
			}
			if( event.Type == UIEVENT_SETCURSOR )
			{
				RECT rcSeparator = GetThumbRect(false);
				if( IsEnabled() && ::PtInRect(&rcSeparator, event.ptMouse) ) {
					::SetCursor(::LoadCursor(NULL, MAKEINTRESOURCE(IDC_SIZENS)));
					return;
				}
			}
		}
		CContainerUI::DoEvent(event);
	}
コード例 #27
0
ファイル: frame.cpp プロジェクト: Bluehorn/wxPython
void wxFrame::GtkOnSize()
{
    // avoid recursions
    if (m_resizing) return;
    m_resizing = true;

    // this shouldn't happen: wxFrame, wxMDIParentFrame and wxMDIChildFrame have m_wxwindow
    wxASSERT_MSG( (m_wxwindow != NULL), wxT("invalid frame") );

    // space occupied by m_frameToolBar and m_frameMenuBar
    int client_area_x_offset = 0,
        client_area_y_offset = 0;

    /* wxMDIChildFrame derives from wxFrame but it _is_ a wxWindow as it uses
       wxWindow::Create to create it's GTK equivalent. m_mainWidget is only
       set in wxFrame::Create so it is used to check what kind of frame we
       have here. if m_mainWidget is NULL it is a wxMDIChildFrame and so we
       skip the part which handles m_frameMenuBar, m_frameToolBar and (most
       importantly) m_mainWidget */

    int minWidth = GetMinWidth(),
        minHeight = GetMinHeight(),
        maxWidth = GetMaxWidth(),
        maxHeight = GetMaxHeight();

    if ((minWidth != -1) && (m_width < minWidth)) m_width = minWidth;
    if ((minHeight != -1) && (m_height < minHeight)) m_height = minHeight;
    if ((maxWidth != -1) && (m_width > maxWidth)) m_width = maxWidth;
    if ((maxHeight != -1) && (m_height > maxHeight)) m_height = maxHeight;

    if (m_mainWidget)
    {
        // TODO
        // Rewrite this terrible code to using GtkVBox

        // m_mainWidget holds the menubar, the toolbar and the client
        // area, which is represented by m_wxwindow.

#if wxUSE_MENUS_NATIVE
        if (m_frameMenuBar && !(m_fsIsShowing && (m_fsSaveFlag & wxFULLSCREEN_NOMENUBAR) != 0))
        {
            if (m_frameMenuBar->IsShown() && !GTK_WIDGET_VISIBLE(m_frameMenuBar->m_widget))
                gtk_widget_show( m_frameMenuBar->m_widget );
            int xx = m_miniEdge;
            int yy = m_miniEdge + m_miniTitle;
            int ww = m_width  - 2*m_miniEdge;
            if (ww < 0)
                ww = 0;
            int hh = m_menuBarHeight;
            if (m_menuBarDetached) hh = wxPLACE_HOLDER;
            m_frameMenuBar->m_x = xx;
            m_frameMenuBar->m_y = yy;
            m_frameMenuBar->m_width = ww;
            m_frameMenuBar->m_height = hh;
            gtk_pizza_set_size( GTK_PIZZA(m_mainWidget),
                                  m_frameMenuBar->m_widget,
                                  xx, yy, ww, hh );
            client_area_y_offset += hh;
        }
        else
        {
            if (m_frameMenuBar)
            {
                if (GTK_WIDGET_VISIBLE(m_frameMenuBar->m_widget))
                    gtk_widget_hide( m_frameMenuBar->m_widget );
            }
        }
#endif // wxUSE_MENUS_NATIVE

#if wxUSE_TOOLBAR
        if ((m_frameToolBar) && m_frameToolBar->IsShown() &&
            (m_frameToolBar->m_widget->parent == m_mainWidget))
        {
            int xx = m_miniEdge;
            int yy = m_miniEdge + m_miniTitle;
#if wxUSE_MENUS_NATIVE
            if (m_frameMenuBar)
            {
                if (!m_menuBarDetached)
                    yy += m_menuBarHeight;
                else
                    yy += wxPLACE_HOLDER;
            }
#endif // wxUSE_MENUS_NATIVE

            m_frameToolBar->m_x = xx;
            m_frameToolBar->m_y = yy;

            // don't change the toolbar's reported height/width
            int ww, hh;
            if ( m_frameToolBar->GetWindowStyle() & wxTB_VERTICAL )
            {
                ww = m_toolBarDetached ? wxPLACE_HOLDER
                                       : m_frameToolBar->m_width;
                hh = m_height - 2*m_miniEdge;

                client_area_x_offset += ww;
            }
            else if( m_frameToolBar->HasFlag(wxTB_RIGHT) )
            {
               yy += 2;
               ww = m_toolBarDetached ? wxPLACE_HOLDER
                                      : m_frameToolBar->m_width;
               xx = GetClientSize().x - 1;
               hh = m_height - 2*m_miniEdge;
               if( hh < 0 )
                  hh = 0;

            }
            else if( m_frameToolBar->GetWindowStyle() & wxTB_BOTTOM )
            {
                xx = m_miniEdge;
                yy = GetClientSize().y;
#if wxUSE_MENUS_NATIVE
                yy += m_menuBarHeight;
#endif // wxUSE_MENU_NATIVE
                m_frameToolBar->m_x = xx;
                m_frameToolBar->m_y = yy;
                ww = m_width - 2*m_miniEdge;
                hh = m_toolBarDetached ? wxPLACE_HOLDER
                                       : m_frameToolBar->m_height;
            }
            else
            {
                ww = m_width - 2*m_miniEdge;
                hh = m_toolBarDetached ? wxPLACE_HOLDER
                                       : m_frameToolBar->m_height;

                client_area_y_offset += hh;
            }

            if (ww < 0)
                ww = 0;
            if (hh < 0)
                hh = 0;
            gtk_pizza_set_size( GTK_PIZZA(m_mainWidget),
                                  m_frameToolBar->m_widget,
                                  xx, yy, ww, hh );
        }
#endif // wxUSE_TOOLBAR

        int client_x = client_area_x_offset + m_miniEdge;
        int client_y = client_area_y_offset + m_miniEdge + m_miniTitle;
        int client_w = m_width - client_area_x_offset - 2*m_miniEdge;
        int client_h = m_height - client_area_y_offset- 2*m_miniEdge - m_miniTitle;
        if (client_w < 0)
            client_w = 0;
        if (client_h < 0)
            client_h = 0;
        gtk_pizza_set_size( GTK_PIZZA(m_mainWidget),
                              m_wxwindow,
                              client_x, client_y, client_w, client_h );
    }
    else
    {
        // If there is no m_mainWidget between m_widget and m_wxwindow there
        // is no need to set the size or position of m_wxwindow.
    }

#if wxUSE_STATUSBAR
    if (m_frameStatusBar && m_frameStatusBar->IsShown() &&
        !(m_fsIsShowing && (m_fsSaveFlag & wxFULLSCREEN_NOSTATUSBAR) != 0))
    {
        if (!GTK_WIDGET_VISIBLE(m_frameStatusBar->m_widget))
            gtk_widget_show( m_frameStatusBar->m_widget );
            
        int xx = 0 + m_miniEdge;
        int yy = m_height - wxSTATUS_HEIGHT - m_miniEdge - client_area_y_offset;
        int ww = m_width - 2*m_miniEdge;
        if (ww < 0)
            ww = 0;
        int hh = wxSTATUS_HEIGHT;
        m_frameStatusBar->m_x = xx;
        m_frameStatusBar->m_y = yy;
        m_frameStatusBar->m_width = ww;
        m_frameStatusBar->m_height = hh;
        gtk_pizza_set_size( GTK_PIZZA(m_wxwindow),
                            m_frameStatusBar->m_widget,
                            xx, yy, ww, hh );
    }
    else
    {
        if (m_frameStatusBar)
        {
            if (GTK_WIDGET_VISIBLE(m_frameStatusBar->m_widget))
                gtk_widget_hide( m_frameStatusBar->m_widget );
        }
    }
#endif // wxUSE_STATUSBAR

    m_sizeSet = true;

    // send size event to frame
    wxSizeEvent event( wxSize(m_width,m_height), GetId() );
    event.SetEventObject( this );
    GetEventHandler()->ProcessEvent( event );

#if wxUSE_STATUSBAR
    // send size event to status bar
    if (m_frameStatusBar)
    {
        wxSizeEvent event2( wxSize(m_frameStatusBar->m_width,m_frameStatusBar->m_height), m_frameStatusBar->GetId() );
        event2.SetEventObject( m_frameStatusBar );
        m_frameStatusBar->GetEventHandler()->ProcessEvent( event2 );
    }
#endif // wxUSE_STATUSBAR

    m_resizing = false;
}
コード例 #28
0
//this message to handle to control the height of the window depending on 
//the visibility of the horizontal scrollbar when ever it is shown
//Horz Scrollbar Visibility is decided by the difference between 
//the WindowRect and ClentRect
LRESULT COXMultiComboBox::COXComboLBox::OnWindowPosChanging(WPARAM wParam, 
															LPARAM lParam)
{	

	LPWINDOWPOS lpWP = (LPWINDOWPOS) lParam;	

	if( (!(lpWP->flags & SWP_NOSIZE))) 
	{

		int nTotalHeight = ((COXMultiComboBox*)m_pWndCombo)->GetTotalHeight();
		int nBorderHeight = GetSystemMetrics(SM_CYBORDER);
		int nScrollbarHeight = GetSystemMetrics(SM_CYHSCROLL);
		CRect rcDrop;
		((COXMultiComboBox*)m_pWndCombo)->GetDroppedControlRect(&rcDrop);

		//Check and see if listbox appears
		//in a random position and if so, fix it - Nish, Feb 24, 2005
		int orig_cy = lpWP->cy;
		if(m_fHorzScrollVisible)
		{
			if(nTotalHeight+nScrollbarHeight+2*nBorderHeight<=rcDrop.Height())
				lpWP->cy = nTotalHeight+nScrollbarHeight + 2*nBorderHeight;
			else
				lpWP->cy = GetMaxHeight();
		}
		else
		{
			if(nTotalHeight + 2*nBorderHeight <= rcDrop.Height())
				lpWP->cy = nTotalHeight + 2*nBorderHeight;
			else
				lpWP->cy = GetMaxHeight();
		}
		//Fixing listbox position - Nish
		if(orig_cy != lpWP->cy)
		{
			CRect rCbEdit;
			m_pWndCombo->GetWindowRect(&rCbEdit);				
			lpWP->y = lpWP->y + (orig_cy - lpWP->cy);
			if(lpWP->y > rCbEdit.bottom)
			{
				lpWP->y = rCbEdit.bottom;
			}
			else {
				if(lpWP->y < rCbEdit.bottom) {
					lpWP->y = rCbEdit.bottom;
				}
			}

		}			
	}				

	// check if the right side of the combo list box is out of screen coordinates
	int nScreenWidth=::GetSystemMetrics(SM_CXSCREEN);
	if(lpWP->x+lpWP->cx>nScreenWidth)
	{
		lpWP->x=nScreenWidth-lpWP->cx;
		lpWP->x=lpWP->x>0 ? lpWP->x : 0;

		// remove SWP_NOMOVE flag
		lpWP->flags&=~SWP_NOMOVE;
	}	

	return DefWindowProc(WM_WINDOWPOSCHANGING,wParam,lParam);

}
コード例 #29
0
ファイル: toplevel.cpp プロジェクト: CobaltBlues/wxWidgets
void wxTopLevelWindowGTK::DoSetSize( int x, int y, int width, int height, int sizeFlags )
{
    wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") );

    // this shouldn't happen: wxFrame, wxMDIParentFrame and wxMDIChildFrame have m_wxwindow
    wxASSERT_MSG( (m_wxwindow != NULL), wxT("invalid frame") );

    // avoid recursions
    if (m_resizing)
        return;
    m_resizing = true;

    int old_x = m_x;
    int old_y = m_y;

    int old_width = m_width;
    int old_height = m_height;

    if ((sizeFlags & wxSIZE_ALLOW_MINUS_ONE) == 0)
    {
        if (x != -1) m_x = x;
        if (y != -1) m_y = y;
    }
    else
    {
        m_x = x;
        m_y = y;
    }
    if (width != -1) m_width = width;
    if (height != -1) m_height = height;

/*
    if ((sizeFlags & wxSIZE_AUTO_WIDTH) == wxSIZE_AUTO_WIDTH)
    {
        if (width == -1) m_width = 80;
    }

    if ((sizeFlags & wxSIZE_AUTO_HEIGHT) == wxSIZE_AUTO_HEIGHT)
    {
       if (height == -1) m_height = 26;
    }
*/

    int minWidth = GetMinWidth(),
        minHeight = GetMinHeight(),
        maxWidth = GetMaxWidth(),
        maxHeight = GetMaxHeight();

#ifdef __WXGPE__
    // GPE's window manager doesn't like size hints
    // at all, esp. when the user has to use the
    // virtual keyboard.
    minWidth = -1;
    minHeight = -1;
    maxWidth = -1;
    maxHeight = -1;
#endif

    if ((minWidth != -1) && (m_width < minWidth)) m_width = minWidth;
    if ((minHeight != -1) && (m_height < minHeight)) m_height = minHeight;
    if ((maxWidth != -1) && (m_width > maxWidth)) m_width = maxWidth;
    if ((maxHeight != -1) && (m_height > maxHeight)) m_height = maxHeight;

    if ((m_x != -1) || (m_y != -1))
    {
        if ((m_x != old_x) || (m_y != old_y))
        {
            gtk_widget_set_uposition( m_widget, m_x, m_y );
        }
    }

    if ((m_width != old_width) || (m_height != old_height))
    {
        if (m_widget->window)
            gdk_window_resize( m_widget->window, m_width, m_height );
        else
            gtk_window_set_default_size( GTK_WINDOW(m_widget), m_width, m_height );

        /* we set the size in GtkOnSize, i.e. mostly the actual resizing is
           done either directly before the frame is shown or in idle time
           so that different calls to SetSize() don't lead to flicker. */
        m_sizeSet = false;
    }

    m_resizing = false;
}
コード例 #30
0
ファイル: toplevel.cpp プロジェクト: CobaltBlues/wxWidgets
void wxTopLevelWindowGTK::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y),
                                     int width, int height )
{
    // due to a bug in gtk, x,y are always 0
    // m_x = x;
    // m_y = y;

    // avoid recursions
    if (m_resizing) return;
    m_resizing = true;

    if ( m_wxwindow == NULL ) return;

    m_width = width;
    m_height = height;

    /* wxMDIChildFrame derives from wxFrame but it _is_ a wxWindow as it uses
       wxWindow::Create to create it's GTK equivalent. m_mainWidget is only
       set in wxFrame::Create so it is used to check what kind of frame we
       have here. if m_mainWidget is NULL it is a wxMDIChildFrame and so we
       skip the part which handles m_frameMenuBar, m_frameToolBar and (most
       importantly) m_mainWidget */

    int minWidth = GetMinWidth(),
        minHeight = GetMinHeight(),
        maxWidth = GetMaxWidth(),
        maxHeight = GetMaxHeight();

#ifdef __WXGPE__
    // GPE's window manager doesn't like size hints
    // at all, esp. when the user has to use the
    // virtual keyboard.
    minWidth = -1;
    minHeight = -1;
    maxWidth = -1;
    maxHeight = -1;
#endif

    if ((minWidth != -1) && (m_width < minWidth)) m_width = minWidth;
    if ((minHeight != -1) && (m_height < minHeight)) m_height = minHeight;
    if ((maxWidth != -1) && (m_width > maxWidth)) m_width = maxWidth;
    if ((maxHeight != -1) && (m_height > maxHeight)) m_height = maxHeight;

    if (m_mainWidget)
    {
        // set size hints
        gint            flag = 0; // GDK_HINT_POS;
        GdkGeometry     geom;

        if ((minWidth != -1) || (minHeight != -1)) flag |= GDK_HINT_MIN_SIZE;
        if ((maxWidth != -1) || (maxHeight != -1)) flag |= GDK_HINT_MAX_SIZE;

        geom.min_width = minWidth;
        geom.min_height = minHeight;

            // Because of the way we set GDK_HINT_MAX_SIZE above, if either of
            // maxHeight or maxWidth is set, we must set them both, else the
            // remaining -1 will be taken literally.

            // I'm certain this also happens elsewhere, and is the probable
            // cause of other such things as:
            // Gtk-WARNING **: gtk_widget_size_allocate():
            //       attempt to allocate widget with width 65535 and height 600
            // but I don't have time to track them all now..
            //
            // Really we need to encapulate all this height/width business and
            // stop any old method from ripping at the members directly and
            // scattering -1's without regard for who might resolve them later.

        geom.max_width = ( maxHeight == -1 ) ? maxWidth
                         : ( maxWidth == -1 ) ? wxGetDisplaySize().GetWidth()
                           : maxWidth ;

        geom.max_height = ( maxWidth == -1 ) ? maxHeight    // ( == -1 here )
                          : ( maxHeight == -1 ) ? wxGetDisplaySize().GetHeight()
                            : maxHeight ;

        gtk_window_set_geometry_hints( GTK_WINDOW(m_widget),
                                       NULL,
                                       &geom,
                                       (GdkWindowHints) flag );

        /* I revert back to wxGTK's original behaviour. m_mainWidget holds the
         * menubar, the toolbar and the client area, which is represented by
         * m_wxwindow.
         * this hurts in the eye, but I don't want to call SetSize()
         * because I don't want to call any non-native functions here. */

        int client_x = m_miniEdge;
        int client_y = m_miniEdge + m_miniTitle;
        int client_w = m_width - 2*m_miniEdge;
        int client_h = m_height - 2*m_miniEdge - m_miniTitle;

        gtk_pizza_set_size( GTK_PIZZA(m_mainWidget),
                              m_wxwindow,
                              client_x, client_y, client_w, client_h );
    }
    else
    {
        // If there is no m_mainWidget between m_widget and m_wxwindow there
        // is no need to set the size or position of m_wxwindow.
    }

    m_sizeSet = true;

    // send size event to frame
    wxSizeEvent event( wxSize(m_width,m_height), GetId() );
    event.SetEventObject( this );
    HandleWindowEvent( event );

    m_resizing = false;
}