svolbar.cpp 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #include <precomp.h>
  2. #include "svolbar.h"
  3. #include <api/core/api_core.h>
  4. const wchar_t volBarXuiStr[] = L"VolBar"; // This is the xml tag
  5. char volBarXuiSvcName[] = "VolBar xui object"; // this is the name of the xuiservice
  6. #define SVOLBAR_NOTIFY_MSG NUM_NOTIFY_MESSAGES+0x1000
  7. SVolBar::SVolBar() {
  8. setDrawOnBorders(TRUE);
  9. setEnable(TRUE);
  10. locked = 0;
  11. setLimits(0,255);
  12. }
  13. SVolBar::~SVolBar() {
  14. WASABI_API_MEDIACORE->core_delCallback(0, this);
  15. }
  16. int SVolBar::onInit() {
  17. SVOLBAR_PARENT::onInit();
  18. corecb_onVolumeChange(WASABI_API_MEDIACORE->core_getVolume(0));
  19. WASABI_API_MEDIACORE->core_addCallback(0, this);
  20. return 1;
  21. }
  22. int SVolBar::onSetPosition() {
  23. SVOLBAR_PARENT::onSetPosition();
  24. int pos = getSliderPosition(); // get slider pos
  25. WASABI_API_MEDIACORE->core_setVolume(0,pos);
  26. return 1;
  27. }
  28. int SVolBar::corecb_onVolumeChange(int newvol) {
  29. if (getSeekStatus()) return 0;
  30. setPosition(newvol, 0);
  31. onPostedPosition(newvol);
  32. return 0;
  33. }
  34. void SVolBar::lock() {
  35. if (locked) return;
  36. locked = 1;
  37. WASABI_API_MEDIACORE->core_delCallback(0, this);
  38. }
  39. void SVolBar::unlock() {
  40. if (!locked) return;
  41. locked = 0;
  42. WASABI_API_MEDIACORE->core_addCallback(0, this);
  43. }