Board game like Abalone for AmigaOS
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

StatusWin.cpp 5.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. /*
  2. * This file is part of Abacus.
  3. * Copyright (C) 1997 Kai Nickel
  4. *
  5. * Abacus is free software: you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation, either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * Abacus is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with Abacus. If not, see <http://www.gnu.org/licenses/>.
  17. *
  18. */
  19. /****************************************************************************************
  20. StatusWin.cpp
  21. -----------------------------------------------------------------------------------------
  22. -----------------------------------------------------------------------------------------
  23. 29.12.1996
  24. ****************************************************************************************/
  25. #include "StatusWin.hpp"
  26. #include "Tools.hpp"
  27. #include "MCC.hpp"
  28. #include "Images.hpp"
  29. #include "images/IMG_Time.c"
  30. struct MUI_CustomClass *CL_StatusWin;
  31. /****************************************************************************************
  32. StatusWin_Status
  33. ****************************************************************************************/
  34. StatusWin_Status::StatusWin_Status(Object* appl, Object* refwin)
  35. {
  36. app = appl;
  37. swin = (Object*)NewObject(CL_StatusWin->mcc_Class, NULL,
  38. MUIA_Window_RefWindow , refwin,
  39. TAG_DONE);
  40. if (!swin)
  41. {
  42. //ShowError(app, NULL, "Could not create MUI window!");
  43. return;
  44. }
  45. data = (StatusWin_Data*)INST_DATA(CL_StatusWin->mcc_Class, swin);
  46. err = 0;
  47. DoMethod(app, OM_ADDMEMBER, swin);
  48. };
  49. StatusWin_Status::~StatusWin_Status()
  50. {
  51. DoMethod(app, OM_REMMEMBER, swin);
  52. DisposeObject(swin);
  53. }
  54. void StatusWin_Status::Init()
  55. {
  56. setatt(swin, MUIA_Window_Open, TRUE);
  57. }
  58. void StatusWin_Status::Exit()
  59. {
  60. setatt(swin, MUIA_Window_Open, FALSE);
  61. }
  62. void StatusWin_Status::Update(int done, int max)
  63. {
  64. if (done != -1)
  65. {
  66. setatt(data->GA_Status, MUIA_Gauge_Current, done);
  67. if (max != -1)
  68. {
  69. setatt(data->GA_Status, MUIA_Disabled, FALSE);
  70. setatt(data->GA_Status, MUIA_Gauge_Max, max);
  71. }
  72. }
  73. else
  74. setatt(data->GA_Status, MUIA_Disabled, TRUE);
  75. }
  76. BOOL StatusWin_Status::Break()
  77. {
  78. if (err != 0) return TRUE;
  79. ULONG sigs = 0;
  80. DoMethod(app, MUIM_Application_NewInput, &sigs);
  81. return !data->running;
  82. }
  83. void StatusWin_Status::SetInfo(int txt)
  84. {
  85. setatt(data->GA_Status, MUIA_Gauge_InfoText, GetStr(txt));
  86. }
  87. /****************************************************************************************
  88. Break
  89. ****************************************************************************************/
  90. ULONG StatusWin_Break(struct IClass* cl, Object* obj, Msg msg)
  91. {
  92. struct StatusWin_Data* data = (StatusWin_Data*)INST_DATA(cl, obj);
  93. data->running = FALSE;
  94. return 0;
  95. }
  96. /****************************************************************************************
  97. New
  98. ****************************************************************************************/
  99. ULONG StatusWin_New(struct IClass* cl, Object* obj, struct opSet* msg)
  100. {
  101. StatusWin_Data tmp;
  102. Object* BT_Stop;
  103. obj = (Object*)DoSuperNew(cl, obj,
  104. MUIA_Window_LeftEdge , MUIV_Window_LeftEdge_Centered,
  105. MUIA_Window_TopEdge , MUIV_Window_TopEdge_Centered,
  106. MUIA_Window_Width , MUIV_Window_Width_Visible(30),
  107. MUIA_Window_CloseGadget, FALSE,
  108. MUIA_Window_DepthGadget, FALSE,
  109. MUIA_Window_SizeGadget , FALSE,
  110. MUIA_Window_DragBar , FALSE,
  111. MUIA_Window_Borderless , TRUE,
  112. WindowContents, VGroup, ButtonFrame,
  113. Child, HGroup,
  114. Child, MakeImage(IMG_Time_body, IMG_TIME_WIDTH, IMG_TIME_HEIGHT,
  115. IMG_TIME_DEPTH, IMG_TIME_COMPRESSION, IMG_TIME_MASKING,
  116. IMG_Save_colors),
  117. Child, HVSpace,
  118. Child, BT_Stop = MUI_MakeObject(MUIO_Button, "Stop"),
  119. End,
  120. Child, tmp.GA_Status = GaugeObject,
  121. GaugeFrame,
  122. MUIA_Gauge_Horiz , TRUE,
  123. MUIA_Gauge_InfoText, "",
  124. End,
  125. Child, ScaleObject, End,
  126. /*
  127. Child, HGroup,
  128. Child, HVSpace,
  129. Child, BT_Stop = MUI_MakeObject(MUIO_Button, "Stop"),
  130. Child, HVSpace,
  131. End,
  132. */
  133. End,
  134. TAG_MORE, msg->ops_AttrList);
  135. if (obj)
  136. {
  137. DoMethod(BT_Stop , MUIM_Notify, MUIA_Pressed, FALSE, obj, 1, MUIM_StatusWin_Break);
  138. struct StatusWin_Data* data = (StatusWin_Data*)INST_DATA(cl, obj);
  139. *data = tmp;
  140. data->running = TRUE;
  141. return (ULONG)obj;
  142. }
  143. return 0;
  144. }
  145. /****************************************************************************************
  146. Dispatcher
  147. ****************************************************************************************/
  148. SAVEDS ASM ULONG StatusWin_Dispatcher(REG(a0) struct IClass* cl, REG(a2) Object* obj, REG(a1) Msg msg)
  149. {
  150. switch(msg->MethodID)
  151. {
  152. case OM_NEW : return(StatusWin_New (cl, obj, (opSet*)msg));
  153. case MUIM_StatusWin_Break: return(StatusWin_Break (cl, obj, msg));
  154. }
  155. return DoSuperMethodA(cl, obj, msg);
  156. }