llcurrencyuimanager.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /**
  2. * @file llcurrencyuimanager.h
  3. * @brief LLCurrencyUIManager class definition
  4. *
  5. * $LicenseInfo:firstyear=2006&license=viewergpl$
  6. *
  7. * Copyright (c) 2006-2009, Linden Research, Inc.
  8. *
  9. * Second Life Viewer Source Code
  10. * The source code in this file ("Source Code") is provided by Linden Lab
  11. * to you under the terms of the GNU General Public License, version 2.0
  12. * ("GPL"), unless you have obtained a separate licensing agreement
  13. * ("Other License"), formally executed by you and Linden Lab. Terms of
  14. * the GPL can be found in doc/GPL-license.txt in this distribution, or
  15. * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
  16. *
  17. * There are special exceptions to the terms and conditions of the GPL as
  18. * it is applied to this Source Code. View the full text of the exception
  19. * in the file doc/FLOSS-exception.txt in this software distribution, or
  20. * online at
  21. * http://secondlifegrid.net/programs/open_source/licensing/flossexception
  22. *
  23. * By copying, modifying or distributing this software, you acknowledge
  24. * that you have read and understood your obligations described above,
  25. * and agree to abide by those obligations.
  26. *
  27. * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
  28. * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
  29. * COMPLETENESS OR PERFORMANCE.
  30. * $/LicenseInfo$
  31. */
  32. #ifndef LL_LLCURRENCYUIMANAGER_H
  33. #define LL_LLCURRENCYUIMANAGER_H
  34. class LLPanel;
  35. // Manages the currency purchase portion of any dialog takes control of, and
  36. // assumes repsonsibility for several fields:
  37. // - 'currency_action': the text "Buy L$" before the entry field.
  38. // - 'currency_amt': the line editor for the entry amount.
  39. // - 'currency_est': the estimated cost from the web site.
  40. class LLCurrencyUIManager
  41. {
  42. public:
  43. LLCurrencyUIManager(LLPanel& parent);
  44. virtual ~LLCurrencyUIManager();
  45. // The amount in L$ to purchase; setting it overwrites the user's entry
  46. // if no_estimate is true, then no web request is made.
  47. void setAmount(S32 amount, bool no_estimate = false);
  48. S32 getAmount();
  49. // Sets the gray message to show when zero
  50. void setZeroMessage(const std::string& message);
  51. // The amount in US$ * 100 (in otherwords, in cents).
  52. void setUSDEstimate(S32 amount);
  53. // Use set when you get this information from elsewhere.
  54. S32 getUSDEstimate();
  55. // The estimated cost in the user's local currency, for example,
  56. // "US$ 10.00" or "10.00 Euros".
  57. void setLocalEstimate(const std::string& local_est);
  58. std::string getLocalEstimate() const;
  59. // Call once after dialog is built, from postBuild()
  60. void prepare();
  61. // Updates all UI elements, if show is false, they are all set not visible.
  62. // Normally, this is done automatically, but you can force it. The show/
  63. // hidden state is remembered.
  64. void updateUI(bool show = true);
  65. // Call periodically, for example, from draw(). Returns true if the UI
  66. // needs to be updated
  67. bool process();
  68. // Call to initiate the purchase
  69. void buy(const std::string& buy_msg);
  70. bool inProcess(); // Is a transaction in process ?
  71. bool canCancel(); // Can we cancel it (by destructing this object) ?
  72. bool canBuy(); // Can the user choose to buy now ?
  73. bool buying(); // Are we in the process of buying ?
  74. bool bought(); // Did the buy() transaction complete successfully ?
  75. void clearError();
  76. bool hasError();
  77. std::string errorMessage();
  78. // Error information for the user, the URI may be blank the technical
  79. // error details will have already been logged
  80. std::string errorURI();
  81. private:
  82. class Impl;
  83. Impl& impl;
  84. };
  85. #endif // LL_LLCURRENCYUIMANAGER_H