Changeset 208:fff9f748b33b

Show
Ignore:
Timestamp:
03/15/08 12:48:15 (6 months ago)
Author:
Frank Benoit <benoit@tionex.de>
branch:
default
Message:

Added convinience methods in MessageBox? now they are same as in dwt-win

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • dwt/widgets/MessageBox.d

    r108 r208  
    1 /******************************************************************************* 
     1/******************************************************************************* 
    22 * Copyright (c) 2000, 2007 IBM Corporation and others. 
    33 * All rights reserved. This program and the accompanying materials 
     
    4848    char[] message = ""; 
    4949    GtkWidget* handle; 
     50    private bool allowNullParent = false; 
    5051/** 
    5152 * Constructs a new instance of this class given only its parent. 
     
    9192    super(parent, checkStyle(style)); 
    9293    checkSubclass (); 
     94} 
     95 
     96/++ 
     97 + DWT extension, a MessageBox with no parent 
     98 +/ 
     99public this (int style) { 
     100    allowNullParent = true; 
     101    super (parent, checkStyle (style)); 
     102    checkSubclass (); 
     103} 
     104// PORT 
     105// actually, the parent can be null 
     106override void checkParent (Shell parent){ 
     107    if( !allowNullParent ){ 
     108        super.checkParent( parent ); 
     109    } 
    93110} 
    94111 
     
    198215    return result[ 0 .. j ]; 
    199216} 
    200 
     217 
     218 
     219/** 
     220 * DWT extension 
     221 */ 
     222public static int showMessageBox(char[] str, char[] title, Shell shell, int style) { 
     223    MessageBox msgBox = (shell is null ) ? new MessageBox( style ) : new MessageBox(shell, style); 
     224    msgBox.setMessage(str); 
     225    if(title !is null){ 
     226        msgBox.setText(title); 
     227    } 
     228    return msgBox.open(); 
     229
     230 
     231/// DWT extension 
     232public static int showInfo(char[] str, char[] title = null, Shell shell = null) { 
     233    return showMessageBox( str, title, shell, DWT.OK | DWT.ICON_INFORMATION ); 
     234
     235/// DWT extension 
     236alias showInfo showInformation; 
     237 
     238/// DWT extension 
     239public static int showWarning(char[] str, char[] title = null, Shell shell = null) { 
     240    return showMessageBox( str, title, shell, DWT.OK | DWT.ICON_WARNING ); 
     241
     242/// DWT extension 
     243public static int showError(char[] str, char[] title = null, Shell shell = null) { 
     244    return showMessageBox( str, title, shell, DWT.OK | DWT.ICON_ERROR ); 
     245
     246 
     247