Torque3D Documentation / _generateds / x86UNIXMessageBox.h

x86UNIXMessageBox.h

Engine/source/platformX86UNIX/x86UNIXMessageBox.h

More...

Classes:

Detailed Description

  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#ifndef _X86UNIXMESSAGEBOX_H_
 25#define _X86UNIXMESSAGEBOX_H_
 26
 27#include <X11/Xlib.h>
 28#include "core/util/tVector.h"
 29
 30class XMessageBoxButton
 31{
 32   public:
 33      XMessageBoxButton();
 34      XMessageBoxButton(const char* label, int clickVal);
 35
 36      const char *getLabel() { return static_cast<const char*>(mLabel); }
 37      int getClickVal() { return mClickVal; }
 38
 39      int getLabelWidth() { return mLabelWidth; }
 40      void setLabelWidth(int width) { mLabelWidth = width; }
 41
 42      void setButtonRect(int x, int y, int width, int height)
 43      {
 44         mX = x;
 45         mY = y;
 46         mWidth = width;
 47         mHeight = height;
 48      }
 49      void setMouseCoordinates(int x, int y)
 50      {
 51         mMouseX = x;
 52         mMouseY = y;
 53      }
 54
 55      bool drawReverse()
 56      {
 57         return mMouseDown && pointInRect(mMouseX, mMouseY);
 58      }
 59
 60      bool pointInRect(int x, int y)
 61      {
 62         if (x >= mX && x <= (mX+mWidth) &&
 63            y >= mY && y <= (mY+mHeight))
 64            return true;
 65         return false;
 66      }
 67
 68      void setMouseDown(bool mouseDown) { mMouseDown = mouseDown; }
 69      bool isMouseDown() { return mMouseDown; }
 70
 71   private:
 72      static const int LabelSize = 100;
 73      char mLabel[LabelSize];
 74      int mClickVal;
 75      int mLabelWidth;
 76      int mX, mY, mWidth, mHeight;
 77      int mMouseX, mMouseY;
 78      bool mMouseDown;
 79};
 80
 81class XMessageBox
 82{
 83   public:
 84      static const int OK = 1;
 85      static const int Cancel = 2;
 86      static const int Retry = 3;
 87      static const int IgnoreAll = 4;
 88
 89      XMessageBox(Display* display);
 90      ~XMessageBox();
 91
 92      int alertOK(const char *windowTitle, const char *message);
 93      int alertOKCancel(const char *windowTitle, const char *message);
 94      int alertRetryCancel(const char *windowTitle, const char *message);
 95      int alertAssert(const char *windowTitle, const char *message);
 96   private:
 97      int show();
 98      void repaint();
 99      void splitMessage();
100      void clearMessageLines();
101      int loadFont();
102      void setDimensions();
103      int getButtonLineWidth();
104
105      const char* mMessage;
106      const char* mTitle;
107      Vector<XMessageBoxButton> mButtons;
108      Vector<char*> mMessageLines;
109
110      Display* mDisplay;
111      GC mGC;
112      Window mWin;
113      XFontStruct* mFS;
114      int mFontHeight;
115      int mFontAscent;
116      int mFontDescent;
117      int mFontDirection;
118
119      int mScreenWidth, mScreenHeight, mMaxWindowWidth, mMaxWindowHeight;
120      int mMBWidth, mMBHeight;
121};
122
123#endif // #define _X86UNIXMESSAGEBOX_H_
124