Пример #1
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();
}
Пример #2
0
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 );
}
Пример #3
0
void CRoiDlg::UpdateRange()
{
    m_SpinX.SetRange(0,GetMaxX());
    m_SpinY.SetRange(0,GetMaxY());
    m_SpinWidth.SetRange(1,GetMaxWidth());
    m_SpinHeight.SetRange(1,GetMaxHeight());
}
OpPoint FormElementOfInterest::UpdateFragmentPositions(int preferred_w, int preferred_h)
{
	// Calculate new dest_rect
	int total_w = 0;
	int total_h = 0;
	int x = LAYER_PADDING;
	OpWidget *root = widget_container->GetRoot();
	for (AnchorFragment* fragment = (AnchorFragment*) region.First(); fragment; fragment = fragment->Suc())
	{
		TextAnchorFragment *text_anchor_frag = fragment->GetTextAnchorFragment();
		if (text_anchor_frag)
		{
			OP_STATUS err = text_anchor_frag->UpdateWidgetString(root, GetMaxWidth() - preferred_w, FALSE);
			OP_ASSERT(OpStatus::IsSuccess(err));
			if (OpStatus::IsError(err))
				return OpPoint(0, 0); // Bad error handling.
		}

		int frag_w = fragment->GetWidth();
		int frag_h = fragment->GetHeight();
		fragment->SetPos(x, (preferred_h + LAYER_PADDING*2 - fragment->GetHeight()) / 2);

		total_w += frag_w;
		total_h = MAX(total_h, frag_h);
		x += frag_w;
	}

	return OpPoint(total_w, total_h);
}
Пример #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
void CRoiDlg::OnKillfocusRoiX()
{
    m_Roi.width = GetInt(&m_WidthEdit);
    m_Roi.x = GetInt(&m_XEdit);
    UpdateValue(m_Roi.x, 0, GetMaxX());
    UpdateValue(m_Roi.width, 1, GetMaxWidth(), &m_SpinWidth);
    UpdateData(FALSE);
}
Пример #7
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();
}
Пример #8
0
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;
    }
  }
}
Пример #9
0
void wxListBox::UpdateScrollbars()
{
    wxSize size = GetClientSize();

    // is our height enough to show all items?
    int nLines = GetCount();
    wxCoord lineHeight = GetLineHeight();
    bool showScrollbarY = nLines*lineHeight > size.y;

    // check the width too if required
    wxCoord charWidth, maxWidth;
    bool showScrollbarX;
    if ( HasHorzScrollbar() )
    {
        charWidth = GetCharWidth();
        maxWidth = GetMaxWidth();
        showScrollbarX = maxWidth > size.x;
    }
    else // never show it
    {
        charWidth = maxWidth = 0;
        showScrollbarX = false;
    }

    // what should be the scrollbar range now?
    int scrollRangeX = showScrollbarX
                        ? (maxWidth + charWidth - 1) / charWidth + 2 // FIXME
                        : 0;
    int scrollRangeY = showScrollbarY
                        ? nLines +
                            (size.y % lineHeight + lineHeight - 1) / lineHeight
                        : 0;

    // reset scrollbars if something changed: either the visibility status
    // or the range of a scrollbar which is shown
    if ( (showScrollbarY != m_showScrollbarY) ||
         (showScrollbarX != m_showScrollbarX) ||
         (showScrollbarY && (scrollRangeY != m_scrollRangeY)) ||
         (showScrollbarX && (scrollRangeX != m_scrollRangeX)) )
    {
        int x, y;
        GetViewStart(&x, &y);
        SetScrollbars(charWidth, lineHeight,
                      scrollRangeX, scrollRangeY,
                      x, y);

        m_showScrollbarX = showScrollbarX;
        m_showScrollbarY = showScrollbarY;

        m_scrollRangeX = scrollRangeX;
        m_scrollRangeY = scrollRangeY;
    }
}
Пример #10
0
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 );
    }
}
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
}
Пример #12
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;
}
Пример #13
0
void CGUILabel::UpdateRenderRect()
{
  // recalculate our text layout
  float width, height;
  m_textLayout.GetTextExtent(width, height);
  width = std::min(width, GetMaxWidth());
  if (m_label.align & XBFONT_CENTER_Y)
    m_renderRect.y1 = m_maxRect.y1 + (m_maxRect.Height() - height) * 0.5f;
  else
    m_renderRect.y1 = m_maxRect.y1 + m_label.offsetY;
  if (m_label.align & XBFONT_RIGHT)
    m_renderRect.x1 = m_maxRect.x2 - width - m_label.offsetX;
  else if (m_label.align & XBFONT_CENTER_X)
    m_renderRect.x1 = m_maxRect.x1 + (m_maxRect.Width() - width) * 0.5f;
  else
    m_renderRect.x1 = m_maxRect.x1 + m_label.offsetX;
  m_renderRect.x2 = m_renderRect.x1 + width;
  m_renderRect.y2 = m_renderRect.y1 + height;
}
Пример #14
0
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());
}
Пример #15
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;
}
Пример #16
0
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;
}
Пример #17
0
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;
}
Пример #18
0
void Text::UpdateText(bool inResize)
{
    int width = 0;
    int height = 0;
    
    rowWidths_.Clear();
    printText_.Clear();
    
    PODVector<unsigned> printToText;
    
    if (font_)
    {
        const FontFace* face = font_->GetFace(fontSize_);
        if (!face)
            return;
        
        rowHeight_ = face->rowHeight_;
        int rowWidth = 0;
        int rowHeight = (int)(rowSpacing_ * rowHeight_);
        
        // First see if the text must be split up
        if (!wordWrap_)
        {
            printText_ = unicodeText_;
            printToText.Resize(printText_.Size());
            for (unsigned i = 0; i < printText_.Size(); ++i)
                printToText[i] = i;
        }
        else
        {
            int maxWidth = GetWidth();
            unsigned nextBreak = 0;
            unsigned lineStart = 0;
            for (unsigned i = 0; i < unicodeText_.Size(); ++i)
            {
                unsigned j;
                unsigned c = unicodeText_[i];
                
                if (c != '\n')
                {
                    bool ok = true;
                    
                    if (nextBreak <= i)
                    {
                        int futureRowWidth = rowWidth;
                        for (j = i; j < unicodeText_.Size(); ++j)
                        {
                            unsigned d = unicodeText_[j];
                            if (d == ' ' || d == '\n')
                            {
                                nextBreak = j;
                                break;
                            }
                            futureRowWidth += face->GetGlyph(d).advanceX_;
                            if (j < unicodeText_.Size() - 1)
                                futureRowWidth += face->GetKerning(d, unicodeText_[j + 1]);
                            if (d == '-' && futureRowWidth <= maxWidth)
                            {
                                nextBreak = j + 1;
                                break;
                            }
                            if (futureRowWidth > maxWidth)
                            {
                                ok = false;
                                break;
                            }
                        }
                    }
                    
                    if (!ok)
                    {
                        // If did not find any breaks on the line, copy until j, or at least 1 char, to prevent infinite loop
                        if (nextBreak == lineStart)
                        {
                            while (i < j)
                            {
                                printText_.Push(unicodeText_[i]);
                                printToText.Push(i);
                                ++i;
                            }
                        }
                        printText_.Push('\n');
                        printToText.Push(Min((int)i, (int)unicodeText_.Size() - 1));
                        rowWidth = 0;
                        nextBreak = lineStart = i;
                    }
                    
                    if (i < unicodeText_.Size())
                    {
                        // When copying a space, position is allowed to be over row width
                        c = unicodeText_[i];
                        rowWidth += face->GetGlyph(c).advanceX_;
                        if (i < text_.Length() - 1)
                            rowWidth += face->GetKerning(c, unicodeText_[i + 1]);
                        if (rowWidth <= maxWidth)
                        {
                            printText_.Push(c);
                            printToText.Push(i);
                        }
                    }
                }
                else
                {
                    printText_.Push('\n');
                    printToText.Push(Min((int)i, (int)unicodeText_.Size() - 1));
                    rowWidth = 0;
                    nextBreak = lineStart = i;
                }
            }
        }
        
        rowWidth = 0;
        
        for (unsigned i = 0; i < printText_.Size(); ++i)
        {
            unsigned c = printText_[i];
            
            if (c != '\n')
            {
                const FontGlyph& glyph = face->GetGlyph(c);
                rowWidth += glyph.advanceX_;
                if (i < printText_.Size() - 1)
                    rowWidth += face->GetKerning(c, printText_[i + 1]);
            }
            else
            {
                width = Max(width, rowWidth);
                height += rowHeight;
                rowWidths_.Push(rowWidth);
                rowWidth = 0;
            }
        }
        
        if (rowWidth)
        {
            width = Max(width, rowWidth);
            height += rowHeight;
            rowWidths_.Push(rowWidth);
        }
        
        // Set row height even if text is empty
        if (!height)
            height = rowHeight;
        
        // Store position & size of each character
        charPositions_.Resize(unicodeText_.Size() + 1);
        charSizes_.Resize(unicodeText_.Size());
        
        unsigned rowIndex = 0;
        int x = GetRowStartPosition(rowIndex);
        int y = 0;
        for (unsigned i = 0; i < printText_.Size(); ++i)
        {
            charPositions_[printToText[i]] = IntVector2(x, y);
            unsigned c = printText_[i];
            if (c != '\n')
            {
                const FontGlyph& glyph = face->GetGlyph(c);
                charSizes_[printToText[i]] = IntVector2(glyph.advanceX_, rowHeight_);
                x += glyph.advanceX_;
                if (i < printText_.Size() - 1)
                    x += face->GetKerning(c, printText_[i + 1]);
            }
            else
            {
                charSizes_[printToText[i]] = IntVector2::ZERO;
                x = GetRowStartPosition(++rowIndex);
                y += rowHeight;
            }
        }
        // Store the ending position
        charPositions_[unicodeText_.Size()] = IntVector2(x, y);
    }
    
    // Set minimum and current size according to the text size, but respect fixed width if set
    if (GetMinWidth() != GetMaxWidth())
    {
        SetMinWidth(width);
        SetWidth(width);
    }
    SetFixedHeight(height);
}
Пример #19
0
	void CHorizontalLayoutUI::DoEvent(TEventUI& event)
	{
		if( m_iSepWidth != 0 ) {
			if( event.Type == UIEVENT_BUTTONDOWN && IsEnabled() )
			{
				RECT rcSeparator = GetThumbRect(false);
				if( ::PtInRect(&rcSeparator, event.ptMouse) ) {
					m_uButtonState |= UISTATE_CAPTURED;
					m_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 cx = event.ptMouse.x - m_ptLastMouse.x;
					m_ptLastMouse = event.ptMouse;
					RECT rc = m_rcNewPos;
					if( m_iSepWidth >= 0 ) {
						if( cx > 0 && event.ptMouse.x < m_rcNewPos.right - m_iSepWidth ) return;
						if( cx < 0 && event.ptMouse.x > m_rcNewPos.right ) return;
						rc.right += cx;
						if( rc.right - rc.left <= GetMinWidth() ) {
							if( m_rcNewPos.right - m_rcNewPos.left <= GetMinWidth() ) return;
							rc.right = rc.left + GetMinWidth();
						}
						if( rc.right - rc.left >= GetMaxWidth() ) {
							if( m_rcNewPos.right - m_rcNewPos.left >= GetMaxWidth() ) return;
							rc.right = rc.left + GetMaxWidth();
						}
					}
					else {
						if( cx > 0 && event.ptMouse.x < m_rcNewPos.left ) return;
						if( cx < 0 && event.ptMouse.x > m_rcNewPos.left - m_iSepWidth ) return;
						rc.left += cx;
						if( rc.right - rc.left <= GetMinWidth() ) {
							if( m_rcNewPos.right - m_rcNewPos.left <= GetMinWidth() ) return;
							rc.left = rc.right - GetMinWidth();
						}
						if( rc.right - rc.left >= GetMaxWidth() ) {
							if( m_rcNewPos.right - m_rcNewPos.left >= GetMaxWidth() ) return;
							rc.left = rc.right - GetMaxWidth();
						}
					}

					CDuiRect rcInvalidate = GetThumbRect(true);
					m_rcNewPos = rc;
					m_cxyFixed.cx = m_rcNewPos.right - m_rcNewPos.left;

					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_SIZEWE)));
					return;
				}
			}
		}
		CContainerUI::DoEvent(event);
	}
Пример #20
0
// 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);
    }
}
Пример #21
0
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;
}
OP_STATUS FormElementOfInterest::MakeClone(BOOL expanded)
{
	OpRect anim_start_rect;
	float  anim_start_opacity = 0.0f;
	if (expanded)
	{
		if (GetElementExpander()->GetState() == EE_EXPANDED)
		{
			anim_start_rect = dest_rect;
			anim_start_opacity = 1.0f;
		}
		else
		{
			anim_start_rect = orig_rect;
		}
	}

	OpWidget *old_widget = clone;
	OpWidget *root = widget_container->GetRoot();

	RETURN_IF_ERROR(source->CreateClone(&clone, root, WIDGETS_F_T_FONTSIZE, expanded));

	if (old_widget)
	{
		old_widget->Remove();
		old_widget->Delete();
	}

	INT32 cols = 20;
	INT32 rows = GetPreferredNumberOfRows(expanded);

	int minimum_size = (ElementExpander::GetFingertipPixelRadius(widget_container->GetWindow()) - LAYER_PADDING) * 2;
	int preferred_w = MAX(minimum_size, source->GetBounds().width);
	int preferred_h = MAX(MAX(minimum_size, source->GetBounds().height), dest_rect.height);
	minimum_size = GetElementExpander()->GetElementMinimumSize();
	if (preferred_w < minimum_size)
		preferred_w = minimum_size;
	if (preferred_h < minimum_size)
		preferred_h = minimum_size;

	clone->GetVisualDevice()->SetFont(font);
	clone->GetPreferedSize(&preferred_w, &preferred_h, cols, rows);
	clone->SetListener(this);

	OpRect visible_rect;
	GetElementExpander()->GetAvailableRect(visible_rect);

	// Limit size to screensize
	preferred_w = MIN(preferred_w, visible_rect.width - LAYER_PADDING * 2);
	preferred_h = MIN(preferred_h, visible_rect.height - LAYER_PADDING * 2);

	widget_a_frag->SetRect(OpRect(LAYER_PADDING, LAYER_PADDING, preferred_w, preferred_h), 0);

	// Calculate new dest_rect
	int total_w = 0;
	int total_h = preferred_h;
	int x = LAYER_PADDING;

	for (AnchorFragment* fragment = (AnchorFragment*) region.First(); fragment; fragment = fragment->Suc())
	{
		int y = preferred_h + LAYER_PADDING * 2 - fragment->GetHeight();
		TextAnchorFragment *text_anchor_frag = fragment->GetTextAnchorFragment();
		if (text_anchor_frag)
		{
			RETURN_IF_ERROR(text_anchor_frag->UpdateWidgetString(root, GetMaxWidth() - preferred_w, FALSE));
		}

		int frag_w = fragment->GetWidth();
		int frag_h = fragment->GetHeight();

		// Checkbox and radiobutton captions should not be too close to the image.
		if (text_anchor_frag)
		{
			switch (clone->GetType())
			{
				case OpTypedObject::WIDGET_TYPE_RADIOBUTTON:
				case OpTypedObject::WIDGET_TYPE_CHECKBOX:
					// TODO: Adapt this to RTL languages!
					y = (frag_h + LAYER_BG_PADDING * 2 - font.GetHeight() + (preferred_h - frag_h)) / 2;
					x += 5;
					frag_w += 5;
					break;
			}
		}

		fragment->SetPos(x, y);

		total_w += frag_w;
		total_h = MAX(total_h, frag_h);
		x += frag_w;
    }

	int y = LAYER_PADDING;
	switch (clone->GetType())
	{
		case OpTypedObject::WIDGET_TYPE_RADIOBUTTON:
		case OpTypedObject::WIDGET_TYPE_CHECKBOX:
			y = (total_h+2*LAYER_PADDING-preferred_h)/2;
			break;
	}

	clone->SetRect(OpRect(LAYER_PADDING, y, preferred_w, preferred_h));

	dest_rect.width = total_w;
	dest_rect.height = total_h;

	if (expanded)
	{
		dest_rect.width += LAYER_PADDING * 2;
		dest_rect.height += LAYER_PADDING * 2;
		ElementExpanderImpl::SmartPositionRectInRect(dest_rect, visible_rect,
													 ElementExpanderImpl::EDGE_NORTH,
													 ElementExpanderImpl::EDGE_WEST);
		AdjustSize();
		ScheduleAnimation(anim_start_rect, anim_start_opacity, dest_rect, 1.0f, 400);
	}
	else
	{
		AdjustSize();
	}

	return OpStatus::OK;
}
Пример #23
0
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;
}
Пример #24
0
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;
}
Пример #25
0
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;
}