UIEditField.cpp 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. #include <TurboBadger/tb_widgets.h>
  2. #include <TurboBadger/tb_widgets_common.h>
  3. #include <TurboBadger/tb_editfield.h>
  4. #include "UIEvents.h"
  5. #include "UIEditField.h"
  6. using namespace tb;
  7. namespace Atomic
  8. {
  9. UIEditField::UIEditField(Context* context, bool createWidget) : UIWidget(context, false)
  10. {
  11. if (createWidget)
  12. {
  13. widget_ = new TBEditField();
  14. widget_->SetDelegate(this);
  15. }
  16. }
  17. UIEditField::~UIEditField()
  18. {
  19. }
  20. void UIEditField::SetWrapping(bool wrap)
  21. {
  22. if (!widget_)
  23. return;
  24. TBEditField* w = (TBEditField*) widget_;
  25. w->SetWrapping(wrap);
  26. }
  27. bool UIEditField::GetWrapping()
  28. {
  29. if (!widget_)
  30. return false;
  31. TBEditField* w = (TBEditField*) widget_;
  32. return w->GetWrapping();
  33. }
  34. void UIEditField::SetTextAlign(TEXT_ALIGN align)
  35. {
  36. if (!widget_)
  37. return;
  38. // safe cast?
  39. TBEditField* w = (TBEditField*) widget_;
  40. switch (align)
  41. {
  42. case TEXT_ALIGN_CENTER:
  43. w->SetTextAlign(TB_TEXT_ALIGN_CENTER);
  44. break;
  45. case TEXT_ALIGN_LEFT:
  46. w->SetTextAlign(TB_TEXT_ALIGN_LEFT);
  47. break;
  48. case TEXT_ALIGN_RIGHT:
  49. w->SetTextAlign(TB_TEXT_ALIGN_RIGHT);
  50. break;
  51. }
  52. }
  53. bool UIEditField::OnEvent(const tb::TBWidgetEvent &ev)
  54. {
  55. return false;
  56. }
  57. }