Changeset 2309fa for molecuilder/src/Menu
- Timestamp:
- Dec 16, 2009, 12:30:16 PM (16 years ago)
- Children:
- f00f02
- Parents:
- 057b77
- git-author:
- Tillmann Crueger <crueger@…> (12/16/09 09:49:55)
- git-committer:
- Frederik Heber <heber@…> (12/16/09 12:30:16)
- Location:
- molecuilder/src/Menu
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
molecuilder/src/Menu/DisplayMenuItem.cpp
r057b77 r2309fa 6 6 */ 7 7 8 #include <sstream> 9 #include <cmath> 10 8 11 #include "Menu/DisplayMenuItem.hpp" 9 12 #include "Views/StringView.hpp" 10 13 11 #include <iostream>12 14 13 15 DisplayMenuItem::DisplayMenuItem(Menu* _menu, StringView *_view): 14 16 MenuItem('\0',"",_menu), 15 view(_view) 17 view(_view), 18 title("") 16 19 { 20 } 17 21 22 DisplayMenuItem::DisplayMenuItem(Menu* _menu, StringView *_view, string _title, char _spacer, int _length ): 23 MenuItem('\0',"",_menu), 24 view(_view), 25 title(_title), 26 spacer(_spacer), 27 length(_length) 28 { 18 29 } 19 30 … … 28 39 29 40 const string DisplayMenuItem::formatEntry(){ 30 return view->toString(); 41 stringstream s; 42 if(title.length()>0) { 43 int pre = floor((length-title.length())/2.0); 44 int post = ceil((length-title.length())/2.0); 45 for(int i=0;i<pre;i++) 46 s << spacer; 47 s << title; 48 for(int i=0;i<post;i++) 49 s << spacer; 50 s << "\n"; 51 } 52 s << view->toString(); 53 return s.str(); 31 54 } 32 55 -
molecuilder/src/Menu/DisplayMenuItem.hpp
r057b77 r2309fa 10 10 11 11 #include "Menu/MenuItem.hpp" 12 #include "defs.hpp" 12 13 13 14 class StringView; … … 17 18 public: 18 19 DisplayMenuItem(Menu* _menu, StringView *_view); 20 DisplayMenuItem(Menu* _menu, StringView *_view, string _title, 21 char _spacer=STD_MENU_TITLE_SPACER, int _length=STD_MENU_LENGTH); 19 22 virtual ~DisplayMenuItem(); 20 23 … … 28 31 private: 29 32 StringView *view; 33 string title; 34 int length; 35 char spacer; 30 36 }; 31 37
Note:
See TracChangeset
for help on using the changeset viewer.