msgBox.cpp

Engine/source/platform/nativeDialogs/msgBox.cpp

More...

Public Functions

DefineEngineFunction(messageBox , S32 , (const char *title, const char *message, MBButtons buttons, MBIcons icons) , (MBOkCancel, MIInformation) , "Display <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> modal message box using the platform's native message box <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">implementation.\n\n</a>" "@param title The title <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> display on the message box <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">window.\n</a>" "@param message The text message <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> display in the <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">box.\n</a>" "@param buttons Which buttons <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> put on the message <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">box.\n</a>" "@param icons Which icon <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> show next <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> the <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">message.\n</a>" "@return One of $MROK,  $MRCancel,  $MRRetry, and $<a href="/coding/file/msgbox_8h/#msgbox_8h_1ac8f914accac7854ace43231a8bafee09aadfb471072b0da2c5593fb8746ecd18d">MRDontSave</a> identifying the button that the user <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">pressed.\n</a>" " @<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">tsexample\n</a>" "messageBox(\"Error\", \"\" );\n" "@<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">endtsexample\n\n</a>" "@ingroup Platform" )
ImplementEnumType(MBButtons , "Which buttons <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> display on <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> message <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">box.\n\n</a>" "@ingroup Platform" )
ImplementEnumType(MBIcons , "What icon <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> show on <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> message <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">box.\n\n</a>" "@ingroup Platform" )
ImplementEnumType(MBReturnVal , "Return <a href="/coding/file/pointer_8h/#pointer_8h_1a32aff7c6c4cd253fdf6563677afab5ce">value</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> messageBox() indicating which button was pressed by the <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">user.\n\n</a>" "@ingroup Platform" )

Detailed Description

Public Variables

 EndImplementEnumType 
const MBReturnVal gsCancel 
const MBReturnVal gsDontSave 
const MBReturnVal gsOK 
const MBReturnVal gsRetry 

Public Functions

AFTER_MODULE_INIT(Sim )

DefineEngineFunction(messageBox , S32 , (const char *title, const char *message, MBButtons buttons, MBIcons icons) , (MBOkCancel, MIInformation) , "Display <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> modal message box using the platform's native message box <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">implementation.\n\n</a>" "@param title The title <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> display on the message box <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">window.\n</a>" "@param message The text message <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> display in the <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">box.\n</a>" "@param buttons Which buttons <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> put on the message <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">box.\n</a>" "@param icons Which icon <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> show next <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> the <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">message.\n</a>" "@return One of $MROK,  $MRCancel,  $MRRetry, and $<a href="/coding/file/msgbox_8h/#msgbox_8h_1ac8f914accac7854ace43231a8bafee09aadfb471072b0da2c5593fb8746ecd18d">MRDontSave</a> identifying the button that the user <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">pressed.\n</a>" " @<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">tsexample\n</a>" "messageBox(\"Error\", \"\" );\n" "@<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">endtsexample\n\n</a>" "@ingroup Platform" )

DefineEnumType(MBButtons )

DefineEnumType(MBIcons )

DefineEnumType(MBReturnVal )

ImplementEnumType(MBButtons , "Which buttons <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> display on <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> message <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">box.\n\n</a>" "@ingroup Platform" )

ImplementEnumType(MBIcons , "What icon <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> show on <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> message <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">box.\n\n</a>" "@ingroup Platform" )

ImplementEnumType(MBReturnVal , "Return <a href="/coding/file/pointer_8h/#pointer_8h_1a32aff7c6c4cd253fdf6563677afab5ce">value</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> messageBox() indicating which button was pressed by the <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">user.\n\n</a>" "@ingroup Platform" )

  1
  2//-----------------------------------------------------------------------------
  3// Copyright (c) 2012 GarageGames, LLC
  4//
  5// Permission is hereby granted, free of charge, to any person obtaining a copy
  6// of this software and associated documentation files (the "Software"), to
  7// deal in the Software without restriction, including without limitation the
  8// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  9// sell copies of the Software, and to permit persons to whom the Software is
 10// furnished to do so, subject to the following conditions:
 11//
 12// The above copyright notice and this permission notice shall be included in
 13// all copies or substantial portions of the Software.
 14//
 15// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 16// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 17// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 18// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 19// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
 21// IN THE SOFTWARE.
 22//-----------------------------------------------------------------------------
 23
 24#include "core/strings/stringFunctions.h"
 25#include "core/module.h"
 26#include "console/console.h"
 27#include "console/engineAPI.h"
 28#include "platform/nativeDialogs/msgBox.h"
 29
 30
 31DefineEnumType( MBButtons );
 32DefineEnumType( MBIcons );
 33DefineEnumType( MBReturnVal );
 34
 35
 36static const MBReturnVal gsOK = MROk;
 37static const MBReturnVal gsCancel = MRCancel;
 38static const MBReturnVal gsRetry = MRRetry;
 39static const MBReturnVal gsDontSave = MRDontSave;
 40
 41AFTER_MODULE_INIT( Sim )
 42{
 43   #if !defined( _XBOX ) && !defined( TORQUE_DEDICATED )
 44   Con::addConstant( "$MROk", TypeS32, &gsOK, "Determines the ok button press state in a message box.\n"
 45      "@ingroup Platform" );
 46   Con::addConstant( "$MRCancel", TypeS32, &gsCancel, "Determines the cancel button press state in a message box.\n"
 47      "@ingroup Platform" );
 48   Con::addConstant( "$MRRetry", TypeS32, &gsRetry, "Determines the retry button press state in a message box.\n"
 49      "@ingroup Platform");
 50   Con::addConstant( "$MRDontSave", TypeS32, &gsDontSave, "Determines the don't save button press state in a message box.\n"
 51      "@ingroup Platform" );
 52   #endif
 53}
 54
 55
 56//-----------------------------------------------------------------------------
 57
 58ImplementEnumType( MBButtons,
 59   "Which buttons to display on a message box.\n\n"
 60   "@ingroup Platform" )
 61   { MBOk,                 "Ok" },
 62   { MBOkCancel,           "OkCancel" },
 63   { MBRetryCancel,        "RetryCancel" },
 64   { MBSaveDontSave,       "SaveDontSave" }, // maps to yes/no on win, to save/discard on mac.
 65   { MBSaveDontSaveCancel, "SaveDontSaveCancel" }, // maps to yes/no/cancel on win, to save/cancel/don'tsave on mac.
 66EndImplementEnumType;
 67
 68ImplementEnumType( MBIcons,
 69   "What icon to show on a message box.\n\n"
 70   "@ingroup Platform" )
 71   { MIInformation,        "Information" },// win: blue i, mac: app icon or talking head
 72   { MIWarning,            "Warning" },    // win & mac: yellow triangle with exclamation pt
 73   { MIStop,               "Stop" },       // win: red x, mac: app icon or stop icon, depending on version
 74   { MIQuestion,           "Question" },   // win: blue ?, mac: app icon
 75EndImplementEnumType;
 76
 77ImplementEnumType( MBReturnVal,
 78   "Return value for messageBox() indicating which button was pressed by the user.\n\n"
 79   "@ingroup Platform" )
 80   { MROk, "OK" },
 81   { MRCancel, "Cancelled" },
 82   { MRRetry, "Retry" },
 83   { MRDontSave, "DontSave" }
 84EndImplementEnumType;
 85
 86
 87//-----------------------------------------------------------------------------
 88
 89DefineEngineFunction( messageBox, S32, ( const char* title, const char* message, MBButtons buttons, MBIcons icons ), ( MBOkCancel, MIInformation ),
 90   "Display a modal message box using the platform's native message box implementation.\n\n"
 91   "@param title The title to display on the message box window.\n"
 92   "@param message The text message to display in the box.\n"
 93   "@param buttons Which buttons to put on the message box.\n"
 94   "@param icons Which icon to show next to the message.\n"
 95   "@return One of $MROK, $MRCancel, $MRRetry, and $MRDontSave identifying the button that the user pressed.\n"
 96   "@tsexample\n"
 97      "messageBox( \"Error\", \"\" );\n" //TODO
 98   "@endtsexample\n\n"
 99   "@ingroup Platform" )
100{
101   return Platform::messageBox( title, message, buttons, icons );
102}
103