39   template <u32 COLUMNS, u32 LINES>
 
   47       SetName(
"Text Panel");
 
   48       SetRenderPoint(
SPoint(0, 0));
 
   53       m_bottomLineShown = 0;
 
   69       SDL_MouseButtonEvent & 
event = mbe.m_event.button;
 
   70       if(event.type == SDL_MOUSEBUTTONDOWN) {
 
   76         switch (event.button) {
 
   79           if (pt.
GetX() < (s32) ELEVATOR_WIDTH) {
 
   80             m_leftButtonDragStart = 
SPoint(event.x,event.y);
 
   81             m_dragStartElevatorBottom = m_elevatorBottom;
 
   85         case SDL_BUTTON_WHEELUP:
 
   86         case SDL_BUTTON_WHEELDOWN:
 
   87           s32 dir = 
event.button == SDL_BUTTON_WHEELDOWN ? -1 : 1;
 
   88           if (mbe.m_keyboard.ShiftHeld()) dir *= 10;
 
   90           m_bottomLineShown = MAX<s32>(0, MIN<s32>(m_bottomLineShown + dir, m_text.
GetLines()));
 
  100       SDL_MouseMotionEvent & 
event = mbe.m_event.motion;
 
  104              event.y - pt.
GetY());
 
  106       if ((pt.
GetX() < (s32) ELEVATOR_WIDTH) &&
 
  107           (mbe.m_buttonMask & (1 << SDL_BUTTON_LEFT)) !=0) {
 
  108         SPoint nowAt(event.x, event.y);
 
  109         s32 deltay = nowAt.
GetY() - m_leftButtonDragStart.
GetY();
 
  110         m_bottomLineShown = ElevatorBottomToBottomLine(m_dragStartElevatorBottom + deltay);
 
  118     static const u32 ELEVATOR_WIDTH = 12;
 
  119     static const u32 ELEVATOR_COLOR = 0xff007f00;
 
  122     u32 m_bottomLineShown;
 
  123     u32 m_lastBytesWritten;
 
  125     SPoint m_leftButtonDragStart;
 
  126     u32 m_dragStartElevatorBottom;
 
  133     u32 m_elevatorBottom;
 
  134     u32 m_elevatorHeight;
 
  138     s32 ElevatorBottomToBottomLine(s32 newElevatorBottom) {
 
  140       newElevatorBottom = MAX<s32>(0, MIN<s32>(newElevatorBottom, m_panelHeight - m_elevatorHeight));
 
  142       s32 newBot = m_textLines - newElevatorBottom * m_textLines / m_elevatorRange;
 
  143       return MAX<s32>(0, MIN<s32>(newBot, m_text.
GetLines()));
 
  146     void RenderText(Drawing & drawing)
 
  148       m_panelHeight = GetHeight();
 
  149       if (m_panelHeight == 0)
 
  152       TTF_Font * font = drawing.GetFont();
 
  155       m_fontHeight = TTF_FontLineSkip(font);
 
  156       if (m_fontHeight == 0)
 
  161       m_neededHeight = m_textLines * m_fontHeight;
 
  163       m_elevatorHeight = m_panelHeight;
 
  164       if (m_neededHeight > m_panelHeight)
 
  165         m_elevatorHeight = m_panelHeight * m_panelHeight / m_neededHeight;
 
  172         m_bottomLineShown = 0;
 
  175       m_elevatorRange = m_panelHeight - m_elevatorHeight;
 
  176       m_elevatorBottom = m_elevatorRange * (m_textLines - m_bottomLineShown) / m_textLines;
 
  178       drawing.FillRect(1, m_elevatorBottom, ELEVATOR_WIDTH-2, m_elevatorHeight, ELEVATOR_COLOR);
 
  180       s32 y = m_panelHeight;
 
  181       for (s32 line = m_textLines - m_bottomLineShown - 1; line >= 0; --line) {
 
  184           printf(
"WTF %d\n", line);
 
  186         drawing.BlitText(zline, UPoint(ELEVATOR_WIDTH, y), UPoint(GetWidth(), m_fontHeight));
 
virtual bool Handle(MouseButtonEvent &mbe)
Definition: TextPanel.h:67
 
u32 GetLines() const 
Definition: LineTailByteSink.h:123
 
u32 SetBorder(const u32 color)
Definition: Panel.h:238
 
u32 SetForeground(const u32 color)
Definition: Panel.h:256
 
void Set(T x, T y)
Definition: Point.tcc:183
 
T GetY() const 
Definition: Point.tcc:40
 
SPoint GetAbsoluteLocation()
Definition: Panel.cpp:173
 
virtual void PaintComponent(Drawing &config)
Definition: Panel.cpp:230
 
Definition: ByteSink.h:47
 
u32 GetBytesWritten() const 
Definition: LineTailByteSink.h:111
 
const char * GetZString(u32 whichLine)
Definition: LineTailByteSink.h:143
 
virtual void PaintComponent(Drawing &drawing)
Definition: TextPanel.h:61
 
virtual bool Handle(MouseMotionEvent &mbe)
Definition: TextPanel.h:98
 
Definition: TextPanel.h:40
 
u32 SetBackground(const u32 color)
Definition: Panel.h:220
 
T GetX() const 
Definition: Point.tcc:34