コード例 #1
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 wxWindowPalm::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);

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

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

    AdjustForParentClientOrigin(x, y, sizeFlags);

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

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

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

    DoMoveWindow(x, y, width, height);
}
コード例 #2
0
wxSize wxSheetCellStringRendererRefData::GetBestSize(wxSheet& sheet,
        const wxSheetCellAttr& attr,
        wxDC& dc,
        const wxSheetCoords& coords)
{
    return DoGetBestSize(sheet, attr, dc, GetString(sheet, coords));
}
コード例 #3
0
ファイル: bar.cpp プロジェクト: Kaoswerk/newton-dynamics
void wxRibbonBar::ShowPanels(bool show)
{
    m_arePanelsShown = show;
    SetMinSize(wxSize(GetSize().GetWidth(), DoGetBestSize().GetHeight()));
    Realise();
    GetParent()->Layout();
}
コード例 #4
0
ファイル: wxappbar.cpp プロジェクト: rkvsraman/eviacam
void WXAppBar::UnSetDockedModeStep2()
{
	Display *dd= (Display *) wxGetDisplay();

	// Window X11 handle
	GtkWidget *gtkWidget= (GtkWidget *) this->GetHandle();
	Window w= GDK_WINDOW_XWINDOW (gtkWidget->window);
	
	Refresh();
	Update();
	
	//
	// Set window style back to normal again
	//
	Atom atomTmp= XInternAtom (dd, "_NET_WM_WINDOW_TYPE", False);
	Atom atom_NET_WM_WINDOW_TYPE_NORMAL= XInternAtom (dd, "_NET_WM_WINDOW_TYPE_NORMAL", False);
	unsigned long propInfo= atom_NET_WM_WINDOW_TYPE_NORMAL;
	XChangeProperty (dd, w, atomTmp, XA_ATOM, 32, PropModeReplace, (unsigned char *) &propInfo, 1);
	XSync(dd, False);
	
	// The code above disables the sticky property, so we enable it again
	SetSticky(true);
	
	// Restore decorations when needed
	SetBorderDecorations(m_dialogHadBorderDecorations);
	
	// Restore original size
	wxSize proposedSize= DoGetBestSize();
	//SetSize (0, 0, proposedSize.GetWidth(), proposedSize.GetHeight());
	SetSize (proposedSize.GetWidth(), proposedSize.GetHeight());
}
コード例 #5
0
ファイル: button.cpp プロジェクト: hgwells/tive
wxSize wxButton::GetMinSize() const
{
    if( wxMotifLargeButtons() )
        return OldGetMinSize();

    return DoGetBestSize();
}
コード例 #6
0
ファイル: spinbutt.cpp プロジェクト: krossell/wxWidgets
void wxSpinButton::OnSize( wxSizeEvent &WXUNUSED(event) )
{
    wxCHECK_RET( (m_widget != NULL), wxT("invalid spin button") );

    m_width = DoGetBestSize().x;
    gtk_widget_set_size_request( m_widget, m_width, m_height );
}
コード例 #7
0
ファイル: menubtn.cpp プロジェクト: erelh/gpac
void wxCustomButton::SetMargins(const wxSize &margin, bool fit)
{
    m_labelMargin = margin;
    m_bitmapMargin = margin;
    CalcLayout(TRUE);
    if (fit) SetSize(DoGetBestSize());
}
コード例 #8
0
ファイル: gridctrl.cpp プロジェクト: 3v1n0/wxWidgets
wxSize wxGridCellStringRenderer::GetBestSize(wxGrid& grid,
                                             wxGridCellAttr& attr,
                                             wxDC& dc,
                                             int row, int col)
{
    return DoGetBestSize(attr, dc, grid.GetCellValue(row, col));
}
コード例 #9
0
ファイル: combobox.cpp プロジェクト: EdgarTx/wx
void wxComboBox::DoSetSize(int x, int y,
                           int width, int WXUNUSED(height),
                           int sizeFlags)
{
    // Necessary so it doesn't call wxChoice::SetSize
    wxWindow::DoSetSize(x, y, width, DoGetBestSize().y, sizeFlags);
}
コード例 #10
0
ファイル: menubtn.cpp プロジェクト: erelh/gpac
bool wxMenuButton::Create( wxWindow* parent, wxWindowID id,
                           const wxString &label,
                           const wxBitmap &bitmap,
                           const wxPoint& pos,
                           const wxSize& size,
                           long style,
                           const wxValidator& val,
                           const wxString& name)
{
    m_style = style;

    long flat = style & wxMENUBUT_FLAT;

    wxControl::Create(parent,id,pos,size,wxNO_BORDER|wxCLIP_CHILDREN,val,name);
    wxControl::SetLabel(label);
    SetBackgroundColour(parent->GetBackgroundColour());
    SetForegroundColour(parent->GetForegroundColour());
    SetFont(parent->GetFont());

    m_labelButton = new MenuLabelButton(this, id, label, bitmap, wxCUSTBUT_BUTTON|flat);
    m_dropdownButton = new MenuDropButton(this, IDD_DROPDOWN_BUTTON, wxCUSTBUT_BUTTON|flat);

    wxSize bestSize = DoGetBestSize();
    SetSize( wxSize(size.x < 0 ? bestSize.x : size.x,
                    size.y < 0 ? bestSize.y : size.y) );

#if (wxMINOR_VERSION<8)
    SetBestSize(GetSize());
#else
    SetInitialSize(GetSize());
#endif

    return TRUE;
}
コード例 #11
0
ファイル: menubtn.cpp プロジェクト: erelh/gpac
bool wxCustomButton::Create(wxWindow* parent, wxWindowID id,
                            const wxString& label, const wxBitmap &bitmap,
                            const wxPoint& pos, const wxSize& size,
                            long style, const wxValidator& val,
                            const wxString& name)
{
    if (!wxControl::Create(parent,id,pos,size,wxNO_BORDER|wxCLIP_CHILDREN,val,name))
        return FALSE;

    wxControl::SetLabel(label);
    wxControl::SetBackgroundColour(parent->GetBackgroundColour());
    wxControl::SetForegroundColour(parent->GetForegroundColour());
    wxControl::SetFont(parent->GetFont());

    if (bitmap.Ok()) m_bmpLabel = bitmap;

    if (!SetButtonStyle(style)) return FALSE;

    wxSize bestSize = DoGetBestSize();
    SetSize(wxSize(size.x<0 ? bestSize.x:size.x, size.y<0 ? bestSize.y:size.y));
#if (wxMINOR_VERSION<8)
    SetBestSize(GetSize());
#else
    SetInitialSize(GetSize());
#endif

    CalcLayout(TRUE);
    return TRUE;
}
コード例 #12
0
ファイル: gridctrl.cpp プロジェクト: 3v1n0/wxWidgets
wxSize wxGridCellFloatRenderer::GetBestSize(wxGrid& grid,
                                            wxGridCellAttr& attr,
                                            wxDC& dc,
                                            int row, int col)
{
    return DoGetBestSize(attr, dc, GetString(grid, row, col));
}
コード例 #13
0
ファイル: wxappbar.cpp プロジェクト: rkvsraman/eviacam
void WXAppBar::SetDockedModeStep1()
{
	// TODO: manage different docking locations on windows
	APPBARDATA abd;		

	// Set metrics (TOP location only)
	wxSize proposedSize= DoGetBestSize();
	m_X= 0;
	m_Y= 0;
	m_Width= GetSystemMetrics(SM_CXSCREEN);
	m_Height= proposedSize.GetHeight();	

	// Register appbar
	abd.cbSize= sizeof(APPBARDATA);
	abd.hWnd= (HWND) GetHandle();
	abd.uCallbackMessage= 12345; //WX_APPBAR_CALLBACK; // TODO: respond to these callback messages
	SHAppBarMessage (ABM_NEW, &abd);

	// Set size
	abd.uEdge= ABE_TOP;
	abd.rc.left = m_X;
	abd.rc.top = m_Y;
	abd.rc.right = m_X + m_Width;
	abd.rc.bottom = m_Y + m_Height;

	SHAppBarMessage(ABM_QUERYPOS,&abd);	// Correct size if needed

	m_X= abd.rc.left;
	m_Y= abd.rc.top;		
	m_Width= abd.rc.right - m_X;
	// Re-calculate bottom corner
	abd.rc.bottom = m_Y + m_Height;		
	SHAppBarMessage(ABM_SETPOS, &abd);
}
コード例 #14
0
ファイル: wxledpanel.cpp プロジェクト: DowerChest/codeblocks
/** Prepares the backgroundimage, to optimze speed */
void wxLEDPanel::PrepareBackground()
{
    wxSize s=DoGetBestSize();
    wxBitmap bmpBG(s.GetWidth(),s.GetHeight());

    m_mdc_background.SelectObject(bmpBG);

    // clear the background
    m_mdc_background.SetBackground(this->GetBackgroundColour());
    m_mdc_background.Clear();

    if(m_invert || m_show_inactivs)
        DrawField(m_mdc_background, true);
}
コード例 #15
0
void tpanel_item::NotifySizeChange() {
	wxSize clientsize = parent->GetClientSize();
	SetMinSize(wxSize(clientsize.x, 1));
	SetMaxSize(wxSize(clientsize.x, 100000));
	wxSize bestsize = DoGetBestSize();
	SetSize(clientsize.x, bestsize.y);

	if (!parent->resize_update_pending) {
		parent->resize_update_pending = true;
		parent->Freeze();
		wxCommandEvent event(wxextRESIZE_UPDATE_EVENT, GetId());
		parent->GetEventHandler()->AddPendingEvent(event);
	}
}
コード例 #16
0
ファイル: spinbutt.cpp プロジェクト: EEmmanuel7/wxWidgets
bool wxSpinButton::Create(wxWindow *parent,
                          wxWindowID id,
                          const wxPoint& pos,
                          const wxSize& size,
                          long style,
                          const wxString& name)
{
    m_needParent = true;

    wxSize new_size = size,
           sizeBest = DoGetBestSize();
    new_size.x = sizeBest.x;            // override width always
    if (new_size.y == -1)
        new_size.y = sizeBest.y;

    if (!PreCreation( parent, pos, new_size ) ||
        !CreateBase( parent, id, pos, new_size, style, wxDefaultValidator, name ))
    {
        wxFAIL_MSG( wxT("wxXX creation failed") );
        return false;
    }

    m_oldPos = 0.0;

    m_adjust = (GtkAdjustment*) gtk_adjustment_new( 0.0, 0.0, 100.0, 1.0, 5.0, 0.0);

    m_widget = gtk_spin_button_new( m_adjust, 0, 0 );

    gtk_spin_button_set_wrap( GTK_SPIN_BUTTON(m_widget),
                              (int)(m_windowStyle & wxSP_WRAP) );

    gtk_signal_connect( GTK_OBJECT (m_adjust),
                        "value_changed",
                        (GtkSignalFunc) gtk_spinbutt_callback,
                        (gpointer) this );

    m_parent->DoAddChild( this );

    PostCreation(new_size);

    return true;
}
コード例 #17
0
ファイル: statusbr.cpp プロジェクト: czxxjtu/wxPython-1
bool wxStatusBarUniv::Create(wxWindow *parent,
                             wxWindowID id,
                             long style,
                             const wxString& name)
{
    if ( !wxWindow::Create(parent, id,
                           wxDefaultPosition, wxDefaultSize,
                           style, name) )
    {
        return false;
    }

    SetFieldsCount(1);

    CreateInputHandler(wxINP_HANDLER_STATUSBAR);

    SetSize(DoGetBestSize());

    return true;
}
コード例 #18
0
ファイル: bar.cpp プロジェクト: AaronDP/wxWidgets
void wxRibbonBar::ShowPanels(wxRibbonDisplayMode mode)
{
    switch ( mode )
    {
        case wxRIBBON_BAR_PINNED:
        case wxRIBBON_BAR_EXPANDED:
            m_arePanelsShown = true;
            break;

        case wxRIBBON_BAR_MINIMIZED:
            m_arePanelsShown = false;
            break;
    }

    SetMinSize(wxSize(GetSize().GetWidth(), DoGetBestSize().GetHeight()));
    Realise();
    GetParent()->Layout();

    m_ribbon_state = mode;
}
コード例 #19
0
ファイル: bmpcombo.cpp プロジェクト: Kangar0o/gambit
bool wxBitmapComboBox::Create( wxWindow* parent, wxWindowID id,
                               const wxPoint& pos, const wxSize& size,
                               long style, const wxValidator& val,
                               const wxString& name)
{
    if (!DropDownBase::Create(parent,id,pos,size,wxNO_BORDER|wxCLIP_CHILDREN,val,name))
        return false;

    m_labelWin = new wxBitmapComboLabel(this);
    m_win_border = m_labelWin->GetSize().x - m_labelWin->GetClientSize().x;

    SetBackgroundColour(*wxWHITE);

    m_frozen = false;
    CalcLayout();

    wxSize bestSize = DoGetBestSize();
    SetSize( wxSize(size.x < 0 ? bestSize.x : size.x,
                    size.y < 0 ? bestSize.y : size.y) );

    return SetButtonStyle(style);
}
コード例 #20
0
ファイル: menubtn.cpp プロジェクト: erelh/gpac
void wxMenuButton::DoSetSize(int x, int y, int width, int height, int sizeFlags)
{
    wxSize curSize( GetSize() );
    wxSize bestSize( DoGetBestSize() );

    if (width == -1)
        width = curSize.GetWidth();
    if (width < 10)
        width = bestSize.GetWidth();

    if (height == -1)
        height = curSize.GetHeight();
    if (height < 5)
        height = bestSize.GetHeight();

    wxWindow::DoSetSize(x, y, width, height, sizeFlags);

    if (m_labelButton)
        m_labelButton->SetSize(0, 0, width - wxMENUBUTTON_DROP_WIDTH, height);
    if (m_dropdownButton)
        m_dropdownButton->SetSize(width-wxMENUBUTTON_DROP_WIDTH, 0, wxMENUBUTTON_DROP_WIDTH, height);
}
コード例 #21
0
ファイル: spinbutt.cpp プロジェクト: Bluehorn/wxPython
bool wxSpinButton::Create(wxWindow *parent,
                          wxWindowID id,
                          const wxPoint& pos,
                          const wxSize& size,
                          long style,
                          const wxString& name)
{
    m_needParent = true;

    wxSize new_size = size,
           sizeBest = DoGetBestSize();
    new_size.x = sizeBest.x;            // override width always
    if (new_size.y == -1)
        new_size.y = sizeBest.y;

    if (!PreCreation( parent, pos, new_size ) ||
        !CreateBase( parent, id, pos, new_size, style, wxDefaultValidator, name ))
    {
        wxFAIL_MSG( wxT("wxSpinButton creation failed") );
        return false;
    }

    m_pos = 0;

    m_widget = gtk_spin_button_new_with_range(0, 100, 1);

    gtk_spin_button_set_wrap( GTK_SPIN_BUTTON(m_widget),
                              (int)(m_windowStyle & wxSP_WRAP) );

    g_signal_connect_after(
        m_widget, "value_changed", G_CALLBACK(gtk_value_changed), this);

    m_parent->DoAddChild( this );

    PostCreation(new_size);

    return true;
}
コード例 #22
0
ファイル: bmpbuttn.cpp プロジェクト: gitrider/wxsj2
bool wxBitmapButton::Create(wxWindow *parent, wxWindowID id, const wxBitmap& bitmap,
           const wxPoint& pos,
           const wxSize& size, long style,
           const wxValidator& validator,
           const wxString& name)
{
    // since bitmapbuttonbase is subclass of button calling wxBitmapButtonBase::Create
    // essentially creates an additional button
    if ( !wxControl::Create(parent, id, pos, size,
                                     style, validator, name) )
        return false;

    m_bmpNormal = bitmap;
 
    if (style & wxBU_AUTODRAW)
    {
        m_marginX = wxDEFAULT_BUTTON_MARGIN;
        m_marginY = wxDEFAULT_BUTTON_MARGIN;
    }
    else
    {
        m_marginX = 0;
        m_marginY = 0;
    }

    int width = size.x;
    int height = size.y;

    if ( bitmap.Ok() )
    {
        wxSize newSize = DoGetBestSize();
        if ( width == -1 )
            width = newSize.x;
        if ( height == -1 )
            height = newSize.y;
    }

    Rect bounds ;
    Str255 title ;
    m_bmpNormal = bitmap;
    wxBitmapRefData * bmap = NULL ;
    
    if ( m_bmpNormal.Ok() )
        bmap = (wxBitmapRefData*) ( m_bmpNormal.GetRefData()) ;
    
    MacPreControlCreate( parent , id ,  wxEmptyString , pos , wxSize( width , height ) ,style, validator , name , &bounds , title ) ;

    m_macControl = (WXWidget) ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , title , false , 0 , 
        kControlBehaviorOffsetContents + 
            ( bmap && bmap->m_bitmapType == kMacBitmapTypeIcon ? 
            kControlContentCIconHandle : kControlContentPictHandle ) , 0, 
          (( style & wxBU_AUTODRAW ) ? kControlBevelButtonSmallBevelProc : kControlBevelButtonNormalBevelProc ), (long) this ) ;
    wxASSERT_MSG( (ControlHandle) m_macControl != NULL , wxT("No valid mac control") ) ;
    
    ControlButtonContentInfo info ;
    wxMacCreateBitmapButton( &info , m_bmpNormal ) ;
    if ( info.contentType != kControlNoContent )
    {
        ::SetControlData( (ControlHandle) m_macControl , kControlButtonPart , kControlBevelButtonContentTag , sizeof(info) , (char*) &info ) ;
    }
    MacPostControlCreate() ;

    return TRUE;
}
コード例 #23
0
ファイル: control.cpp プロジェクト: Duion/Torsion
void wxControl::MacPostControlCreate()
{
    wxASSERT_MSG( (ControlHandle) m_macControl != NULL , wxT("No valid mac control") ) ;
    DoSetWindowVariant( m_windowVariant ) ;
   /* 
    if ( IsKindOf( CLASSINFO( wxScrollBar ) ) )
    {
        // no font
    }
    else if ( !UMAHasAquaLayout() && (IsKindOf( CLASSINFO( wxStaticBox ) ) || IsKindOf( CLASSINFO( wxRadioBox ) ) || IsKindOf( CLASSINFO( wxButton ) ) ) )
    {
        ControlFontStyleRec     controlstyle ;
        controlstyle.flags = kControlUseFontMask ;
        controlstyle.font = kControlFontSmallBoldSystemFont ;
        
        ::SetControlFontStyle( (ControlHandle) m_macControl , &controlstyle ) ;
    }
    else
    {
        ControlFontStyleRec     controlstyle ;
        controlstyle.flags = kControlUseFontMask ;
        
        if (IsKindOf( CLASSINFO( wxButton ) ) )
            controlstyle.font = kControlFontBigSystemFont ; // eventually kControlFontBigSystemFont ;
        else
            controlstyle.font = kControlFontSmallSystemFont ;
        
        ::SetControlFontStyle( (ControlHandle) m_macControl , &controlstyle ) ;
    }
    */
    ControlHandle container = (ControlHandle) GetParent()->MacGetContainerForEmbedding() ;
    wxASSERT_MSG( container != NULL , wxT("No valid mac container control") ) ;
    ::EmbedControl( (ControlHandle) m_macControl , container ) ;
    m_macControlIsShown  = MacIsReallyShown() ;

    wxAssociateControlWithMacControl( (ControlHandle) m_macControl , this ) ;
    if ( wxMacSetupControlBackgroundUPP == NULL )
    {
        wxMacSetupControlBackgroundUPP = NewControlColorUPP( wxMacSetupControlBackground ) ;
    }
    if ( wxMacControlActionUPP == NULL )
    {
        wxMacControlActionUPP = NewControlDefUPP( wxMacControlDefinition ) ;
    }
    // The following block of code is responsible for crashes when switching
    // back to windows, which can be seen in the dialogs sample.
    // It is disabled until a proper solution can be found.
#if 0
#if TARGET_CARBON
/*
    only working under classic carbon
    m_macControlAction = *(**(ControlHandle)m_macControl).contrlDefProc ;
    (**(ControlHandle)m_macControl).contrlDefProc = (Handle) &wxMacControlActionUPP ;
*/
#else
    m_macControlAction = *(**(ControlHandle)m_macControl).contrlDefProc ;

    cdefHandle cdef ;
    cdef = (cdefHandle) NewHandle( sizeof(cdefRec) ) ;
    if (  (**(ControlHandle)m_macControl).contrlDefProc != NULL )
    {
        (**cdef).instruction = 0x4EF9;  /* JMP instruction */
        (**cdef).function = (void(*)()) wxMacControlActionUPP;
        (**(ControlHandle)m_macControl).contrlDefProc = (Handle) cdef ;
    }
#endif
#endif
    SetControlColorProc( (ControlHandle) m_macControl , wxMacSetupControlBackgroundUPP ) ;
    
    // Adjust the controls size and position
    wxPoint pos(m_x, m_y);
    wxSize best_size( DoGetBestSize() );
    wxSize new_size( m_width, m_height );
    
    m_x = m_y = m_width = m_height = -1;  // Forces SetSize to move/size the control
    
    if (new_size.x == -1) {
        new_size.x = best_size.x;
    }
    if (new_size.y == -1) {
        new_size.y = best_size.y;
    }
    
    SetSize(pos.x, pos.y, new_size.x, new_size.y);
    
#if wxUSE_UNICODE
    UMASetControlTitle( (ControlHandle) m_macControl , wxStripMenuCodes(m_label) , m_font.GetEncoding() ) ;
#endif

    if ( m_macControlIsShown )
        UMAShowControl( (ControlHandle) m_macControl ) ;
    
    SetCursor( *wxSTANDARD_CURSOR ) ;
    
    Refresh() ;
}
コード例 #24
0
ファイル: spinbutt.cpp プロジェクト: AlexHayton/decoda
bool wxSpinButton::Create(wxWindow *parent,
                          wxWindowID id,
                          const wxPoint& pos,
                          const wxSize& size,
                          long style,
                          const wxString& name)
{
    // basic initialization
    m_windowId = (id == wxID_ANY) ? NewControlId() : id;

    SetName(name);

    int x = pos.x;
    int y = pos.y;
    int width = size.x;
    int height = size.y;

    m_windowStyle = style;

    SetParent(parent);

    // get the right size for the control
    if ( width <= 0 || height <= 0 )
    {
        wxSize size = DoGetBestSize();
        if ( width <= 0 )
            width = size.x;
        if ( height <= 0 )
            height = size.y;
    }

    if ( x < 0 )
        x = 0;
    if ( y < 0 )
        y = 0;

    // translate the styles
    DWORD wstyle = WS_VISIBLE | WS_CHILD | WS_TABSTOP | /*  WS_CLIPSIBLINGS | */
                   UDS_NOTHOUSANDS | // never useful, sometimes harmful
                   UDS_SETBUDDYINT;  // it doesn't harm if we don't have buddy

    if ( m_windowStyle & wxCLIP_SIBLINGS )
        wstyle |= WS_CLIPSIBLINGS;
    if ( m_windowStyle & wxSP_HORIZONTAL )
        wstyle |= UDS_HORZ;
    if ( m_windowStyle & wxSP_ARROW_KEYS )
        wstyle |= UDS_ARROWKEYS;
    if ( m_windowStyle & wxSP_WRAP )
        wstyle |= UDS_WRAP;

    // create the UpDown control.
    m_hWnd = (WXHWND)CreateUpDownControl
                     (
                       wstyle,
                       x, y, width, height,
                       GetHwndOf(parent),
                       m_windowId,
                       wxGetInstance(),
                       NULL, // no buddy
                       m_max, m_min,
                       m_min // initial position
                     );

    if ( !m_hWnd )
    {
        wxLogLastError(wxT("CreateUpDownControl"));

        return false;
    }

    if ( parent )
    {
        parent->AddChild(this);
    }

    SubclassWin(m_hWnd);

    SetInitialSize(size);

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

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

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

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

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

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

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

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

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

        wxSize newSize(width, height);
        wxSizeEvent event(newSize, GetId());
        event.SetEventObject(this);
        HandleWindowEvent(event);
    }
}
コード例 #26
0
 virtual wxSize GetMinSize() const
 {
     return DoGetBestSize();
 }
コード例 #27
0
ファイル: toggle.cpp プロジェクト: SamanthaClark/UI-Builder
void wxCustomButton::SetBitmapMargin(const wxSize &margin, bool fit)
{
    m_bitmapMargin = margin;
    CalcLayout(true);
    if (fit) SetSize(DoGetBestSize());
}
コード例 #28
0
void wxSpeedButton::CalcLayout(bool inRefresh) {
int         i;
int         bn;
int         w, h;
bool        gz, lz;
int         gx, gy;
int         lx, ly;

// no recursive calls

    if (mCalcBusy) return;
    mCalcBusy = true;

// current size of the button

    GetSize(&w,&h);
    mCurrentSize.Set(w, h);

// get sizes of bitmaps and labels, alignment and margin

    DoGetBestSize();

// glyph or label not used?

    gz = (mGlyphSize.GetWidth() == 0) || (mGlyphSize.GetHeight() == 0);
    lz = (mLabelSize.GetWidth() == 0) || (mLabelSize.GetHeight() == 0);

// border size is a magiv number, imperically determined using the
// wxNativeRenderer to draw the button

    bn = 2;

// position depends on alignment

    i = GetWindowStyleFlag();

    if (gz && lz) {                 // no glyph, no label
        gx = 0;
        gy = 0;
        lx = 0;
        ly = 0;
    }
    else if (gz) {                  // no glyph, only label
        gx = 0;
        gy = 0;
        lx = (mCurrentSize.GetWidth()  - mLabelSize.GetWidth())  / 2;
        ly = (mCurrentSize.GetHeight() - mLabelSize.GetHeight()) / 2;
    }
    else if (lz) {                  // no label, glyph only
        gx = (mCurrentSize.GetWidth()  - mGlyphSize.GetWidth())  / 2;
        gy = (mCurrentSize.GetHeight() - mGlyphSize.GetHeight()) / 2;
        lx = 0;
        ly = 0;
    }
    else if ((i & wxBU_LEFT) != 0) {
        gx = bn + mMargin;
        lx = gx + mGlyphSize.GetWidth() + mMargin;
        gy = (mCurrentSize.GetHeight() - mGlyphSize.GetHeight()) / 2;
        ly = (mCurrentSize.GetHeight() - mLabelSize.GetHeight()) / 2;
    }
    else if ((i & wxBU_RIGHT) != 0) {
        gx = mCurrentSize.GetWidth() - (mGlyphSize.GetWidth() + mMargin + bn);
        lx = gx - (mLabelSize.GetWidth() + mMargin);
        gy = (mCurrentSize.GetHeight() - mGlyphSize.GetHeight()) / 2;
        ly = (mCurrentSize.GetHeight() - mLabelSize.GetHeight()) / 2;
    }
    else if ((i & wxBU_TOP) != 0) {
        gx = (mCurrentSize.GetWidth()  - mGlyphSize.GetWidth())  / 2;
        lx = (mCurrentSize.GetWidth()  - mLabelSize.GetWidth())  / 2;
        gy = bn + mMargin;
        ly = gy + mMargin + mGlyphSize.GetHeight();
    }
    else if ((i & wxBU_BOTTOM) != 0) {
        gx = (mCurrentSize.GetWidth()  - mGlyphSize.GetWidth())  / 2;
        lx = (mCurrentSize.GetWidth()  - mLabelSize.GetWidth())  / 2;
        gy = mCurrentSize.GetHeight() - (bn + mMargin + mGlyphSize.GetHeight());
        ly = gy - (mLabelSize.GetHeight() + mMargin);
    }
    else { // unknown
        gx = 0;
        gy = 0;
        lx = 0;
        ly = 0;
    };

// save the positions

    mGlyphPos.x = gx;
    mGlyphPos.y = gy;
    mLabelPos.x = lx;
    mLabelPos.y = ly;

// redraw button?

    if (inRefresh) Refresh(false);

// allow another call

    mCalcBusy = false;
}
コード例 #29
0
ファイル: spinbutt.cpp プロジェクト: esrrhs/fuck-music-player
bool wxSpinButton::Create(
  wxWindow*                         pParent
, wxWindowID                        vId
, const wxPoint&                    rPos
, const wxSize&                     rSize
, long                              lStyle
, const wxString&                   rsName
)
{
    int                             nX      = rPos.x;
    int                             nY      = rPos.y;
    int                             nWidth  = rSize.x;
    int                             nHeight = rSize.y;
    SWP                             vSwp;

    m_min = 0;
    m_max = 100;
    if (vId == -1)
        m_windowId = NewControlId();
    else
        m_windowId = vId;
    if (pParent)
    {
        m_backgroundColour = pParent->GetBackgroundColour();
        m_foregroundColour = pParent->GetForegroundColour();
    }
    SetName(rsName);
    SetParent(pParent);
    m_windowStyle      = lStyle;

    //
    // Get the right size for the control
    //
    if (nWidth <= 0 || nHeight <= 0 )
    {
        wxSize                      vSize = DoGetBestSize();

        if (nWidth <= 0 )
            nWidth = vSize.x;
        if (nHeight <= 0 )
            nHeight = vSize.y;
    }
    if (nX < 0 )
        nX = 0;
    if (nY < 0 )
        nY = 0;

    long                            lSstyle = 0L;

    lSstyle = WS_VISIBLE      |
              WS_TABSTOP      |
              SPBS_MASTER     | // We use only single field spin buttons
              SPBS_NUMERICONLY; // We default to numeric data

    if (m_windowStyle & wxCLIP_SIBLINGS )
        lSstyle |= WS_CLIPSIBLINGS;

    m_hWnd = (WXHWND)::WinCreateWindow( GetWinHwnd(pParent)
                                       ,WC_SPINBUTTON
                                       ,(PSZ)NULL
                                       ,lSstyle
                                       ,0L, 0L, 0L, 0L
                                       ,GetWinHwnd(pParent)
                                       ,HWND_TOP
                                       ,(HMENU)vId
                                       ,NULL
                                       ,NULL
                                      );
    if (m_hWnd == 0)
    {
        return FALSE;
    }
    SetRange(m_min, m_max);
    if(pParent)
        pParent->AddChild((wxSpinButton *)this);

    ::WinQueryWindowPos(m_hWnd, &vSwp);
    SetXComp(vSwp.x);
    SetYComp(vSwp.y-5); // compensate for the associated TextControl border

    SetFont(*wxSMALL_FONT);
    //
    // For OS/2 we want to hide the text portion so we can substitute an
    // independent text ctrl in its place.
    // Therefore we must override any user given width with our best guess.
    //
    SetSize( nX - GetXComp()
            ,nY - GetYComp()
            ,nWidth
            ,nHeight
           );
    wxAssociateWinWithHandle( m_hWnd
                             ,(wxWindowOS2*)this
                            );
#if 0
    // FIXME:
    // Apparently, this does not work, as it crashes in setvalue/setrange calls
    // What's it supposed to do anyway?
    ::WinSetWindowULong(GetHwnd(), QWL_USER, (LONG)this);
    fnWndProcSpinCtrl = (WXFARPROC)::WinSubclassWindow(m_hWnd, (PFNWP)wxSpinCtrlWndProc);
#endif
    return TRUE;
} // end of wxSpinButton::Create
コード例 #30
0
ファイル: fiximp.cpp プロジェクト: maxmods/wx.mod
bool wxFixWidthImportCtrl::Create(wxWindow *parent,
                            wxWindowID id,
                            const wxPoint& pos,
                            const wxSize& size,
                            long style,
                            const wxString& name)
{
    if ( !wxControl::Create(parent, id, pos, size,
                            style,
                            wxDefaultValidator, name) )
    {
        return false;
    }

    //Create the scroll bars
    m_scrbarH = new wxScrollBar(this, FW_SCROH);
    m_scrbarV = new wxScrollBar(this, FW_SCROV,
                                wxDefaultPosition, wxDefaultSize, wxSB_VERTICAL);

    if (!m_scrbarH || !m_scrbarV)
        return false;

    m_margin = 2;
    m_sbHheigth = m_scrbarH->GetSize().GetHeight();
    m_sbVwidth  = m_scrbarV->GetSize().GetWidth();

    //Fonts we'll use are some more big and small than default's one
    int pointsizeDef = GetFont().GetPointSize();

    //A fixed pitch font for the file (a little bigger)
    m_Ffont = wxTheFontList->FindOrCreateFont((int)(pointsizeDef * 1.13),
                                              wxMODERN, wxNORMAL, wxNORMAL);

    //The font for the scale, also a pitch font (a little smaller)
    m_Sfont = wxTheFontList->FindOrCreateFont((int)(pointsizeDef * 0.88),
                                              wxMODERN, wxNORMAL, wxNORMAL);

    //Size
    wxSize sizeReal;
    if ( size.x == -1 || size.y == -1 )
    {
        sizeReal = DoGetBestSize();
        if ( size.x != -1 )
            sizeReal.x = size.x;
        if ( size.y != -1 )
            sizeReal.y = size.y;
    }
    else
    {
        sizeReal = size;
    }

    //SetSize calls DoMoveWindow, which sets sub-controls  size & position
    SetSize(pos.x, pos.y, sizeReal.x, sizeReal.y);

    m_curposX = m_curposL = m_markedL = m_LAct = 0;
    m_delPrev = false;
    m_captured = false;
    m_timeInit = m_timeNow = 0;
    m_lastType = 0;
    deliEnabled = true;

    return true;
}