aboutsummaryrefslogtreecommitdiff
path: root/src/FbTk/Menu.cc
diff options
context:
space:
mode:
authorsimonb <simonb>2006-05-20 15:08:14 (GMT)
committersimonb <simonb>2006-05-20 15:08:14 (GMT)
commit0861f3a9073ccd016302af26ff992fa19331a02d (patch)
treef1a2276449a5fc9b27f2d1afa5ffff4410141345 /src/FbTk/Menu.cc
parent5ddabb0f390f69db793b5a6e40be9f94b8f83136 (diff)
downloadfluxbox-0861f3a9073ccd016302af26ff992fa19331a02d.zip
fluxbox-0861f3a9073ccd016302af26ff992fa19331a02d.tar.bz2
improve native language handling, move messages and menu labels to
FbTk::FbString
Diffstat (limited to 'src/FbTk/Menu.cc')
-rw-r--r--src/FbTk/Menu.cc23
1 files changed, 11 insertions, 12 deletions
diff --git a/src/FbTk/Menu.cc b/src/FbTk/Menu.cc
index d99c9ba..63f3958 100644
--- a/src/FbTk/Menu.cc
+++ b/src/FbTk/Menu.cc
@@ -193,15 +193,15 @@ Menu::~Menu() {
193 s_focused = 0; 193 s_focused = 0;
194} 194}
195 195
196int Menu::insert(const char *label, RefCount<Command> &cmd, int pos) { 196int Menu::insert(const FbString &label, RefCount<Command> &cmd, int pos) {
197 return insert(new MenuItem(label, cmd), pos); 197 return insert(new MenuItem(label, cmd), pos);
198} 198}
199 199
200int Menu::insert(const char *label, int pos) { 200int Menu::insert(const FbString &label, int pos) {
201 return insert(new MenuItem(label), pos); 201 return insert(new MenuItem(label), pos);
202} 202}
203 203
204int Menu::insert(const char *label, Menu *submenu, int pos) { 204int Menu::insert(const FbString &label, Menu *submenu, int pos) {
205 submenu->m_parent = this; 205 submenu->m_parent = this;
206 return insert(new MenuItem(label, submenu), pos); 206 return insert(new MenuItem(label, submenu), pos);
207} 207}
@@ -392,7 +392,7 @@ void Menu::enableTitle() {
392 392
393void Menu::updateMenu(int active_index) { 393void Menu::updateMenu(int active_index) {
394 if (m_title_vis) { 394 if (m_title_vis) {
395 menu.item_w = theme().titleFont().textWidth(menu.label.c_str(), 395 menu.item_w = theme().titleFont().textWidth(menu.label,
396 menu.label.size()); 396 menu.label.size());
397 menu.item_w += (theme().bevelWidth() * 2); 397 menu.item_w += (theme().bevelWidth() * 2);
398 } else 398 } else
@@ -427,14 +427,14 @@ void Menu::updateMenu(int active_index) {
427 int itmp = (theme().itemHeight() * menu.persub); 427 int itmp = (theme().itemHeight() * menu.persub);
428 menu.frame_h = itmp < 1 ? 1 : itmp; 428 menu.frame_h = itmp < 1 ? 1 : itmp;
429 429
430 int new_width = (menu.sublevels * menu.item_w); 430 unsigned int new_width = (menu.sublevels * menu.item_w);
431 int new_height = menu.frame_h; 431 unsigned int new_height = menu.frame_h;
432 432
433 if (m_title_vis) 433 if (m_title_vis)
434 new_height += theme().titleHeight() + ((menu.frame_h > 0)?menu.title.borderWidth():0); 434 new_height += theme().titleHeight() + ((menu.frame_h > 0)?menu.title.borderWidth():0);
435 435
436 436
437 if (new_width < 1) { 437 if (new_width == 0) {
438 if (menu.item_w > 0) 438 if (menu.item_w > 0)
439 new_width = menu.item_w; 439 new_width = menu.item_w;
440 else 440 else
@@ -638,12 +638,11 @@ void Menu::move(int x, int y) {
638 638
639 639
640void Menu::redrawTitle(FbDrawable &drawable) { 640void Menu::redrawTitle(FbDrawable &drawable) {
641 const char *text = menu.label.c_str();
642 641
643 const FbTk::Font &font = theme().titleFont(); 642 const FbTk::Font &font = theme().titleFont();
644 int dx = theme().bevelWidth(); 643 int dx = theme().bevelWidth();
645 size_t len = menu.label.size(); 644 size_t len = menu.label.size();
646 unsigned int l = font.textWidth(text, len) + theme().bevelWidth()*2; 645 unsigned int l = font.textWidth(menu.label, len) + theme().bevelWidth()*2;
647 646
648 switch (theme().titleFontJustify()) { 647 switch (theme().titleFontJustify()) {
649 case FbTk::RIGHT: 648 case FbTk::RIGHT:
@@ -662,7 +661,7 @@ void Menu::redrawTitle(FbDrawable &drawable) {
662 font.drawText(drawable, // drawable 661 font.drawText(drawable, // drawable
663 screenNumber(), 662 screenNumber(),
664 theme().titleTextGC().gc(), // graphic context 663 theme().titleTextGC().gc(), // graphic context
665 text, len, // text string with length 664 menu.label, len, // text string with length
666 dx, font.ascent() + theme().bevelWidth() + height_offset/2); // position 665 dx, font.ascent() + theme().bevelWidth() + height_offset/2); // position
667} 666}
668 667
@@ -784,9 +783,9 @@ int Menu::drawItem(FbDrawable &drawable, unsigned int index,
784 return item_y; 783 return item_y;
785} 784}
786 785
787void Menu::setLabel(const char *labelstr) { 786void Menu::setLabel(const FbString &labelstr) {
788 //make sure we don't send 0 to std::string 787 //make sure we don't send 0 to std::string
789 menu.label = (labelstr ? labelstr : ""); 788 menu.label = labelstr;
790 reconfigure(); 789 reconfigure();
791} 790}
792 791