#include <CSTextarea.h>
Inheritance diagram for CSTextarea:
Public Member Functions | |
CSTextarea (int height, int width) | |
virtual | ~CSTextarea () |
virtual std::string | getType () |
virtual void | setText (const std::string text) |
virtual void | setText (const CSStringlist &lines) |
virtual void | setMultiLineText (const std::string text) |
void | reactOnMessageTextarea (CSMessage *message) |
virtual void | reactOnMessage (CSMessage *message) |
to be overloaded | |
void | setEditable (bool b) |
virtual void | paint (SDL_Surface *destination, SDL_Rect *parentViewport) |
virtual void | putString (SDL_Surface *destination, SDL_Rect *viewport, int x, int y, const std::string &string) |
coordinates relativ to this element | |
virtual void | layoutSetup () |
Static Public Attributes | |
const char * | CLASS = "CSTextarea" |
static element, name of this class (introsepection) | |
Protected Member Functions | |
void | layoutSetupTextarea () |
|
Definition at line 13 of file CSTextarea.cpp. References CSGrafikElement::init(), LOG_ENTER, and LOG_EXIT.
00013 : CSGrafikElement(height, width) 00014 { 00015 static char *functionName="CSTextarea"; 00016 LOG_ENTER 00017 init(""); 00018 LOG_EXIT 00019 } |
Here is the call graph for this function:
|
Definition at line 57 of file CSTextarea.h.
00057 {} |
|
Definition at line 515 of file CSTextarea.cpp. References CSGrafikElement::getBorder(), CSLAF::getCurrentLAF(), CSGrafikElement::getInset(), CSInset::getTotalHeight(), CSBorder::getTotalHeight(), CSInset::getTotalWidth(), CSBorder::getTotalWidth(), LOG_ENTER, and LOG_EXIT. Referenced by layoutSetup().
00516 { 00517 static char *functionName="layoutSetupTextarea"; 00518 LOG_ENTER 00519 CSLAF *laf = CSLAF::getCurrentLAF(); 00520 mMinHeight = mHeight - getBorder()->getTotalHeight() - getInset().getTotalHeight(); 00521 mMinWidth = mWidth - getBorder()->getTotalWidth() - getInset().getTotalWidth(); 00522 00523 LOG_EXIT 00524 } |
Here is the call graph for this function:
|
Reimplemented from CSGrafikElement. Definition at line 59 of file CSTextarea.h. References CLASS.
00059 {return (std::string) CLASS;} |
|
Definition at line 50 of file CSTextarea.cpp.
00051 { 00052 static char *functionName="setText"; 00053 mString = text; 00054 buildLines(); 00055 } |
|
Definition at line 62 of file CSTextarea.h.
00062 {mLines = lines;} |
|
Definition at line 65 of file CSTextarea.h. References CSStringlist::add(), and CSStringlist::clear(). Referenced by CSMessageBox::rebuildElement().
00066 { 00067 mLines.clear(); 00068 char *copy = strdup(text.c_str()); 00069 char *tmp = copy; 00070 00071 char *pointerToWord = strtok( copy, "\n"); 00072 while (pointerToWord != 0) 00073 { 00074 mLines.add(std::string(pointerToWord)); 00075 pointerToWord = strtok( 0, " \n\t"); 00076 } 00077 free(tmp); 00078 } |
Here is the call graph for this function:
|
Definition at line 314 of file CSTextarea.cpp. References FOCUS_GAINED_MESSAGE, FOCUS_LOST_MESSAGE, CSDesktop::focusedNextComponent(), CSGrafikElement::getDesktop(), CSStringlist::getSize(), CSStringlist::getString(), CSMessage::getSubtype(), CSMessage::getType(), GUI_MESSAGE, CSStringlist::insert(), KEY_PRESSED_MESSAGE, KEY_RELEASED_MESSAGE, GuiMessage::keySymbolic, GuiMessage::keyUnicodeChar, CSMessage::mIsHandled, MOUSE_BUTTON_RELEASED_MESSAGE, CSGrafikElement::reactOnMessageGrafikElement(), GuiMessage::receiver, GuiMessage::receiverX, GuiMessage::receiverY, CSStringlist::remove(), CSStringlist::set(), and CSGrafikElement::setEnabled(). Referenced by reactOnMessage().
00315 { 00316 static char *functionName="reactOnMessage"; 00317 if (message->mIsHandled) 00318 { 00319 reactOnMessageGrafikElement(message); 00320 return; 00321 } 00322 switch (message->getType()) 00323 { 00324 case GUI_MESSAGE: 00325 { 00326 GuiMessage *gm = (GuiMessage *) message; 00327 if (gm->receiver != this) 00328 { 00329 break; 00330 } 00331 else // receiver == this 00332 { 00333 switch (message->getSubtype()) 00334 { 00335 case MOUSE_BUTTON_RELEASED_MESSAGE: 00336 { 00337 int x,y; 00338 if (mIsEditable) 00339 { 00340 x = gm->receiverX; 00341 y = gm->receiverY; 00342 setGrafikCursor(x,y); 00343 gm->mIsHandled = true; 00344 } 00345 break; 00346 } 00347 00348 case FOCUS_GAINED_MESSAGE: 00349 { 00350 if (mIsEditable) 00351 { 00352 setEnabled(true); 00353 if (mCursorY>=0) 00354 { 00355 mLines.set(mCursorY, mWorkingString); 00356 } 00357 gm->mIsHandled = true; 00358 } 00359 break; 00360 } 00361 00362 case FOCUS_LOST_MESSAGE: 00363 { 00364 if (mIsEditable) 00365 { 00366 setEnabled(false); 00367 } 00368 00369 mWorkingString = mLines.getString(mCursorY); 00370 gm->mIsHandled = true; 00371 break; 00372 } 00373 00374 case KEY_RELEASED_MESSAGE: 00375 { 00376 gm->mIsHandled = false; 00377 break; 00378 } 00379 00380 case KEY_PRESSED_MESSAGE: 00381 { 00382 int ch=gm->keyUnicodeChar; 00383 if (gm->keySymbolic == SDLK_TAB) 00384 { 00385 getDesktop()->focusedNextComponent(); 00386 gm->mIsHandled = true; 00387 break; 00388 } 00389 if (gm->keySymbolic == SDLK_DELETE) 00390 { 00391 if (mCursorX<mWorkingString.length()) 00392 { 00393 deleteCharAtPos(mCursorX); 00394 setTextCursor(mCursorX, mCursorY); 00395 } 00396 else 00397 { 00398 if (mCursorY<mLines.getSize()) 00399 { 00400 mWorkingString += mLines.getString(mCursorY+1); 00401 mLines.remove(mCursorY+1); 00402 setTextCursor(mCursorX, mCursorY); 00403 } 00404 } 00405 gm->mIsHandled = true; 00406 break; 00407 } 00408 00409 if (gm->keySymbolic == SDLK_BACKSPACE) 00410 { 00411 if (mCursorX>0) 00412 { 00413 deleteCharAtPos(mCursorX-1); 00414 setTextCursor(mCursorX-1, mCursorY); 00415 } 00416 else 00417 { 00418 if (mCursorY>0) 00419 { 00420 setTextCursor(mCursorX, mCursorY-1); 00421 mCursorX = mWorkingString.length(); 00422 00423 mWorkingString += mLines.getString(mCursorY+1); 00424 mLines.remove(mCursorY+1); 00425 setTextCursor(mCursorX, mCursorY); 00426 } 00427 } 00428 gm->mIsHandled = true; 00429 break; 00430 } 00431 if ((gm->keySymbolic == SDLK_RETURN) || (gm->keySymbolic == SDLK_KP_ENTER)) 00432 { 00433 std::string t1 = mWorkingString.substr(0, mCursorX); 00434 std::string t2 = mWorkingString.substr(mCursorX, mWorkingString.length()-t1.length()); 00435 mWorkingString = t1; 00436 mLines.insert(mCursorY+1,t2); 00437 mCursorX=0; 00438 setTextCursor(mCursorX, mCursorY+1); 00439 gm->mIsHandled = true; 00440 break; 00441 } 00442 00443 if (gm->keySymbolic == SDLK_UP) 00444 { 00445 if (mCursorY>0) 00446 { 00447 setTextCursor(mCursorX, mCursorY-1); 00448 } 00449 gm->mIsHandled = true; 00450 break; 00451 } 00452 00453 if (gm->keySymbolic == SDLK_DOWN) 00454 { 00455 if (mCursorY+1<mLines.getSize()) 00456 { 00457 setTextCursor(mCursorX, mCursorY+1); 00458 } 00459 gm->mIsHandled = true; 00460 break; 00461 } 00462 00463 if (gm->keySymbolic == SDLK_LEFT) 00464 { 00465 if (mCursorX>0) 00466 { 00467 setTextCursor(mCursorX-1, mCursorY); 00468 } 00469 gm->mIsHandled = true; 00470 break; 00471 } 00472 00473 if (gm->keySymbolic == SDLK_RIGHT) 00474 { 00475 if (mCursorX<mWorkingString.length()) 00476 { 00477 setTextCursor(mCursorX+1, mCursorY); 00478 } 00479 gm->mIsHandled = true; 00480 break; 00481 } 00482 00483 if (gm->keySymbolic == SDLK_HOME) 00484 { 00485 setTextCursor(0, mCursorY); 00486 gm->mIsHandled = true; 00487 break; 00488 } 00489 00490 if (gm->keySymbolic == SDLK_END) 00491 { 00492 setTextCursor(mWorkingString.length(), mCursorY); 00493 gm->mIsHandled = true; 00494 break; 00495 } 00496 if ((ch>31) && (ch<128)) 00497 { 00498 int len = mWorkingString.length(); 00499 insertCharAtPos(mCursorX, ch); 00500 setTextCursor(mCursorX+1, mCursorY); 00501 gm->mIsHandled = true; 00502 break; 00503 } 00504 00505 break; 00506 } 00507 00508 } 00509 } 00510 } 00511 } 00512 reactOnMessageGrafikElement(message); 00513 } |
Here is the call graph for this function:
|
to be overloaded
Reimplemented from CSGrafikElement. Definition at line 309 of file CSTextarea.cpp. References reactOnMessageTextarea().
00310 { 00311 reactOnMessageTextarea(message); 00312 } |
Here is the call graph for this function:
|
Definition at line 83 of file CSTextarea.h. Referenced by CSMessageBox::rebuildElement().
00083 {mIsEditable = b;} |
|
Reimplemented from CSGrafikElement. Definition at line 200 of file CSTextarea.cpp. References CSLAF::getCurrentLAF(), CSGrafikElement::getFocused(), CSGrafikElement::getFont(), CSGrafikElement::getHeight(), CSFont::getHeight(), CSGrafikElement::getHorizontalElementSpacing(), CSStringlist::getSize(), CSStringlist::getString(), CSLAF::getTextAreaCursorColor(), CSGrafikElement::getVerticalElementSpacing(), CSGrafikElement::getViewportHeight(), CSGrafikElement::getViewportWidth(), CSGrafikElement::getViewportX(), CSGrafikElement::getViewportY(), CSFont::getWidth(), CSGrafikElement::getX(), CSGrafikElement::getY(), CSGrafikElement::line(), and putString().
00201 { 00202 static char *functionName="paint"; 00203 CSLAF *laf = CSLAF::getCurrentLAF(); 00204 float currentTick = SDL_GetTicks() + mCursorRate; 00205 if (currentTick > mTickTimeNext) 00206 { 00207 mTickTimeNext = currentTick + mCursorRate; 00208 mCursorShown = !mCursorShown; 00209 } 00210 00211 SDL_Rect thisViewportArea; 00212 thisViewportArea.x = parentViewport->x + getViewportX() + getX(); 00213 thisViewportArea.y = parentViewport->y + getViewportY() + getY(); 00214 thisViewportArea.h = getViewportHeight(); 00215 thisViewportArea.w = getViewportWidth(); 00216 00217 int x = getHorizontalElementSpacing(); 00218 int y = 0; 00219 00220 int yAdd = getFont()->getHeight() + getVerticalElementSpacing(); 00221 int xAdd = getFont()->getWidth(" "); 00222 00223 mVerticalDisplayLengthChar = getViewportHeight() / yAdd; 00224 ///////////////////////// 00225 if (mCursorY < mVerticalDisplayStart) 00226 { 00227 mVerticalDisplayStart = mCursorY; 00228 mVerticalDisplayEnd = mVerticalDisplayStart + mVerticalDisplayLengthChar; 00229 if (mVerticalDisplayEnd > mLines.getSize()) 00230 { 00231 mVerticalDisplayEnd = mLines.getSize(); 00232 } 00233 } 00234 mVerticalDisplayEnd = mVerticalDisplayStart + mVerticalDisplayLengthChar; 00235 if (mCursorY > mVerticalDisplayEnd-1) 00236 { 00237 mVerticalDisplayEnd = mCursorY+1; 00238 mVerticalDisplayStart = mVerticalDisplayEnd - (mVerticalDisplayLengthChar); 00239 if (mVerticalDisplayStart < 0) 00240 { 00241 mVerticalDisplayStart = 0; 00242 } 00243 } 00244 ///////////////////////// 00245 ///////////////////////// 00246 mHorizontalDisplayLengthChar = (getViewportWidth()-(2*(getHorizontalElementSpacing()))) / xAdd; 00247 if (mCursorX < mHorizontalDisplayStart) 00248 { 00249 mHorizontalDisplayStart = mCursorX; 00250 mHorizontalDisplayEnd = mHorizontalDisplayStart + mHorizontalDisplayLengthChar; 00251 } 00252 mHorizontalDisplayEnd = mHorizontalDisplayStart + mHorizontalDisplayLengthChar; 00253 if (mCursorX > mHorizontalDisplayEnd-1) 00254 { 00255 mHorizontalDisplayEnd = mCursorX+1; 00256 mHorizontalDisplayStart = mHorizontalDisplayEnd - (mHorizontalDisplayLengthChar); 00257 if (mHorizontalDisplayStart < 0) 00258 { 00259 mHorizontalDisplayStart = 0; 00260 } 00261 } 00262 ///////////////////////// 00263 00264 for (int i = mVerticalDisplayStart; i < mVerticalDisplayEnd; i++) 00265 { 00266 if (((i!= mCursorY) || (!getFocused())) || (!mIsEditable)) 00267 { 00268 if (mLines.getString(i).size() >=mHorizontalDisplayStart) 00269 { 00270 std::string t = mLines.getString(i).substr(mHorizontalDisplayStart, mHorizontalDisplayLengthChar); 00271 putString(destination, &thisViewportArea, x, y, t); 00272 00273 } 00274 } 00275 else 00276 { 00277 if (mWorkingString.size() >=mHorizontalDisplayStart) 00278 { 00279 std::string t = mWorkingString.substr(mHorizontalDisplayStart, mHorizontalDisplayLengthChar); 00280 putString(destination, &thisViewportArea, x, y, t); 00281 } 00282 } 00283 y += yAdd; 00284 } 00285 00286 if ((getFocused() && (mCursorShown)) && (mIsEditable)) 00287 { 00288 line(destination, &thisViewportArea, 00289 mExactCursorX, mExactCursorY, 00290 mExactCursorX, mExactCursorY+getFont()->getHeight(), 00291 laf->getTextAreaCursorColor()); 00292 } 00293 } |
Here is the call graph for this function:
|
coordinates relativ to this element no clipping Reimplemented from CSGrafikElement. Definition at line 192 of file CSTextarea.cpp. References CSGrafikElement::getFont(), CSGrafikElement::getTextColor(), and CSFont::putString(). Referenced by paint().
00193 { 00194 static char *functionName="putString"; 00195 x += viewport->x; 00196 y += viewport->y; 00197 getFont()->putString(destination,x,y,getTextColor(), string); 00198 } |
Here is the call graph for this function:
|
Reimplemented from CSGrafikElement. Definition at line 87 of file CSTextarea.h. References layoutSetupTextarea().
00087 {layoutSetupTextarea();} |
Here is the call graph for this function:
|
static element, name of this class (introsepection)
Reimplemented from CSGrafikElement. Definition at line 11 of file CSTextarea.cpp. Referenced by CSLAF::getAreaInternal(), CSLAF::getBackgroundColorDisabledInternal(), CSLAF::getBackgroundColorEnabledInternal(), CSLAF::getBorderInternal(), CSLAF::getFontInternal(), CSLAF::getHorizontalElementSpacingInternal(), CSLAF::getTextColorDisabledInternal(), CSLAF::getTextColorEnabledInternal(), getType(), and CSLAF::getVerticalElementSpacingInternal(). |