OBUTT3D.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. /*
  2. * Seven Kingdoms: Ancient Adversaries
  3. *
  4. * Copyright 1997,1998 Enlight Software Ltd.
  5. *
  6. * This program is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. *
  19. */
  20. //Filename : OBUTT3D.H
  21. //Description : Header file of button object
  22. #ifndef __OBUTT3D_H
  23. #define __OBUTT3D_H
  24. //------- Define button type -------//
  25. enum { BUTTON_TYPE_SHELL, // use the button standard shells combining with bitmap for each button
  26. BUTTON_TYPE_BITMAP, // display the button using a single bitmap
  27. };
  28. //------- Define button styles -------//
  29. enum { BUTTON_STYLE_ACTION='A' }; // Action button
  30. enum { BUTTON_ACTION_WIDTH=52,
  31. BUTTON_ACTION_HEIGHT=43,
  32. };
  33. //------- Define class Button3D -------//
  34. class Button3D
  35. {
  36. public:
  37. enum { HELP_CODE_LEN=8 };
  38. char init_flag;
  39. short x1,y1,x2,y2; // some function will need to access the button's coordination for area detection
  40. char button_type;
  41. char button_style;
  42. char pushed_flag;
  43. char enable_flag; // either 1(Yes) or 0(No)
  44. char elastic_flag;
  45. unsigned short button_key; // button is pressed when user press this key
  46. char* icon_ptr; // can be a text pointer, bitmap pointer or a pointer to user defined function
  47. char* button_up_ptr;
  48. char* button_down_ptr;
  49. char* button_disabled_ptr;
  50. char help_code[HELP_CODE_LEN+1];
  51. public:
  52. Button3D();
  53. void create(int pX1, int pY1, char buttonStyle,
  54. char* buttonName, char elasticFlag=1, char defIsPushed=0);
  55. void create(int pX1, int pY1, char* upButtonName,
  56. char* downButtonName, char elasticFlag, char defIsPushed);
  57. void set_key(unsigned keyCode) { button_key = keyCode; }
  58. void paint(int pX1, int pY1, char buttonStyle,
  59. char* buttonName, char elasticFlag=1, char defIsPushed=0)
  60. { create( pX1, pY1, buttonStyle, buttonName, elasticFlag, defIsPushed ); paint(); }
  61. void paint(int pX1, int pY1, char* upButtonName,
  62. char* downButtonName, char elasticFlag=1, char defIsPushed=0)
  63. { create( pX1, pY1, upButtonName, downButtonName, elasticFlag, defIsPushed ); paint(); }
  64. void paint(int defIsPushed= -1);
  65. void set_help_code(char* helpCode);
  66. void update_bitmap(char* buttonName);
  67. void reset() { init_flag=0; }
  68. void hide();
  69. int detect(unsigned=0,unsigned=0,int=0,int=0);
  70. void push() { if(!pushed_flag) paint(1); }
  71. void pop() { if(pushed_flag) paint(0); }
  72. void disable() { if(enable_flag) { enable_flag=0; paint(); } }
  73. void enable() { if(!enable_flag) { enable_flag=1; paint(); } }
  74. };
  75. //-------------------------------------------------//
  76. #endif