2 Copyright 2005 Brian Walton
4 This file is part of VOMP.
6 VOMP 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.
11 VOMP 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.
16 You should have received a copy of the GNU General Public License
17 along with VOMP; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
26 WTextbox::WTextbox(const char* ttext):
27 foreColour(DrawStyle::LIGHTTEXT)
29 // int fontHeight = Surface::getFontHeight();
30 //setDimensions(70, fontHeight);
31 //setDimensions(100,100);
40 if (ttext) setText(ttext);
48 if (text) delete[] text;
51 void WTextbox::setParaMode(bool mode)
56 void WTextbox::setText(const char* takeText)
58 if (text) delete[] text;
59 int length = strlen(takeText);
60 text = new char[length + 1];
61 strcpy(text, takeText);
64 void WTextbox::setForegroundColour(const DrawStyle& fcolour)
74 if (paraMode) rem_scroll_line=drawPara(text, textX, textY, foreColour,cur_scroll_line);
75 else drawText(text, textX, textY, foreColour);
79 void WTextbox::setTextPos(int x, int y)
85 int WTextbox::handleCommand(int command)
92 if (cur_scroll_line > 0)
100 return 4; // Signal return control to parent
103 case Remote::DF_DOWN:
106 if (rem_scroll_line > 0)
117 case Remote::DF_LEFT:
118 case Remote::DF_RIGHT:
128 bool WTextbox::mouseAndroidScroll(int x, int y, int sx, int sy)
130 if ((x - getRootBoxOffsetX()) >= 0 && (y - getRootBoxOffsetY()) >= 0
131 && (x - getRootBoxOffsetX()) <= (int)area.w && (y - getRootBoxOffsetY()) <= (int)area.h )
133 int change = -sy /120;
135 int rel_change = min(cur_scroll_line, -change);
136 cur_scroll_line-=rel_change;
137 rem_scroll_line+=rel_change;
139 else if (change > 0) {
140 int rel_change = min(rem_scroll_line, change);
141 cur_scroll_line += rel_change;
142 rem_scroll_line -= rel_change;