00001 #ifndef CAMENU_H 00002 #define CAMENU_H 00003 00004 #include <ClanLib/core.h> 00005 #include <ClanLib/display.h> 00006 00007 #include "camath.h" 00008 #include "camenuitem.h" 00009 #include "cascreen.h" 00010 00014 class CAMenu : public CAScreen { 00015 public: 00016 CAMenu( const char* title ); 00017 ~CAMenu(); 00018 00019 virtual int run(); 00020 virtual void buildScreen(); 00021 00022 void addMenuLabel( const char* label ); 00023 void addMenuInput( const char* label, char* result, int maxLength ); 00024 void addMenuInput( const char* label, int* result, int maxLength ); 00025 void addMenuSelect( const char* label, const char* valueList, int* result ); 00026 void addMenuSelect( const char* label, const char* valueList, bool* result ); 00027 00028 void calcMenuDimensions(); 00029 00030 virtual void on_button_press(CL_InputDevice *device, const CL_Key &key ); 00031 00033 int getLeft() { 00034 return left; 00035 } 00037 int getRight() { 00038 return right; 00039 } 00041 int getTop() { 00042 return top; 00043 } 00045 int getBottom() { 00046 return bottom; 00047 } 00048 00050 int getWidth() { 00051 return width; 00052 } 00054 int getHeight() { 00055 return height; 00056 } 00057 00059 int getItemHeight() { 00060 return itemHeight; 00061 } 00063 int getHeaderHeight() { 00064 return headerHeight; 00065 } 00066 00070 void setConfigureMenu( bool on ) { 00071 configureMenu = on; 00072 } 00074 void setChanged( bool on=true ) { 00075 changed = on; 00076 } 00078 void setCursor( int pos ) { 00079 if( cursor>=0 && cursor<numItems ) cursor = pos; 00080 } 00082 int getCursor() { 00083 return cursor; 00084 } 00086 int getSelection() { 00087 return (cancel ? -1 : cursor); 00088 } 00089 00090 protected: 00092 00093 bool changed; 00095 int left; 00097 int right; 00099 int top; 00101 int bottom; 00103 int width; 00105 int height; 00107 int itemHeight; 00109 int headerHeight; 00110 00112 CAMenuItem* item[CA_MAXMENUITEMS]; 00114 CL_String title; 00116 int numItems; 00117 00119 int cursor; 00121 bool configureMenu; 00122 00123 CL_Slot slot; 00124 00125 }; 00126 00127 #endif
1.5.0