예제 #1
0
wxMacDataBrowserColumn* wxMacDataBrowserListControl::DoInsertColumn( unsigned int pos, DataBrowserPropertyID property,
                                const wxString& title, bool editable,
                                DataBrowserPropertyType colType, SInt16 just, int width )
{
    DataBrowserListViewColumnDesc columnDesc;
    columnDesc.headerBtnDesc.titleOffset = 0;
    columnDesc.headerBtnDesc.version = kDataBrowserListViewLatestHeaderDesc;

    columnDesc.headerBtnDesc.btnFontStyle.flags =
        kControlUseFontMask | kControlUseJustMask;

    columnDesc.headerBtnDesc.btnContentInfo.contentType = kControlContentTextOnly;
    columnDesc.headerBtnDesc.btnFontStyle.just = just;
    columnDesc.headerBtnDesc.btnFontStyle.font = kControlFontViewSystemFont;
    columnDesc.headerBtnDesc.btnFontStyle.style = normal;

    // TODO: Why is m_font not defined when we enter wxLC_LIST mode, but is
    // defined for other modes?
    wxFontEncoding enc;
    if ( m_font.IsOk() )
        enc = m_font.GetEncoding();
    else
        enc = wxLocale::GetSystemEncoding();
    wxCFStringRef cfTitle( title, enc );
    columnDesc.headerBtnDesc.titleString = cfTitle;

    columnDesc.headerBtnDesc.minimumWidth = 0;
    columnDesc.headerBtnDesc.maximumWidth = 30000;

    columnDesc.propertyDesc.propertyID = property;
    columnDesc.propertyDesc.propertyType = colType;
    columnDesc.propertyDesc.propertyFlags = kDataBrowserListViewSortableColumn;
    columnDesc.propertyDesc.propertyFlags |= kDataBrowserListViewTypeSelectColumn;
    columnDesc.propertyDesc.propertyFlags |= kDataBrowserListViewNoGapForIconInHeaderButton;

    if ( editable )
        columnDesc.propertyDesc.propertyFlags |= kDataBrowserPropertyIsMutable;

    verify_noerr( AddColumn( &columnDesc, pos ) );

    if (width > 0)
    {
        wxMacDataBrowserControl::SetColumnWidth(property, width);
    }

    wxMacDataBrowserColumn *col = new wxMacDataBrowserColumn( property, colType, editable );

    m_columns.Insert( col, pos );

    return col;
}
예제 #2
0
void wxMacDataItemBrowserControl::InsertColumn(int col, DataBrowserPropertyType colType,
                                            const wxString& title, SInt16 just, int defaultWidth)
{
    DataBrowserListViewColumnDesc columnDesc;
    columnDesc.headerBtnDesc.titleOffset = 0;
    columnDesc.headerBtnDesc.version = kDataBrowserListViewLatestHeaderDesc;

    columnDesc.headerBtnDesc.btnFontStyle.flags =
        kControlUseFontMask | kControlUseJustMask;

    columnDesc.headerBtnDesc.btnContentInfo.contentType = kControlContentTextOnly;
    columnDesc.headerBtnDesc.btnFontStyle.just = just;
    columnDesc.headerBtnDesc.btnFontStyle.font = kControlFontViewSystemFont;
    columnDesc.headerBtnDesc.btnFontStyle.style = normal;

    // TODO: Why is m_font not defined when we enter wxLC_LIST mode, but is
    // defined for other modes?
    wxFontEncoding enc;
    if ( m_font.IsOk() )
        enc = m_font.GetEncoding();
    else
        enc = wxLocale::GetSystemEncoding();
    wxCFStringRef cfTitle( title, enc );
    columnDesc.headerBtnDesc.titleString = cfTitle;

    columnDesc.headerBtnDesc.minimumWidth = 0;
    columnDesc.headerBtnDesc.maximumWidth = 30000;

    DataBrowserPropertyID id = kMinColumnId + column_id_counter;
    column_id_counter++;

    columnDesc.propertyDesc.propertyID = id;
    columnDesc.propertyDesc.propertyType = colType;
    columnDesc.propertyDesc.propertyFlags = kDataBrowserListViewSortableColumn;
    columnDesc.propertyDesc.propertyFlags |= kDataBrowserListViewTypeSelectColumn;
    columnDesc.propertyDesc.propertyFlags |= kDataBrowserListViewNoGapForIconInHeaderButton;

    verify_noerr( AddColumn( &columnDesc, col ) );

    if (defaultWidth > 0){
        SetColumnWidth(col, defaultWidth);
    }
}
예제 #3
0
int wxMessageDialog::ShowModal()
{
    WX_HOOK_MODAL_DIALOG();

    int resultbutton = wxID_CANCEL;

    const long style = GetMessageDialogStyle();

    wxASSERT_MSG( (style & 0x3F) != wxYES,
        "this style is not supported on Mac" );

    AlertType alertType = kAlertPlainAlert;

    switch ( GetEffectiveIcon() )
    {
        case wxICON_ERROR:
            alertType = kAlertStopAlert;
            break;

        case wxICON_WARNING:
            alertType = kAlertCautionAlert;
            break;

        case wxICON_QUESTION:
        case wxICON_INFORMATION:
            alertType = kAlertNoteAlert;
            break;
    }

    // (the standard alert has two slots [title, text]
    //  for the three wxStrings [caption, message, extended message])
    //
    // if the extended text is empty we use the caption and
    // the message (for backwards compatibility)
    //
    // if the extended text is not empty we ignore the caption
    // and use the message and the extended message


    wxString msgtitle,msgtext;
    if(m_extendedMessage.IsEmpty())
    {
        if ( m_caption.IsEmpty() )
            msgtitle = m_message;
        else
        {
            msgtitle = m_caption;
            msgtext  = m_message;
        }
    }
    else
    {
        msgtitle = m_message;
        msgtext  = m_extendedMessage;
    }


    if ( !wxIsMainThread() )
    {
        CFStringRef defaultButtonTitle = NULL;
        CFStringRef alternateButtonTitle = NULL;
        CFStringRef otherButtonTitle = NULL;

        wxCFStringRef cfTitle( msgtitle, GetFont().GetEncoding() );
        wxCFStringRef cfText( msgtext, GetFont().GetEncoding() );

        wxCFStringRef cfNoString( GetNoLabel().c_str(), GetFont().GetEncoding() );
        wxCFStringRef cfYesString( GetYesLabel().c_str(), GetFont().GetEncoding() );
        wxCFStringRef cfOKString( GetOKLabel().c_str() , GetFont().GetEncoding()) ;
        wxCFStringRef cfCancelString( GetCancelLabel().c_str(), GetFont().GetEncoding() );

        int buttonId[4] = { 0, 0, 0, wxID_CANCEL /* time-out */ };

        if (style & wxYES_NO)
        {
            if ( style & wxNO_DEFAULT )
            {
                defaultButtonTitle = cfNoString;
                alternateButtonTitle = cfYesString;
                buttonId[0] = wxID_NO;
                buttonId[1] = wxID_YES;
            }
            else
            {
                defaultButtonTitle = cfYesString;
                alternateButtonTitle = cfNoString;
                buttonId[0] = wxID_YES;
                buttonId[1] = wxID_NO;
            }
            if (style & wxCANCEL)
            {
                otherButtonTitle = cfCancelString;
                buttonId[2] = wxID_CANCEL;
            }
        }
        else
        {
            // the MSW implementation even shows an OK button if it is not specified, we'll do the same
            buttonId[0] = wxID_OK;
            // using null as default title does not work on earlier systems
            defaultButtonTitle = cfOKString;
            if (style & wxCANCEL)
            {
                alternateButtonTitle = cfCancelString;
                buttonId[1] = wxID_CANCEL;
            }
        }

        CFOptionFlags exitButton;
        OSStatus err = CFUserNotificationDisplayAlert(
            0, alertType, NULL, NULL, NULL, cfTitle, cfText,
            defaultButtonTitle, alternateButtonTitle, otherButtonTitle, &exitButton );
        if (err == noErr)
            resultbutton = buttonId[exitButton];
    }
    else
    {
        short result;

        AlertStdCFStringAlertParamRec param;
        wxCFStringRef cfNoString( GetNoLabel().c_str(), GetFont().GetEncoding() );
        wxCFStringRef cfYesString( GetYesLabel().c_str(), GetFont().GetEncoding() );
        wxCFStringRef cfOKString( GetOKLabel().c_str(), GetFont().GetEncoding() );
        wxCFStringRef cfCancelString( GetCancelLabel().c_str(), GetFont().GetEncoding() );

        wxCFStringRef cfTitle( msgtitle, GetFont().GetEncoding() );
        wxCFStringRef cfText = msgtext.IsEmpty() ? wxCFStringRef() : wxCFStringRef( msgtext, GetFont().GetEncoding() );

        param.movable = true;
        param.flags = 0;
        param.version = kStdCFStringAlertVersionOne;

        bool skipDialog = false;

        if (style & wxYES_NO)
        {
            if (style & wxCANCEL)
            {
                param.defaultText = cfYesString;
                param.cancelText = cfCancelString;
                param.otherText = cfNoString;
                param.helpButton = false;
                param.defaultButton = style & wxNO_DEFAULT ? kAlertStdAlertOtherButton : kAlertStdAlertOKButton;
                param.cancelButton = kAlertStdAlertCancelButton;
            }
            else
            {
                param.defaultText = cfYesString;
                param.cancelText = NULL;
                param.otherText = cfNoString;
                param.helpButton = false;
                param.defaultButton = style & wxNO_DEFAULT ? kAlertStdAlertOtherButton : kAlertStdAlertOKButton;
                param.cancelButton = 0;
            }
        }
        // the MSW implementation even shows an OK button if it is not specified, we'll do the same
        else
        {
            if (style & wxCANCEL)
            {
                // that's a cancel missing
                param.defaultText = cfOKString;
                param.cancelText = cfCancelString;
                param.otherText = NULL;
                param.helpButton = false;
                param.defaultButton = kAlertStdAlertOKButton;
                param.cancelButton = 0;
            }
            else
            {
                param.defaultText = cfOKString;
                param.cancelText = NULL;
                param.otherText = NULL;
                param.helpButton = false;
                param.defaultButton = kAlertStdAlertOKButton;
                param.cancelButton = 0;
            }
        }

        param.position = kWindowDefaultPosition;
        if ( !skipDialog )
        {
            DialogRef alertRef;
            CreateStandardAlert( alertType, cfTitle, cfText, &param, &alertRef );
            wxDialog::OSXBeginModalDialog();
            RunStandardAlert( alertRef, NULL, &result );
            wxDialog::OSXEndModalDialog();
        }
        else
        {
            return wxID_CANCEL;
        }

        if (style & wxOK)
        {
            switch ( result )
            {
            case 1:
                resultbutton = wxID_OK;
                break;

            case 2:
                // TODO: add Cancel button
                // if (style & wxCANCEL)
                //     resultbutton = wxID_CANCEL;
                break;

            case 3:
            default:
                break;
            }
        }
        else if (style & wxYES_NO)
        {
            switch ( result )
            {
            case 1:
                resultbutton = wxID_YES;
                break;

            case 2:
                if (!(style & wxCANCEL))
                    resultbutton = wxID_CANCEL;
                break;

            case 3:
                resultbutton = wxID_NO;
                break;

            default:
                break;
            }
        }
    }

    SetReturnCode(resultbutton);

    return resultbutton;
}
예제 #4
0
파일: msgdlg.cpp 프로젝트: Duion/Torsion
int wxMessageDialog::ShowModal()
{
    int resultbutton = wxID_CANCEL ;

    short result ;

    const long style = GetMessageDialogStyle();

    wxASSERT_MSG( ( style & 0x3F ) != wxYES , wxT("this style is not supported on mac") ) ;

    AlertType alertType = kAlertPlainAlert ;
    if (style & wxICON_EXCLAMATION)
        alertType = kAlertNoteAlert ;
    else if (style & wxICON_HAND)
        alertType = kAlertStopAlert ;
    else if (style & wxICON_INFORMATION)
        alertType = kAlertNoteAlert ;
    else if (style & wxICON_QUESTION)
        alertType = kAlertCautionAlert ;

#if TARGET_CARBON
    if ( UMAGetSystemVersion() >= 0x1000 )
    {
        AlertStdCFStringAlertParamRec param ;
        wxMacCFStringHolder cfNoString(_("No") , m_font.GetEncoding()) ;
        wxMacCFStringHolder cfYesString( _("Yes") , m_font.GetEncoding()) ;

        wxMacCFStringHolder cfTitle(m_caption , m_font.GetEncoding());
        wxMacCFStringHolder cfText(m_message , m_font.GetEncoding());

        param.movable = true;
        param.flags = 0 ;

        bool skipDialog = false ;

        if (style & wxYES_NO)
        {
            if (style & wxCANCEL)
            {
                param.defaultText     = cfYesString ;
                param.cancelText     = (CFStringRef) kAlertDefaultCancelText;
                param.otherText     = cfNoString ;
                param.helpButton     = false ;
                param.defaultButton = kAlertStdAlertOKButton;
                param.cancelButton     = kAlertStdAlertCancelButton;
            }
            else
            {
                param.defaultText     = cfYesString ;
                param.cancelText     = NULL;
                param.otherText     = cfNoString ;
                param.helpButton     = false ;
                param.defaultButton = kAlertStdAlertOKButton;
                param.cancelButton     = 0;
            }
        }
        // the msw implementation even shows an ok button if it is not specified, we'll do the same
        else
        {
            if (style & wxCANCEL)
            {
                // thats a cancel missing
                param.defaultText     = (CFStringRef) kAlertDefaultOKText ;
                param.cancelText     = (CFStringRef) kAlertDefaultCancelText ;
                param.otherText     = NULL;
                param.helpButton     = false ;
                param.defaultButton = kAlertStdAlertOKButton;
                param.cancelButton     = 0;
            }
            else
            {
                param.defaultText     = (CFStringRef) kAlertDefaultOKText ;
                param.cancelText     = NULL;
                param.otherText     = NULL;
                param.helpButton     = false ;
                param.defaultButton = kAlertStdAlertOKButton;
                param.cancelButton     = 0;
            }
        }
        /*
        else
        {
            skipDialog = true ;
        }
        */

        param.position = kWindowDefaultPosition;
        if ( !skipDialog )
        {
            DialogRef alertRef ;
            CreateStandardAlert( alertType , cfTitle , cfText , &param , &alertRef ) ;
            RunStandardAlert( alertRef , NULL , &result ) ;
        }
        if ( skipDialog )
            return wxID_CANCEL ;
    }
    else
#endif
    {
        AlertStdAlertParamRec    param;

        Str255 yesPString ;
        Str255 noPString ;

        Str255 pascalTitle ;
        Str255 pascalText ;
        wxMacStringToPascal( m_caption , pascalTitle ) ;
        wxMacStringToPascal( _("Yes") , yesPString ) ;
        wxMacStringToPascal(  _("No") , noPString ) ;
        wxMacStringToPascal( m_message , pascalText ) ;

        param.movable         = true;
        param.filterProc     = NULL ;
        if (style & wxYES_NO)
        {
            if (style & wxCANCEL)
            {
                param.defaultText     = yesPString ;
                param.cancelText     = (StringPtr) kAlertDefaultCancelText;
                param.otherText     = noPString ;
                param.helpButton     = false ;
                param.defaultButton = kAlertStdAlertOKButton;
                param.cancelButton     = kAlertStdAlertCancelButton;
            }
            else
            {
                param.defaultText     = yesPString ;
                param.cancelText     = NULL;
                param.otherText     = noPString ;
                param.helpButton     = false ;
                param.defaultButton = kAlertStdAlertOKButton;
                param.cancelButton     = 0;
            }
        }
        else if (style & wxOK)
        {
            if (style & wxCANCEL)
            {
                param.defaultText     = (StringPtr) kAlertDefaultOKText ;
                param.cancelText     = (StringPtr) kAlertDefaultCancelText ;
                param.otherText     = NULL;
                param.helpButton     = false ;
                param.defaultButton = kAlertStdAlertOKButton;
                param.cancelButton     = 0;
            }
            else
            {
                param.defaultText     = (StringPtr) kAlertDefaultOKText ;
                param.cancelText     = NULL;
                param.otherText     = NULL;
                param.helpButton     = false ;
                param.defaultButton = kAlertStdAlertOKButton;
                param.cancelButton     = 0;
            }
        }
        else
        {
            return resultbutton ;
        }

        param.position         = 0;

        StandardAlert( alertType, pascalTitle, pascalText, &param, &result );
    }

    if (style & wxOK)
    {
        if (style & wxCANCEL)
        {
            //TODO add Cancelbutton
            switch( result )
            {
            case 1 :
                resultbutton = wxID_OK ;
                break ;
            case 2 :
                break ;
            case 3 :
                break ;
            }
        }
        else
        {
            switch( result )
            {
            case 1 :
                resultbutton = wxID_OK ;
                break ;
            case 2 :
                break ;
            case 3 :
                break ;
            }
        }
    }
    else if (style & wxYES_NO)
    {
        if (style & wxCANCEL)
        {
            switch( result )
            {
            case 1 :
                resultbutton = wxID_YES ;
                break ;
            case 2 :
                resultbutton = wxID_CANCEL ;
                break ;
            case 3 :
                resultbutton = wxID_NO ;
                break ;
            }
        }
        else
        {
            switch( result )
            {
            case 1 :
                resultbutton = wxID_YES ;
                break ;
            case 2 :
                break ;
            case 3 :
                resultbutton = wxID_NO ;
                break ;
            }
        }
    }

    return resultbutton ;
}
예제 #5
0
파일: msgdlg.cpp 프로젝트: EdgarTx/wx
int wxMessageDialog::ShowModal()
{
    int resultbutton = wxID_CANCEL;

    const long style = GetMessageDialogStyle();

    wxASSERT_MSG( (style & 0x3F) != wxYES, wxT("this style is not supported on Mac") );

    AlertType alertType = kAlertPlainAlert;
    if (style & wxICON_EXCLAMATION)
        alertType = kAlertCautionAlert;
    else if (style & wxICON_HAND)
        alertType = kAlertStopAlert;
    else if (style & wxICON_INFORMATION)
        alertType = kAlertNoteAlert;
    else if (style & wxICON_QUESTION)
        alertType = kAlertNoteAlert;

#if TARGET_API_MAC_OSX
    if ( !wxIsMainThread() )
    {
        CFStringRef defaultButtonTitle = NULL;
        CFStringRef alternateButtonTitle = NULL;
        CFStringRef otherButtonTitle = NULL;

        wxMacCFStringHolder cfTitle( m_caption, m_font.GetEncoding() );
        wxMacCFStringHolder cfText( m_message, m_font.GetEncoding() );

        wxMacCFStringHolder cfNoString( _("No"), m_font.GetEncoding() );
        wxMacCFStringHolder cfYesString( _("Yes"), m_font.GetEncoding() );
        wxMacCFStringHolder cfOKString( _("OK") , m_font.GetEncoding()) ;
        wxMacCFStringHolder cfCancelString( _("Cancel"), m_font.GetEncoding() );

        int buttonId[4] = { 0, 0, 0, wxID_CANCEL /* time-out */ };

        if (style & wxYES_NO)
        {
            if ( style & wxNO_DEFAULT )
            {
                defaultButtonTitle = cfNoString;
                alternateButtonTitle = cfYesString;
                buttonId[0] = wxID_NO;
                buttonId[1] = wxID_YES;
            }
            else
            {
                defaultButtonTitle = cfYesString;
                alternateButtonTitle = cfNoString;
                buttonId[0] = wxID_YES;
                buttonId[1] = wxID_NO;
            }
            if (style & wxCANCEL)
            {
                otherButtonTitle = cfCancelString;
                buttonId[2] = wxID_CANCEL;
            }
        }
        else
        {
            // the MSW implementation even shows an OK button if it is not specified, we'll do the same
            buttonId[0] = wxID_OK;
            // using null as default title does not work on earlier systems
            defaultButtonTitle = cfOKString;
            if (style & wxCANCEL)
            {
                alternateButtonTitle = cfCancelString;
                buttonId[1] = wxID_CANCEL;
            }
        }

        CFOptionFlags exitButton;
        OSStatus err = CFUserNotificationDisplayAlert(
            0, alertType, NULL, NULL, NULL, cfTitle, cfText,
            defaultButtonTitle, alternateButtonTitle, otherButtonTitle, &exitButton );
        if (err == noErr)
            resultbutton = buttonId[exitButton];
    }
    else
#endif
    {
        short result;

        AlertStdCFStringAlertParamRec param;
        wxMacCFStringHolder cfNoString( _("No"), m_font.GetEncoding() );
        wxMacCFStringHolder cfYesString( _("Yes"), m_font.GetEncoding() );

        wxMacCFStringHolder cfTitle( m_caption, m_font.GetEncoding() );
        wxMacCFStringHolder cfText( m_message, m_font.GetEncoding() );

        param.movable = true;
        param.flags = 0;
        param.version = kStdCFStringAlertVersionOne;

        bool skipDialog = false;

        if (style & wxYES_NO)
        {
            if (style & wxCANCEL)
            {
                param.defaultText = cfYesString;
                param.cancelText = (CFStringRef) kAlertDefaultCancelText;
                param.otherText = cfNoString;
                param.helpButton = false;
                param.defaultButton = style & wxNO_DEFAULT ? kAlertStdAlertOtherButton : kAlertStdAlertOKButton;
                param.cancelButton = kAlertStdAlertCancelButton;
            }
            else
            {
                param.defaultText = cfYesString;
                param.cancelText = NULL;
                param.otherText = cfNoString;
                param.helpButton = false;
                param.defaultButton = style & wxNO_DEFAULT ? kAlertStdAlertOtherButton : kAlertStdAlertOKButton;
                param.cancelButton = 0;
            }
        }
        // the MSW implementation even shows an OK button if it is not specified, we'll do the same
        else
        {
            if (style & wxCANCEL)
            {
                // that's a cancel missing
                param.defaultText = (CFStringRef) kAlertDefaultOKText;
                param.cancelText = (CFStringRef) kAlertDefaultCancelText;
                param.otherText = NULL;
                param.helpButton = false;
                param.defaultButton = kAlertStdAlertOKButton;
                param.cancelButton = 0;
            }
            else
            {
                param.defaultText = (CFStringRef) kAlertDefaultOKText;
                param.cancelText = NULL;
                param.otherText = NULL;
                param.helpButton = false;
                param.defaultButton = kAlertStdAlertOKButton;
                param.cancelButton = 0;
            }
        }

        param.position = kWindowDefaultPosition;
        if ( !skipDialog )
        {
            DialogRef alertRef;
            CreateStandardAlert( alertType, cfTitle, cfText, &param, &alertRef );
            RunStandardAlert( alertRef, NULL, &result );
        }
        else
        {
            return wxID_CANCEL;
        }

        if (style & wxOK)
        {
            switch ( result )
            {
            case 1:
                resultbutton = wxID_OK;
                break;

            case 2:
                // TODO: add Cancel button
                // if (style & wxCANCEL)
                //     resultbutton = wxID_CANCEL;
                break;

            case 3:
            default:
                break;
            }
        }
        else if (style & wxYES_NO)
        {
            switch ( result )
            {
            case 1:
                resultbutton = wxID_YES;
                break;

            case 2:
                if (!(style & wxCANCEL))
                    resultbutton = wxID_CANCEL;
                break;

            case 3:
                resultbutton = wxID_NO;
                break;

            default:
                break;
            }
        }
    }

    return resultbutton;
}