Ejemplo n.º 1
0
void RainExceptionDialog::_addExtraControls()
{
  m_pSaveBtn = new wxButton(this, wxID_SAVE, wxT("Copy to Clipboard"));
  m_pStaticLine = new wxStaticLine(this, wxID_ANY);

  m_pDetailList = new wxListCtrl(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSUNKEN_BORDER | wxLC_REPORT | wxLC_SINGLE_SEL);

  m_pDetailList->InsertColumn(0, wxT("Message"));
  m_pDetailList->InsertColumn(1, wxT("File"));
  m_pDetailList->InsertColumn(2, wxT("Ln."));

  size_t count = m_aMessages.GetCount();
  for(size_t n = 0; n < count; ++n)
  {
    m_pDetailList->InsertItem(n, m_aMessages[n]);
    m_pDetailList->SetItem(n, 1, m_aFiles[n]);
    m_pDetailList->SetItem(n, 2, wxString::Format(wxT("%li"), m_aLines[n]));
  }

  m_pDetailList->SetColumnWidth(0, wxLIST_AUTOSIZE);
  m_pDetailList->SetColumnWidth(1, wxLIST_AUTOSIZE);
  m_pDetailList->SetColumnWidth(2, wxLIST_AUTOSIZE);

  int height = GetCharHeight()*(count + 4);
  int heightMax = wxGetDisplaySize().y - GetPosition().y - 2*GetMinHeight();

  heightMax *= 9;
  heightMax /= 10;

  m_pDetailList->SetSize(wxDefaultCoord, wxMin(height, heightMax));
}
Ejemplo n.º 2
0
int CTextBase::CoreRequestHeight()
{
    int min = std::max(1, GetMinHeight());
    
    if (!m_Lines.empty())
        min = std::max(min, SafeConvert<int>(m_Lines.size()));
    
    if (!m_QueuedText.empty())
    {
        int lines = 0;
        const int width = RequestWidth();
        TSTLStrSize start = 0, end, length = m_QueuedText.length();
        
        while (start < length)
        {
            end = GetNextLine(m_QueuedText, start, width);
            lines++;
            start = end + 1;
        }
        
        min = std::max(min, lines);
    }
    
    if ((m_iMaxReqHeight > 0) && (min > m_iMaxReqHeight))
        min = m_iMaxReqHeight;
    
    return min;
}
Ejemplo n.º 3
0
EditPathDlg::EditPathDlg(wxWindow* parent,
        const wxString& path,
        const wxString& basepath,
        const wxString& title,
        const wxString& message,
        const bool wantDir,
        const bool allowMultiSel,
        const wxString& filter)
{
    //ctor
    wxXmlResource::Get()->LoadObject(this, parent, _T("dlgEditPath"),_T("wxScrollingDialog"));

    XRCCTRL(*this, "txtPath", wxTextCtrl)->SetValue(path);
    XRCCTRL(*this, "dlgEditPath", wxScrollingDialog)->SetTitle(title);

    if (!wantDir) {
        XRCCTRL(*this, "lblText", wxStaticText)->SetLabel(_("File:"));
    }

    m_Path = path;
    m_WantDir = wantDir;
    m_AllowMultiSel = allowMultiSel;
    m_Message = message;
    m_Basepath = basepath;
    m_Filter = filter;
    m_AskMakeRelative = true;
    m_ShowCreateDirButton = false;
    XRCCTRL(*this, "txtPath", wxTextCtrl)->SetFocus();

    // Limit vertical resizing.
    SetMaxSize(wxSize(-1, GetMinHeight()));
}
Ejemplo n.º 4
0
CBlockUnit::CBlockUnit(UINT nType, UINT x, UINT y)
{
  // Setup initial data
  m_bSelected = FALSE;
  m_bError    = FALSE;
  m_pParent   = NULL;
  m_pDocument = NULL;
  m_lName     = 0;
  m_nType     = nType;
  m_pView     = NULL;
  m_pScope    = NULL;
  m_pEditor   = NULL;
  m_pProgram  = NULL;
  m_fPrevTime = 0;

  // Setup initial metrics
  m_rRect.X = x;
  m_rRect.Y = y;
  m_rRect.Width  = GetMinWidth();
  m_rRect.Height = GetMinHeight();

  // Setup editor metrics
  m_rEditor.X = CW_USEDEFAULT;
  m_rEditor.Y = CW_USEDEFAULT;
  m_rEditor.Width  = 640;
  m_rEditor.Height = 480;
  
  // Setup explorer metrics
  m_rScope.X = CW_USEDEFAULT;
  m_rScope.Y = CW_USEDEFAULT;
  m_rScope.Width  = 640;
  m_rScope.Height = 480;
}
Ejemplo n.º 5
0
bool wxMDIChildFrame::HandleGetMinMaxInfo(void *mmInfo)
{
    MINMAXINFO *info = (MINMAXINFO *)mmInfo;

    // let the default window proc calculate the size of MDI children
    // frames because it is based on the size of the MDI client window,
    // not on the values specified in wxWindow m_max variables
    bool processed = MSWDefWindowProc(WM_GETMINMAXINFO, 0, (LPARAM)mmInfo) != 0;

    int minWidth = GetMinWidth(),
        minHeight = GetMinHeight();

    // but allow GetSizeHints() to set the min size
    if ( minWidth != -1 )
    {
        info->ptMinTrackSize.x = minWidth;

        processed = true;
    }

    if ( minHeight != -1 )
    {
        info->ptMinTrackSize.y = minHeight;

        processed = true;
    }

    return processed;
}
Ejemplo n.º 6
0
int CBox::CoreRequestHeight()
{
    int ret = RequestedWidgetsH();
    
    if (HasBox())
        ret += 2;

    return std::max(ret, GetMinHeight());
}
Ejemplo n.º 7
0
void EBox::SetHeight(float height) {
	_hHint = height;
	_h = GetMinHeight();
	_w = GetMinWidth();

	if (IsCentered())
		SetBoxCenter(_center);
	UpdateChild();
}
Ejemplo n.º 8
0
void EBox::SetWidth(float width) {
	_wHint = width;
	_w = GetMinWidth();
	_h = GetMinHeight();

	if (IsCentered())
		SetBoxCenter(_center);
	UpdateChild();
}
Ejemplo n.º 9
0
void CPDFSDK_Annot::SetRect(const CPDF_Rect& rect)
{
	ASSERT(m_pAnnot != NULL);
	ASSERT(m_pAnnot->m_pAnnotDict != NULL);
	ASSERT(rect.right - rect.left >= GetMinWidth());
	ASSERT(rect.top - rect.bottom >= GetMinHeight());
	
	m_pAnnot->m_pAnnotDict->SetAtRect("Rect", rect);
}
int CWindowManager::CoreRequestHeight()
{
    const TChildList &childs = GetChildList();
    int ret = GetMinHeight();
    
    for (TChildList::const_iterator it=childs.begin(); it!=childs.end(); it++)
    {
        if ((*it)->Enabled())
            ret = std::max(ret, (*it)->RequestHeight());
    }
    
    return ret;
}
Ejemplo n.º 11
0
int CMenu::CoreRequestHeight()
{
    int ret = std::max(GetMinHeight(), 1);
    
    ret = std::max(ret, SafeConvert<int>(m_MenuList.size()));
    
    ret += 2; // Surrounding box
    
    if (ret > m_iMaxHeight)
        ret = m_iMaxHeight;

    return ret;
}
Ejemplo n.º 12
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 CXTPDockingPaneSidePanel::MovePanel(LENGTH* pLength, CRect rect)
{
	m_bInRecalcLayout = TRUE;

	if (m_bCollapsed && m_bSlideOut)
	{
		m_bSlideOut = FALSE;
		m_bExpanded = FALSE;
		m_nSlideStep = 0;
		KillTimer(TID_SLIDEOUT);
		OnAction(xtpPaneActionCollapsed);
	}

	BOOL bHorizontal = IsHorizontal();
	CSize sz = bHorizontal ? CSize(pLength->nSize, pLength->nHeight) : CSize(pLength->nHeight, pLength->nSize);

	int nMinHeight = GetMinHeight();

	if (m_bCollapsed && !m_bExpanded)
	{
		if (bHorizontal) sz.cy = nMinHeight; else sz.cx = nMinHeight;
	}
	else
	{
		if (bHorizontal) sz.cy = max(sz.cy, nMinHeight); else sz.cx = max(sz.cx, nMinHeight);
	}

	CPoint pt;

	switch (m_direction)
	{
	case xtpPaneDockLeft: pt = CPoint(rect.left, pLength->nPos + rect.top); break;
	case xtpPaneDockTop: pt = CPoint(rect.left + pLength->nPos, rect.top); break;
	case xtpPaneDockRight: pt = CPoint(rect.right - sz.cx, rect.top + pLength->nPos); break;
	case xtpPaneDockBottom: pt = CPoint(rect.left + pLength->nPos, rect.bottom - sz.cy); break;
	}

	SetWindowPos(&CWnd::wndTop, pt.x, pt.y, sz.cx, sz.cy, SWP_NOOWNERZORDER | SWP_SHOWWINDOW);

	CRect rcClient;
	GetClientRect(rcClient);

	GetPaintManager()->AdjustClientRect(this, rcClient);

	CXTPDockingPaneTabbedContainer* pContainer = GetTopContainer();
	if (pContainer)
	{
		pContainer->OnSizeParent(this, rcClient, NULL);
	}
	m_bInRecalcLayout = FALSE;
}
Ejemplo n.º 14
0
/////////////////////////////////////////////////////////////////////////////
// Prepare "m_bitmaps[???]" for all possible states
//
//   HDC     hDC - DC used to create memory DCs for bitmap preparation
//
//          HBITMAP &bmpDest - this parameter is one of the following:
//                m_bitmaps[ 0 ] : BOX_ON  bitmap
//                m_bitmaps[ 1 ] : BOX_OFF bitmap
//                ...
//                m_bitmaps[ 5 ] : BOX_DISABLED_2 bitmap
//
//          int nState - specifies the state of the CB and can be:
//             BOX_ON
//             BOX_OFF
//             BOX_LDOWN_1
//             BOX_LDOWN_2
//             BOX_DISABLED_1
//             BOX_DISABLED_2
/////////////////////////////////////////////////////////////////////////////
void
ZCheckBox::PrepareBitmaps( HDC hDC )
{
   m_nHeight = GetMinHeight( hDC );
   if ( m_nHeight < BOX_SIZE )
      m_nHeight = BOX_SIZE;

   PrepareState( hDC, m_bitmaps[ 0 ], BOX_ON );
   PrepareState( hDC, m_bitmaps[ 1 ], BOX_OFF );
   PrepareState( hDC, m_bitmaps[ 2 ], BOX_LDOWN_1 );
   PrepareState( hDC, m_bitmaps[ 3 ], BOX_LDOWN_2 );
   PrepareState( hDC, m_bitmaps[ 4 ], BOX_DISABLED_1 );
   PrepareState( hDC, m_bitmaps[ 5 ], BOX_DISABLED_2 );
}
Ejemplo n.º 15
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
}
Ejemplo n.º 16
0
EditBreakpointDlg::EditBreakpointDlg(const DebuggerBreakpoint &breakpoint, wxWindow* parent)
    : m_breakpoint(breakpoint)
{
    //ctor
    wxXmlResource::Get()->LoadObject(this, parent, _T("dlgEditBreakpoint"),_T("wxScrollingDialog"));

    XRCCTRL(*this, "chkEnabled", wxCheckBox)->SetValue(m_breakpoint.enabled);
    XRCCTRL(*this, "chkIgnore", wxCheckBox)->SetValue(m_breakpoint.useIgnoreCount);
    XRCCTRL(*this, "spnIgnoreCount", wxSpinCtrl)->SetValue(m_breakpoint.ignoreCount);
    XRCCTRL(*this, "chkExpr", wxCheckBox)->SetValue(m_breakpoint.useCondition);
    XRCCTRL(*this, "txtExpr", wxTextCtrl)->SetValue(m_breakpoint.condition);

    // Limit vertical resizing.
    SetMaxSize(wxSize(-1, GetMinHeight()));
}
Ejemplo n.º 17
0
void CBlockUnit::SizeBlock(UINT x, UINT y)
{
  UINT nMinWidth  = GetMinWidth();
  UINT nMinHeight = GetMinHeight();

  // Different policy for I/O ports
  if ((m_nType == T_INPUT) || (m_nType == T_OUTPUT))
  {
    // Assign values
    m_rRect.Width  = x - m_rRect.X;
    m_rRect.Height = 20;
  }
  else
  {
    m_rRect.Width  = x - m_rRect.X;
    m_rRect.Height = y - m_rRect.Y;
  }
}
Ejemplo n.º 18
0
BoatDialog::BoatDialog(WeatherRouting &weatherrouting)
    : BoatDialogBase(&weatherrouting),
      m_WeatherRouting(weatherrouting), m_PlotScale(0), m_CrossOverRegenerate(false), m_CrossOverGenerationThread(NULL)
{
    // for small screens: don't let boat dialog be larger than screen
    int w,h;
    wxDisplaySize( &w, &h );
    w = wxMin(w, GetMinWidth());
    h = wxMin(h-32, GetMinHeight());
    SetMinSize(wxSize(w, h));
    SetSize(wxSize(w, h));

    m_lPolars->InsertColumn(spFILENAME, _("Filename"));

    wxFileConfig *pConf = GetOCPNConfigObject();
    pConf->SetPath ( _T( "/PlugIns/WeatherRouting/BoatDialog" ) );

    m_orientation[0] = pConf->Read ( _T ( "Orientation0" ), 1L );
    m_orientation[1] = pConf->Read ( _T ( "Orientation1" ), 1L );

    // hack to adjust items
    SetSize(wxSize(w, h));
}
void CXTPDockingPaneSidePanel::DoSlideStep(BOOL bActivate)
{
	m_bInRecalcLayout = TRUE;

	int nMinHeight = GetMinHeight();
	BOOL bHorizontal = IsHorizontal();

	CXTPWindowRect rc(this);
	int nSize = max(nMinHeight, m_nSlideStep * ( bHorizontal ? m_rcWindow.Height() : m_rcWindow.Width()) / m_nStepsCount);

	switch (m_direction)
	{
		case xtpPaneDockLeft: rc.right = rc.left + nSize; break;
		case xtpPaneDockTop: rc.bottom = rc.top + nSize; break;
		case xtpPaneDockRight: rc.left = rc.right - nSize; break;
		case xtpPaneDockBottom: rc.top = rc.bottom - nSize; break;
	}

	GetParent()->ScreenToClient(rc);

	SetWindowPos(&CWnd::wndTop, rc.left, rc.top, rc.Width(), rc.Height(), (!bActivate ? SWP_NOZORDER | SWP_NOACTIVATE : SWP_NOACTIVATE));
	Invalidate(FALSE);

	CRect rcClient;
	GetClientRect(rcClient);

	GetPaintManager()->AdjustClientRect(this, rcClient);

	CXTPDockingPaneTabbedContainer* pContainer = GetTopContainer();
	if (pContainer)
	{
		pContainer->OnSizeParent(this, rcClient, NULL);
	}


	m_bInRecalcLayout = FALSE;
}
Ejemplo n.º 20
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;
}
Ejemplo n.º 21
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;
}
Ejemplo n.º 22
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);
    }
}
Ejemplo n.º 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;
}
Ejemplo n.º 24
0
	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);
	}
Ejemplo n.º 25
0
int IconPanel::GetMaxHeight() {
  int minHeight = GetMinHeight();
  if (maxHeight_ < minHeight) return minHeight;
  return maxHeight_;
}
Ejemplo n.º 26
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;
}
Ejemplo n.º 27
0
pxStaticText &pxStaticText::SetMinWidth(int width)
{
    SetMinSize(wxSize(width, GetMinHeight()));
    return *this;
}
Ejemplo n.º 28
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;
}
Ejemplo n.º 29
0
void CBlockUnit::DrawBlock(Graphics *pGraph)
{
  Pen pen(Color(0, 0, 0));
  Font fontBold(L"Tahoma", 10, FontStyleBold);
  Font fontNormal(L"Tahoma", 10, FontStyleRegular);
  SolidBrush brush(Color(0, 0, 0));

  // Check & update block size
  UINT nMinWidth  = GetMinWidth();
  UINT nMinHeight = GetMinHeight();
  if ((INT)m_rRect.Width < (INT)nMinWidth)
  {
    m_rRect.Width = ROUND(nMinWidth);
  }
  if ((INT)m_rRect.Height < (INT)nMinHeight)
  {
    m_rRect.Height = ROUND(nMinHeight);
  }

  // select color according to type
  switch (m_nType)
  {
    case T_FUNCTION:
      {
        brush.SetColor(Color(220, 220, 255));
      }
      break;
    case T_SUBSYSTEM:
      {
        brush.SetColor(Color(255, 220, 220));
      }
      break;
    case T_TEXTBOX:
      {
        brush.SetColor(Color(255, 255, 230));
      }
      break;
    case T_INPUT:
      {
        brush.SetColor(Color(255, 255, 220));
      }
      break;
    case T_OUTPUT:
      {
        brush.SetColor(Color(255, 255, 220));
      }
      break;
    default:
      {
        ASSERT(TRUE);
      }
  }

  // Mark selected
  if (m_bSelected)
  {
    pen.SetWidth(2);
  }

  // Outline error connections
  if (m_bError)
  {
    pen.SetColor(Color(255, 100, 100));
  }
  else
  {
    pen.SetColor(Color(0, 0, 0));
  }

  // Draw rectangle body
  pGraph->FillRectangle(&brush, m_rRect);
  pGraph->DrawRectangle(&pen, m_rRect);

  if ((m_nType != T_INPUT) && (m_nType != T_OUTPUT))
  {
    pen.SetWidth(1);
    brush.SetColor(Color(0, 0, 0));
    RectF rect, rectSize;
    StringFormat format;

    // Write title string
    if (m_nType == T_TEXTBOX)
    {
      rect = RectF(m_rRect.X, m_rRect.Y, m_rRect.Width, m_rRect.Height);
      wstring ws(m_sName.begin(), m_sName.end());
      pGraph->DrawString(ws.c_str(), -1, &fontNormal, rect, &format, &brush);

      // Measure title text width
      rect.Width = 0;
      pGraph->MeasureString(ws.c_str(), -1, &fontNormal, rect, &format,
          &rectSize);
      m_lName = (INT)rectSize.Width;
    }
    else
    {
      // Draw title line
      pGraph->DrawLine(&pen, m_rRect.X, m_rRect.Y+20, m_rRect.GetRight(),
          m_rRect.Y+20);

      format.SetAlignment(StringAlignmentCenter);
      format.SetLineAlignment(StringAlignmentCenter);
      rect = RectF(m_rRect.X, m_rRect.Y, m_rRect.Width, 20);
      wstring ws(m_sName.begin(), m_sName.end());
      pGraph->DrawString(ws.c_str(), -1, &fontBold, rect, &format, &brush);

      // Measure title text width
      rect.Width = 0;
      pGraph->MeasureString(ws.c_str(), -1, &fontBold, rect, &format,
          &rectSize);
      m_lName = (INT)rectSize.Width;
    }
  }

  // Draw input variables
  Point ptInput(m_rRect.X, m_rRect.GetTop() + 10);
  if ((m_nType != T_INPUT) && (m_nType != T_OUTPUT))
  {
    ptInput.Y += 20;
  }
  for (int i=0; i<m_vInput.size(); i++)
  {
    // Skip if input port
    if (m_nType == T_INPUT)
    {
      break;
    }

    // Draw port
    m_vInput[i]->DrawIOPort(pGraph, ptInput.X, ptInput.Y);
    ptInput.Y += 20;

    // Only draw one if I/O ports
    if (m_nType == T_OUTPUT)
    {
      break;
    }
  }

  // Draw output variables
  Point ptOutput(m_rRect.GetRight(), m_rRect.Y + 10);
  if ((m_nType != T_INPUT) && (m_nType != T_OUTPUT))
  {
    ptOutput.Y += 20;
  }
  for (int i=0; i<m_vOutput.size(); i++)
  {
    // Skip if output port
    if (m_nType == T_OUTPUT)
    {
      break;
    }

    // Draw port
    m_vOutput[i]->DrawIOPort(pGraph, ptOutput.X, ptOutput.Y);
    ptOutput.Y += 20;

    // Only draw one if I/O ports
    if (m_nType == T_INPUT)
    {
      break;
    }
  }
}
Ejemplo n.º 30
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;
}