AbstractUserDialog.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. /******************************************************************************
  2. |* THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
  3. |* ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
  4. |* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
  5. |* PARTICULAR PURPOSE.
  6. |*
  7. |* Copyright 1995-2005 Nero AG. All Rights Reserved.
  8. |*-----------------------------------------------------------------------------
  9. |* NeroSDK / NeroRobo
  10. |*
  11. |* PROGRAM: AbstractUserDialog.h
  12. |*
  13. |* PURPOSE: Interface for GUI
  14. ******************************************************************************/
  15. /* This file defines an abstract way to represent a dialog with an interface exported to e.g. a DLL
  16. * or a separate thread. */
  17. #ifndef ABSTRACTUSERDIALOG_H
  18. #define ABSTRACTUSERDIALOG_H
  19. #include <windows.h>
  20. #include "AbstractConfigurationStorage.h"
  21. /* Event received through the watchdog when dialog is closed */
  22. #define ABSTRACTUSERDIALOG_CANCEL "CANCEL"
  23. class CUserDialogHandle
  24. {
  25. public:
  26. /* Feed back enums returned by the dialog on special user action. */
  27. typedef enum
  28. {
  29. DLGRESULT_OK,
  30. DLGRESULT_CANCEL,
  31. DLGRESULT_NONE // no user feedback received
  32. }
  33. UserDlgFeedbackType;
  34. /* Waits for the user to answer the dialog. */
  35. virtual void WaitForUserFeedback() = 0;
  36. /* Retrieve feedback. Will return the type of button the user has pressed to quit the dialog.
  37. * Querying this method should be enough for most dialogs. However, if additional informations
  38. * are obtained from the user, GetFeedbackData() can be used to return those. */
  39. virtual UserDlgFeedbackType GetFeedback() = 0;
  40. /* Get the result of the dialog. Depending on the kind of dialog this handle is associated with
  41. * this may e.g. return a string or a filename.
  42. * The default implementation of this method will just return NULL. */
  43. virtual const char *GetFeedbackData() { return NULL; };
  44. /* Close the dialog and destroy it's handle */
  45. virtual ~CUserDialogHandle() {};
  46. };
  47. class IUserDialogContainer;
  48. /* Interface enabling limited manipulation of dialog elemnts. */
  49. class IUserDialogElement
  50. {
  51. public:
  52. /* Show (bShow = TRUE) and hide (bShow = FALSE) current dialog element respectively. */
  53. virtual void SetShow(BOOL bShow) = 0;
  54. /* Enable (bSensitive = TRUE) and hide (bSensitive = FALSE) current dialog element respectively. */
  55. virtual void SetSensitive(BOOL bSensitive) = 0;
  56. virtual ~IUserDialogElement() {};
  57. /* Called by the container to set the position of dialog element. */
  58. virtual void SetPosition(int xpos, int ypos) = 0;
  59. /* Retrieve the size of dialog element. */
  60. virtual void GetSize(int &iXSize, int &iYSize) const = 0;
  61. };
  62. class IUserDialogContainer
  63. :public IUserDialogElement
  64. {
  65. public:
  66. /* Options valid for every container element */
  67. #define DE_OPTION_ALIGN_LEFT 0
  68. #define DE_OPTION_ALIGN_RIGHT 1
  69. #define DE_OPTION_ALIGN_CENTER 3
  70. /* Factory methods for some controls. */
  71. virtual IUserDialogElement *CreateCheckBox(DWORD dwOptions, const char *szName, const char *szText, BOOL bDefaultState = FALSE) = 0;
  72. virtual IUserDialogElement *CreatePushButton(int iMinXsize, int iMinYsize, DWORD dwOptions, const char *szName, const char *szText) = 0;
  73. virtual IUserDialogContainer *CreateHBox(DWORD dwOptions = 0) = 0;
  74. virtual IUserDialogContainer *CreateVBox(DWORD dwOptions = 0) = 0;
  75. virtual ~IUserDialogContainer() {};
  76. /* Called by a child to notify the parent about a size change */
  77. virtual void SizeChanged(IUserDialogElement *pElement) = 0;
  78. /* Called by a child's destructor */
  79. virtual void Unref(IUserDialogElement *pElement) = 0;
  80. };
  81. class IUserDialog
  82. :public IUserDialogContainer
  83. {
  84. public:
  85. /* Call this from within a watchdog callback to quit the dialog */
  86. virtual void Quit() = 0;
  87. /* Call this to execute the dialog */
  88. virtual void Exec() = 0;
  89. virtual ~IUserDialog() {};
  90. };
  91. class IUserDialogFactory
  92. :virtual public IConfigurationStorage
  93. {
  94. public:
  95. /* Create a dialog. The dialog is being shown immediately with szTitle and allign options
  96. * specified in IUserDialogContainer. Default all dialog elements are left alligned. */
  97. virtual IUserDialog *CreateUserDialog(const char *szTitle, DWORD dwOptions = 0) = 0;
  98. /* This method can be used to estimate current Nero language to localize special driver
  99. * messages. */
  100. virtual const char *GetCurrentLanguage() = 0;
  101. /* Return the currently set OEM name for some device given in szTemplateName.
  102. * If no matching OEM substitution could be found, return szTemplateName. */
  103. virtual const char *GetOEMName(const char *szTemplateName) = 0;
  104. /* Create simple message box which can only be confirmed by the user. */
  105. virtual CUserDialogHandle::UserDlgFeedbackType CreateMessageBox(const char *szText) = 0;
  106. virtual ~IUserDialogFactory() {};
  107. };
  108. #endif // ABSTRACTUSERDIALOG_H