Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Namespace Members | Compound Members | File Members

MouseState.h

Go to the documentation of this file.
00001 //------------------------------------------------------------------------------
00002 // Lamp : Open source game middleware
00003 // Copyright (C) 2004  Junpei Ohtani ( Email : junpee@users.sourceforge.jp )
00004 //
00005 // This library is free software; you can redistribute it and/or
00006 // modify it under the terms of the GNU Lesser General Public
00007 // License as published by the Free Software Foundation; either
00008 // version 2.1 of the License, or (at your option) any later version.
00009 //
00010 // This library is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013 // Lesser General Public License for more details.
00014 //
00015 // You should have received a copy of the GNU Lesser General Public
00016 // License along with this library; if not, write to the Free Software
00017 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018 //------------------------------------------------------------------------------
00019 
00020 /** @file
00021  * マウスステートヘッダ
00022  * @author Junpee
00023  */
00024 
00025 #ifndef MOUSE_STATE_H_
00026 #define MOUSE_STATE_H_
00027 
00028 namespace Lamp{
00029 
00030 class BinaryWriter;
00031 class BinaryReader;
00032 
00033 //------------------------------------------------------------------------------
00034 /**
00035  * マウスステート
00036  */
00037 class MouseState{
00038 friend class MouseDevice;
00039 public:
00040     /// 最大ボタン数
00041     static const int maxButtonCount = 8;
00042 
00043     //--------------------------------------------------------------------------
00044     /**
00045      * コンストラクタ
00046      */
00047     MouseState(){ clear(); }
00048 
00049     /**
00050      * デストラクタ
00051      */
00052     virtual ~MouseState(){}
00053 
00054     /**
00055      * クリア
00056      */
00057     virtual void clear(){
00058         xAxis_ = yAxis_ = zAxis_ = 0;
00059         for(int i = 0; i < maxButtonCount; i++){ buttons_[i] = false; }
00060     }
00061 
00062     //--------------------------------------------------------------------------
00063     /**
00064      * X軸の設定
00065      * @param xAxis X軸
00066      */
00067     virtual void setXAxis(int xAxis){ xAxis_ = xAxis; }
00068 
00069     /**
00070      * X軸の取得
00071      * @return X軸
00072      */
00073     virtual int getXAxis() const{ return xAxis_; }
00074 
00075     /**
00076      * Y軸の設定
00077      * @param yAxis Y軸
00078      */
00079     virtual void setYAxis(int yAxis){ yAxis_ = yAxis; }
00080 
00081     /**
00082      * Y軸の取得
00083      * @return Y軸
00084      */
00085     virtual int getYAxis() const{ return yAxis_; }
00086 
00087     /**
00088      * Z軸の設定
00089      * @param zAxis Z軸
00090      */
00091     virtual void setZAxis(int zAxis){ zAxis_ = zAxis; }
00092 
00093     /**
00094      * Z軸の取得
00095      * @return Z軸
00096      */
00097     virtual int getZAxis() const{ return zAxis_; }
00098 
00099     //--------------------------------------------------------------------------
00100     /**
00101      * ボタンの設定
00102      * @param id 対象ボタンID
00103      * @param pressed trueなら押されている
00104      */
00105     virtual void setButtonPressed(int id, bool pressed){
00106         Assert((id >= 0) && (id < maxButtonCount));
00107         buttons_[id] = pressed;
00108     }
00109 
00110     /**
00111      * ボタンが押されているか
00112      * @param id 対象ボタンID
00113      * @return ボタンが押されていればtrue
00114      */
00115     virtual bool buttonPressed(int id) const{
00116         Assert((id >= 0) && (id < maxButtonCount));
00117         return buttons_[id];
00118     }
00119 
00120     //--------------------------------------------------------------------------
00121     /**
00122      * 文字列への変換
00123      * @return 文字列
00124      */
00125     virtual String toString() const{
00126         String result;
00127         result.format("( X = %4d , Y = %4d , Z = %4d )\n"
00128             "Press       %d %d %d %d %d %d %d %d\n",
00129             getXAxis(), getYAxis(), getZAxis(),
00130             buttonPressed(0), buttonPressed(1), buttonPressed(2),
00131             buttonPressed(3), buttonPressed(4), buttonPressed(5), 
00132             buttonPressed(6), buttonPressed(7));
00133         return result;
00134     }
00135 
00136     //--------------------------------------------------------------------------
00137     /**
00138      * バイナリ書き出し
00139      * @param binaryWriter バイナリライタ
00140      */
00141     virtual void writeBinary(BinaryWriter* binaryWriter) const;
00142 
00143     /**
00144      * バイナリ読み込み
00145      * @param binaryReader バイナリリーダ
00146      */
00147     virtual void readBinary(BinaryReader* binaryReader);
00148 
00149     //--------------------------------------------------------------------------
00150 private:
00151     // X軸
00152     int xAxis_;
00153     // Y軸
00154     int yAxis_;
00155     // Z軸
00156     int zAxis_;
00157     // ボタンデータ
00158     bool buttons_[maxButtonCount];
00159 };
00160 
00161 //------------------------------------------------------------------------------
00162 } // End of namespace Lamp
00163 #endif // End of _H_
00164 //------------------------------------------------------------------------------
00165 

Generated on Wed Mar 16 10:29:33 2005 for Lamp by doxygen 1.3.2