To comment on the following update, log in, then open the issue:
http://www.openoffice.org/issues/show_bug.cgi?id=79327
                 Issue #|79327
                 Summary|Constant c.s.s.awt.DEFAULT_BUTTON_IGNORE
               Component|api
                 Version|OOo 2.1
                Platform|All
                     URL|
              OS/Version|All
                  Status|UNCONFIRMED
       Status whiteboard|
                Keywords|
              Resolution|
              Issue type|DEFECT
                Priority|P4
            Subcomponent|code
             Assigned to|jsc
             Reported by|villeroy





------- Additional comments from [EMAIL PROTECTED] Fri Jul  6 13:26:09 +0000 
2007 -------
I wrote a simple message box wrapper in Python. See comments in declaration of
dictionary dInput:

# _________PYTHON__________
from com.sun.star.awt.MessageBoxButtons import BUTTONS_OK, BUTTONS_OK_CANCEL,
BUTTONS_ABORT_IGNORE_RETRY, BUTTONS_YES_NO_CANCEL, BUTTONS_YES_NO,
BUTTONS_RETRY_CANCEL, DEFAULT_BUTTON_OK, DEFAULT_BUTTON_CANCEL,
DEFAULT_BUTTON_RETRY, DEFAULT_BUTTON_YES, DEFAULT_BUTTON_NO, 
DEFAULT_BUTTON_IGNORE

class MessageBox:
    '''Message box for OpenOffice.org, like the one in the Basic macro language.
To specify a MsgBox type, use the named constants of this class or the
equivalent numbers described in the StarBasic online help. Specify a parent
window on initialization.'''

    # Named constants for ease of use:
    OK = 0
    OK_CANCEL = 1
    ABORT_RETRY_IGNORE = 2
    YES_NO_CANCEL = 3
    YES_NO = 4
    RETRY_CANCEL = 5
    ERROR = 16
    QUERY = 32
    WARN = 48
    INFO = 64
    DEFAULT_FIRST = 128
    DEFAULT_SECOND = 256
    DEFAULT_THIRD = 512
    RESULT_OK = 1
    RESULT_CANCEL = 2
    RESULT_ABORT = 3
    RESULT_RETRY = 4
    RESULT_IGNORE = 5
    RESULT_YES = 6
    RESULT_NO = 7

    # Mapping above StarBasic MsgBox constants to awt.MessageBoxButtons and 
icons:
    dInput = {
        OK_CANCEL : BUTTONS_OK_CANCEL,
        # the following constant should be named BUTTONS_ABORT_RETRY_IGNORE:
        ABORT_RETRY_IGNORE : BUTTONS_ABORT_IGNORE_RETRY,
        YES_NO_CANCEL : BUTTONS_YES_NO_CANCEL,
        YES_NO : BUTTONS_YES_NO,
        RETRY_CANCEL : BUTTONS_RETRY_CANCEL,
        ERROR : 'errorbox',
        QUERY : 'querybox',
        WARN : 'warningbox',
        INFO : 'infobox',
        129 : BUTTONS_OK_CANCEL + DEFAULT_BUTTON_OK,
        130 : BUTTONS_ABORT_IGNORE_RETRY + DEFAULT_BUTTON_CANCEL,
        131 : BUTTONS_YES_NO_CANCEL + DEFAULT_BUTTON_YES,
        132 : BUTTONS_YES_NO + DEFAULT_BUTTON_YES,
        133 : BUTTONS_RETRY_CANCEL + DEFAULT_BUTTON_RETRY,
        257 : BUTTONS_OK_CANCEL + DEFAULT_BUTTON_CANCEL,
        258 : BUTTONS_ABORT_IGNORE_RETRY + DEFAULT_BUTTON_RETRY, # retry is 2nd!
        259 : BUTTONS_YES_NO_CANCEL + DEFAULT_BUTTON_NO,
        260 : BUTTONS_YES_NO + DEFAULT_BUTTON_NO,
        261 : BUTTONS_RETRY_CANCEL + DEFAULT_BUTTON_CANCEL,
        # DEFAULT_BUTTON_IGNORE doesn't work at all. Use retry in this case:
        # 514 : BUTTONS_ABORT_IGNORE_RETRY  + DEFAULT_BUTTON_IGNORE,
        514 : BUTTONS_ABORT_IGNORE_RETRY  + DEFAULT_BUTTON_RETRY,
        515 : BUTTONS_YES_NO_CANCEL + DEFAULT_BUTTON_CANCEL,
        }
    dOutput = {
        1 : RESULT_OK,
        2 : RESULT_YES,
        3 : RESULT_NO,
        4 : RESULT_RETRY,
        5 : RESULT_IGNORE,
        0 : RESULT_CANCEL, # there is no const for ABORT
        }
        
    def __init__(self, XParentWindow):
        '''Set needed objects on init'''
        try:
            self.Parent = XParentWindow
            self.Toolkit = XParentWindow.getToolkit()
        except:
            raise AttributeError, 'Did not get a valid parent window'
            
    def msgbox(self, message='', flag=0, title=''):
        '''Wrapper for com.sun.star.awt.XMessageBoxFactory.'''
        rect = uno.createUnoStruct('com.sun.star.awt.Rectangle')
        stype, buttons = self.getFlags(flag)
        box = self.Toolkit.createMessageBox(self.Parent, rect, stype, buttons,
title, message)
        e = box.execute()
        # the result of execute() does not distinguish between Cancel and Abort:
        if (e == 0) and (flag & self.ABORT_RETRY_IGNORE == 
self.ABORT_RETRY_IGNORE):
            r  = self.RESULT_ABORT
        else:
            try:
                r = self.dOutput[e]
            except KeyError:
                raise KeyError, 'Lookup of message box result '+ str(e) +' 
failed'

        return r

    def getFlags(self, flag):
        s = self.dInput.get(flag & 112, 'messbox')
        try:
            b = self.dInput[flag & 903]
        except KeyError:
            b = self.dInput.get(flag & 7, BUTTONS_OK)
        # print 'B/D-Flag:', flag & 7, flag & 896, 'Return:', hex(b), s
        return s, b

---------------------------------------------------------------------
Please do not reply to this automatically generated notification from
Issue Tracker. Please log onto the website and enter your comments.
http://qa.openoffice.org/issue_handling/project_issues.html#notification

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to