~ubuntu-branches/debian/squeeze/stella/squeeze

« back to all changes in this revision

Viewing changes to src/gui/PopUpWidget.cxx

  • Committer: Bazaar Package Importer
  • Author(s): Stephen Kitt
  • Date: 2010-07-12 23:49:36 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20100712234936-juawrr3etzhr2qpv
Tags: 3.1.2-1
* New maintainer (closes: #532039).
* New upstream version (closes: #461121):
  - includes launcher (closes: #396058).
* Fix the reference to the X Window System in the description (closes:
  #411815).
* Move to main, DFSG-free ROMs are available (see README.Debian).
* Enhance the package description.
* Drop the libslang2-dev dependency (closes: #560274).
* Remove the Encoding entry from stella.desktop.
* Avoid ignoring errors when cleaning.
* Add ${misc:Depends} to the package dependencies.
* Provide a doc-base file to install the documentation using doc-base.
* Switch to debhelper 7 with a simplified rules file.
* Use autotools-dev to provide updated configuration files.
* Update to Standards-Version 3.9.0:
  - Move to menu section Applications/Emulators.
  - Move the homepage declaration.
* Re-write the manpage.

Show diffs side-by-side

added added

removed removed

Lines of Context:
8
8
//  SS  SS   tt   ee      ll   ll  aa  aa
9
9
//   SSSS     ttt  eeeee llll llll  aaaaa
10
10
//
11
 
// Copyright (c) 1995-2008 by Bradford W. Mott and the Stella team
 
11
// Copyright (c) 1995-2010 by Bradford W. Mott, Stephen Anthony
 
12
// and the Stella Team
12
13
//
13
 
// See the file "license" for information on usage and redistribution of
 
14
// See the file "License.txt" for information on usage and redistribution of
14
15
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
15
16
//
16
 
// $Id: PopUpWidget.cxx,v 1.39 2008/02/06 13:45:24 stephena Exp $
 
17
// $Id: PopUpWidget.cxx 2001 2010-04-10 21:37:23Z stephena $
17
18
//
18
19
//   Based on code from ScummVM - Scumm Interpreter
19
20
//   Copyright (C) 2002-2004 The ScummVM project
21
22
 
22
23
#include "bspf.hxx"
23
24
 
 
25
#include "FrameBuffer.hxx"
 
26
#include "ContextMenu.hxx"
24
27
#include "DialogContainer.hxx"
25
 
#include "Dialog.hxx"
26
 
#include "FrameBuffer.hxx"
27
 
#include "OSystem.hxx"
28
 
#include "Stack.hxx"
29
 
#include "StringListWidget.hxx"
30
28
 
31
29
#include "PopUpWidget.hxx"
32
30
 
45
43
};
46
44
 
47
45
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
48
 
PopUpDialog::PopUpDialog(PopUpWidget* boss, int clickX, int clickY)
49
 
  : Dialog(boss->instance(), boss->parent(), 0, 0, 16, 16),
50
 
    _popUpBoss(boss)
51
 
{
52
 
  // Copy the selection index
53
 
  _selection = _popUpBoss->_selectedItem;
54
 
 
55
 
        // Calculate real popup dimensions
56
 
  _x = _popUpBoss->getAbsX() + _popUpBoss->_labelWidth;
57
 
  _y = _popUpBoss->getAbsY() - _popUpBoss->_selectedItem * _popUpBoss->_fontHeight;
58
 
  _w = _popUpBoss->_w - _popUpBoss->_labelWidth - 10;
59
 
  _h = 2;
60
 
}
61
 
 
62
 
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
63
 
void PopUpDialog::drawDialog()
64
 
{
65
 
  // Normally we add widgets and let Dialog::draw() take care of this
66
 
  // logic.  But for some reason, this Dialog was written differently
67
 
  // by the ScummVM guys, so I'm not going to mess with it.
68
 
  if(_dirty)
69
 
  {
70
 
    FrameBuffer& fb = instance()->frameBuffer();
71
 
 
72
 
    // Draw the menu border
73
 
    fb.hLine(_x, _y, _x + _w - 1, kColor);
74
 
    fb.hLine(_x, _y + _h - 1, _x + _w - 1, kShadowColor);
75
 
    fb.vLine(_x, _y, _y + _h - 1, kColor);
76
 
    fb.vLine(_x + _w - 1, _y, _y + _h - 1, kShadowColor);
77
 
 
78
 
    // If necessary, draw dividing line
79
 
    if(_twoColumns)
80
 
      fb.vLine(_x + _w / 2, _y, _y + _h - 2, kColor);
81
 
 
82
 
    // Draw the entries
83
 
    int count = _popUpBoss->_entries.size();
84
 
    for(int i = 0; i < count; i++)
85
 
      drawMenuEntry(i, i == _selection);
86
 
 
87
 
    // The last entry may be empty. Fill it with black.
88
 
    if(_twoColumns && (count & 1))
89
 
      fb.fillRect(_x + 1 + _w / 2, _y + 1 + _popUpBoss->_fontHeight * (_entriesPerColumn - 1),
90
 
                  _w / 2 - 1, _popUpBoss->_fontHeight, kWidColor);
91
 
 
92
 
    _dirty = false;
93
 
    fb.addDirtyRect(_x, _y, _w, _h);
94
 
  }
95
 
}
96
 
 
97
 
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
98
 
void PopUpDialog::handleMouseDown(int x, int y, int button, int clickCount)
99
 
{
100
 
  // Only make a selection if we're in the dialog area
101
 
  if(x >= 0 && x < _w && y >= 0 && y < _h)
102
 
    sendSelection();
103
 
  else
104
 
    cancelSelection();
105
 
}
106
 
 
107
 
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
108
 
void PopUpDialog::handleMouseWheel(int x, int y, int direction)
109
 
{
110
 
  if(direction < 0)
111
 
    moveUp();
112
 
  else if(direction > 0)
113
 
    moveDown();
114
 
}
115
 
 
116
 
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
117
 
void PopUpDialog::handleMouseMoved(int x, int y, int button)
118
 
{
119
 
  // Compute over which item the mouse is...
120
 
  int item = findItem(x, y);
121
 
 
122
 
  if(item >= 0 && _popUpBoss->_entries[item].name.size() == 0)
123
 
    item = -1;
124
 
 
125
 
  if(item == -1 && !isMouseDown())
126
 
    return;
127
 
 
128
 
  // ...and update the selection accordingly
129
 
  setSelection(item);
130
 
}
131
 
 
132
 
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
133
 
void PopUpDialog::handleKeyDown(int ascii, int keycode, int modifiers)
134
 
{
135
 
  if(isMouseDown())
136
 
    return;
137
 
 
138
 
  Event::Type e = instance()->eventHandler().eventForKey(keycode, kMenuMode);
139
 
  handleEvent(e);
140
 
}
141
 
 
142
 
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
143
 
void PopUpDialog::handleJoyDown(int stick, int button)
144
 
{
145
 
  Event::Type e =
146
 
    instance()->eventHandler().eventForJoyButton(stick, button, kMenuMode);
147
 
  handleEvent(e);
148
 
}
149
 
 
150
 
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
151
 
void PopUpDialog::handleJoyAxis(int stick, int axis, int value)
152
 
{
153
 
  if(value != 0)  // we don't care about 'axis up' events
154
 
  {
155
 
    Event::Type e =
156
 
      instance()->eventHandler().eventForJoyAxis(stick, axis, value, kMenuMode);
157
 
    handleEvent(e);
158
 
  }
159
 
}
160
 
 
161
 
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
162
 
bool PopUpDialog::handleJoyHat(int stick, int hat, int value)
163
 
{
164
 
  Event::Type e =
165
 
    instance()->eventHandler().eventForJoyHat(stick, hat, value, kMenuMode);
166
 
  handleEvent(e);
167
 
  return true;
168
 
}
169
 
 
170
 
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
171
 
void PopUpDialog::handleEvent(Event::Type e)
172
 
{
173
 
  switch(e)
174
 
  {
175
 
    case Event::UISelect:
176
 
      sendSelection();
177
 
      break;
178
 
    case Event::UIUp:
179
 
    case Event::UILeft:
180
 
      moveUp();
181
 
      break;
182
 
    case Event::UIDown:
183
 
    case Event::UIRight:
184
 
      moveDown();
185
 
      break;
186
 
    case Event::UIHome:
187
 
      setSelection(0);
188
 
      break;
189
 
    case Event::UIEnd:
190
 
      setSelection(_popUpBoss->_entries.size()-1);
191
 
      break;
192
 
    case Event::UICancel:
193
 
      cancelSelection();
194
 
      break;
195
 
    default:
196
 
      break;
197
 
  }
198
 
}
199
 
 
200
 
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
201
 
void PopUpDialog::drawMenuEntry(int entry, bool hilite)
202
 
{
203
 
  FrameBuffer& fb = instance()->frameBuffer();
204
 
 
205
 
  // Draw one entry of the popup menu, including selection
206
 
  int x, y, w;
207
 
 
208
 
  if(_twoColumns)
209
 
  {
210
 
    int n = _popUpBoss->_entries.size() / 2;
211
 
 
212
 
    if(_popUpBoss->_entries.size() & 1)
213
 
      n++;
214
 
 
215
 
    if (entry >= n)
216
 
    {
217
 
      x = _x + 1 + _w / 2;
218
 
      y = _y + 1 + _popUpBoss->_fontHeight * (entry - n);
219
 
    }
220
 
    else
221
 
    {
222
 
      x = _x + 1;
223
 
      y = _y + 1 + _popUpBoss->_fontHeight * entry;
224
 
    }
225
 
 
226
 
    w = _w / 2 - 1;
227
 
  }
228
 
  else
229
 
  {
230
 
    x = _x + 1;
231
 
    y = _y + 1 + _popUpBoss->_fontHeight * entry;
232
 
    w = _w - 2;
233
 
  }
234
 
 
235
 
  string& name = _popUpBoss->_entries[entry].name;
236
 
  fb.fillRect(x, y, w, _popUpBoss->_fontHeight, hilite ? kTextColorHi : kWidColor);
237
 
 
238
 
  if(name.size() == 0)
239
 
  {
240
 
    // Draw a separator
241
 
    fb.hLine(x - 1, y + _popUpBoss->_fontHeight / 2, x + w, kShadowColor);
242
 
    fb.hLine(x, y + 1 + _popUpBoss->_fontHeight / 2, x + w, kColor);
243
 
  }
244
 
  else
245
 
    fb.drawString(_popUpBoss->font(), name, x + 1, y + 2, w - 2,
246
 
                  hilite ? _popUpBoss->_textcolorhi : _popUpBoss->_textcolor);
247
 
}
248
 
 
249
 
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
250
 
void PopUpDialog::recalc()
251
 
{
252
 
  // Perform clipping / switch to scrolling mode if we don't fit on the screen
253
 
  const int height = instance()->frameBuffer().baseHeight();
254
 
 
255
 
  _x = _popUpBoss->getAbsX() + _popUpBoss->_labelWidth;
256
 
  _y = _popUpBoss->getAbsY() + _popUpBoss->getHeight();
257
 
 
258
 
  _h = _popUpBoss->_entries.size() * _popUpBoss->_fontHeight + 2;
259
 
 
260
 
  // HACK: For now, we do not do scrolling. Instead, we draw the dialog
261
 
  // in two columns if it's too tall.
262
 
  if(_h >= height)
263
 
  {
264
 
    const int width = instance()->frameBuffer().baseWidth();
265
 
 
266
 
    _twoColumns = true;
267
 
    _entriesPerColumn = _popUpBoss->_entries.size() / 2;
268
 
 
269
 
    if(_popUpBoss->_entries.size() & 1)
270
 
      _entriesPerColumn++;
271
 
 
272
 
    _h = _entriesPerColumn * _popUpBoss->_fontHeight + 2;
273
 
    _w = 0;
274
 
 
275
 
    // Find width of largest item
276
 
    for(unsigned int i = 0; i < _popUpBoss->_entries.size(); i++)
277
 
    {
278
 
      int width = _popUpBoss->_font->getStringWidth(_popUpBoss->_entries[i].name);
279
 
 
280
 
      if(width > _w)
281
 
      _w = width;
282
 
    }
283
 
 
284
 
    _w = 2 * _w + 10;
285
 
 
286
 
    if (!(_w & 1))
287
 
      _w++;
288
 
 
289
 
    if(_popUpBoss->_selectedItem >= _entriesPerColumn)
290
 
    {
291
 
      _x -= _w / 2;
292
 
      _y = _popUpBoss->getAbsY() - (_popUpBoss->_selectedItem - _entriesPerColumn) *
293
 
           _popUpBoss->_fontHeight;
294
 
    }
295
 
 
296
 
    if(_w >= width)
297
 
      _w = width - 1;
298
 
    if(_x < 0)
299
 
      _x = 0;
300
 
    if(_x + _w >= width)
301
 
      _x = width - 1 - _w;
302
 
  }
303
 
  else
304
 
    _twoColumns = false;
305
 
 
306
 
  if(_h >= height)
307
 
    _h = height - 1;
308
 
  if(_y < 0)
309
 
    _y = 0;
310
 
  else if(_y + _h >= height)
311
 
    _y = height - 1 - _h;
312
 
 
313
 
  // TODO - implement scrolling if we had to move the menu, or if there are too many entries
314
 
}
315
 
 
316
 
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
317
 
int PopUpDialog::findItem(int x, int y) const
318
 
{
319
 
  if(x >= 0 && x < _w && y >= 0 && y < _h)
320
 
  {
321
 
    if(_twoColumns)
322
 
    {
323
 
      unsigned int entry = (y - 2) / _popUpBoss->_fontHeight;
324
 
      if(x > _w / 2)
325
 
      {
326
 
        entry += _entriesPerColumn;
327
 
 
328
 
        if(entry >= _popUpBoss->_entries.size())
329
 
          return -1;
330
 
      }
331
 
      return entry;
332
 
    }
333
 
    return (y - 2) / _popUpBoss->_fontHeight;
334
 
  }
335
 
 
336
 
  return -1;
337
 
}
338
 
 
339
 
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
340
 
void PopUpDialog::setSelection(int item)
341
 
{
342
 
  if(item != _selection)
343
 
  {
344
 
    // Change selection
345
 
    _selection = item;
346
 
    _popUpBoss->_selectedItem = item;
347
 
 
348
 
    setDirty(); _popUpBoss->setDirty(); _popUpBoss->draw();
349
 
  }
350
 
}
351
 
 
352
 
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
353
 
void PopUpDialog::sendSelection()
354
 
{
355
 
  if(_popUpBoss->_cmd)
356
 
    _popUpBoss->sendCommand(_popUpBoss->_cmd,
357
 
                            _popUpBoss->_entries[_selection].tag,
358
 
                            _popUpBoss->_id);
359
 
 
360
 
  // We remove the dialog when the user has selected an item
361
 
  parent()->removeDialog();
362
 
}
363
 
 
364
 
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
365
 
void PopUpDialog::cancelSelection()
366
 
{
367
 
  setSelection(_oldSelection);
368
 
  parent()->removeDialog();
369
 
}
370
 
 
371
 
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
372
 
bool PopUpDialog::isMouseDown()
373
 
{
374
 
  // TODO - need a way to determine whether any mouse buttons are pressed or not.
375
 
  // Sure, we could just count mouse button up/down events, but that is cumbersome and
376
 
  // error prone. Would be much nicer to add an API to OSystem for this...
377
 
 
378
 
  return false;
379
 
}
380
 
 
381
 
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
382
 
void PopUpDialog::moveUp()
383
 
{
384
 
  if(_selection < 0)
385
 
  {
386
 
    setSelection(_popUpBoss->_entries.size() - 1);
387
 
  }
388
 
  else if(_selection > 0)
389
 
  {
390
 
    int item = _selection;
391
 
    do {
392
 
      item--;
393
 
    } while (item >= 0 && _popUpBoss->_entries[item].name.size() == 0);
394
 
    if(item >= 0)
395
 
      setSelection(item);
396
 
  }
397
 
}
398
 
 
399
 
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
400
 
void PopUpDialog::moveDown()
401
 
{
402
 
  int lastItem = _popUpBoss->_entries.size() - 1;
403
 
 
404
 
  if(_selection < 0)
405
 
  {
406
 
    setSelection(0);
407
 
  }
408
 
  else if(_selection < lastItem)
409
 
  {
410
 
    int item = _selection;
411
 
    do {
412
 
      item++;
413
 
    } while (item <= lastItem && _popUpBoss->_entries[item].name.size() == 0);
414
 
    if(item <= lastItem)
415
 
      setSelection(item);
416
 
  }
417
 
}
418
 
 
419
 
//
420
 
// PopUpWidget
421
 
//
422
 
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
423
46
PopUpWidget::PopUpWidget(GuiObject* boss, const GUI::Font& font,
424
 
                         int x, int y, int w, int h,
 
47
                         int x, int y, int w, int h, const StringMap& list,
425
48
                         const string& label, int labelWidth, int cmd)
426
49
  : Widget(boss, font, x, y - 1, w, h + 2),
427
50
    CommandSender(boss),
428
51
    _label(label),
429
 
    _labelWidth(labelWidth),
430
 
    _cmd(cmd)
 
52
    _labelWidth(labelWidth)
431
53
{
432
54
  _flags = WIDGET_ENABLED | WIDGET_CLEARBG | WIDGET_RETAIN_FOCUS;
433
55
  _type = kPopUpWidget;
436
58
  _textcolor = kTextColor;
437
59
  _textcolorhi = kTextColor;
438
60
 
439
 
  _selectedItem = -1;
440
 
 
441
61
  if(!_label.empty() && _labelWidth == 0)
442
62
    _labelWidth = _font->getStringWidth(_label);
443
63
 
447
67
  myTextY   = (_h - _font->getFontHeight()) / 2;
448
68
  myArrowsY = (_h - 8) / 2;
449
69
 
450
 
  myPopUpDialog = new PopUpDialog(this, x + getAbsX(), y + getAbsY());
 
70
  myMenu = new ContextMenu(this, font, list, cmd);
451
71
}
452
72
 
453
73
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
454
74
PopUpWidget::~PopUpWidget()
455
75
{
456
 
  delete myPopUpDialog;
457
 
  myPopUpDialog = NULL;
 
76
  delete myMenu;
458
77
}
459
78
 
460
79
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
462
81
{
463
82
  if(isEnabled())
464
83
  {
465
 
    myPopUpDialog->_oldSelection = _selectedItem;
466
 
    parent()->addDialog(myPopUpDialog);
 
84
    // Add menu just underneath parent widget
 
85
    const GUI::Rect& image = instance().frameBuffer().imageRect();
 
86
    uInt32 tx, ty;
 
87
    dialog().surface().getPos(tx, ty);
 
88
    tx += getAbsX() + _labelWidth - image.x();
 
89
    ty += getAbsY() + getHeight() - image.y();
 
90
    myMenu->show(tx, ty, myMenu->getSelected());
467
91
  }
468
92
}
469
93
 
484
108
}
485
109
 
486
110
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
487
 
void PopUpWidget::appendEntry(const string& entry, int tag)
488
 
{
489
 
  Entry e;
490
 
  e.name = entry;
491
 
  e.tag = tag;
492
 
  _entries.push_back(e);
493
 
}
494
 
 
495
 
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
496
 
void PopUpWidget::clearEntries()
497
 
{
498
 
  _entries.clear();
499
 
  _selectedItem = -1;
500
 
 
501
 
  // Reset the height of the popup dialog to be empty
502
 
  myPopUpDialog->setHeight(2);
503
 
}
504
 
 
505
 
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
506
 
void PopUpWidget::setSelected(int item)
507
 
{
508
 
  if(item != _selectedItem)
509
 
  {
510
 
    if(item >= 0 && item < (int)_entries.size())
511
 
      _selectedItem = item;
512
 
    else
513
 
      _selectedItem = -1;
514
 
  }
515
 
}
516
 
 
517
 
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
518
 
void PopUpWidget::setSelectedName(const string& name)
519
 
{
520
 
  for(unsigned int item = 0; item < _entries.size(); ++item)
521
 
  {
522
 
    if(_entries[item].name == name)
523
 
    {
524
 
      setSelected(item);
525
 
      return;
526
 
    }
527
 
  }
528
 
}
529
 
 
530
 
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
531
 
void PopUpWidget::setSelectedTag(int tag)
532
 
{
533
 
  for(unsigned int item = 0; item < _entries.size(); ++item)
534
 
  {
535
 
    if(_entries[item].tag == tag)
536
 
    {
537
 
      setSelected(item);
538
 
      return;
539
 
    }
540
 
  }
541
 
}
542
 
 
543
 
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
544
 
void PopUpWidget::setSelectedMax()
545
 
{
546
 
  setSelected(_entries.size() - 1);
 
111
void PopUpWidget::handleCommand(CommandSender* sender, int cmd, int data, int id)
 
112
{
 
113
  // Intercept all events sent through the PromptWidget
 
114
  // They're likely from our ContextMenu, indicating a redraw is required
 
115
  dialog().setDirty();
 
116
 
 
117
  // Pass the cmd on to our parent
 
118
  sendCommand(cmd, data, id);
547
119
}
548
120
 
549
121
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
550
122
void PopUpWidget::drawWidget(bool hilite)
551
123
{
552
124
//cerr << "PopUpWidget::drawWidget\n";
553
 
  FrameBuffer& fb = instance()->frameBuffer();
 
125
  FBSurface& s = dialog().surface();
554
126
 
555
127
  int x = _x + _labelWidth;
556
128
  int w = _w - _labelWidth;
557
129
 
558
130
  // Draw the label, if any
559
131
  if (_labelWidth > 0)
560
 
    fb.drawString(_font, _label, _x, _y + myTextY, _labelWidth,
561
 
                  isEnabled() ? _textcolor : kColor, kTextAlignRight);
 
132
    s.drawString(_font, _label, _x, _y + myTextY, _labelWidth,
 
133
                 isEnabled() ? _textcolor : kColor, kTextAlignRight);
562
134
 
563
135
  // Draw a thin frame around us.
564
 
  fb.hLine(x, _y, x + w - 1, kColor);
565
 
  fb.hLine(x, _y +_h-1, x + w - 1, kShadowColor);
566
 
  fb.vLine(x, _y, _y+_h-1, kColor);
567
 
  fb.vLine(x + w - 1, _y, _y +_h - 1, kShadowColor);
 
136
  s.hLine(x, _y, x + w - 1, kColor);
 
137
  s.hLine(x, _y +_h-1, x + w - 1, kShadowColor);
 
138
  s.vLine(x, _y, _y+_h-1, kColor);
 
139
  s.vLine(x + w - 1, _y, _y +_h - 1, kShadowColor);
568
140
 
569
141
  // Fill the background
570
 
  fb.fillRect(x + 1, _y + 1, w - 2, _h - 2, kWidColor);
 
142
  s.fillRect(x + 1, _y + 1, w - 2, _h - 2, kWidColor);
571
143
 
572
144
  // Draw an arrow pointing down at the right end to signal this is a dropdown/popup
573
 
  fb.drawBitmap(up_down_arrows, x+w - 10, _y + myArrowsY,
574
 
                !isEnabled() ? kColor : hilite ? kTextColorHi : kTextColor);
 
145
  s.drawBitmap(up_down_arrows, x+w - 10, _y + myArrowsY,
 
146
               !isEnabled() ? kColor : hilite ? kTextColorHi : kTextColor);
575
147
 
576
148
  // Draw the selected entry, if any
577
 
  if(_selectedItem >= 0)
578
 
  {
579
 
    TextAlignment align = (_font->getStringWidth(_entries[_selectedItem].name) > w-6) ?
580
 
                           kTextAlignRight : kTextAlignLeft;
581
 
    fb.drawString(_font, _entries[_selectedItem].name, x+2, _y+myTextY, w-6,
582
 
                  !isEnabled() ? kColor : kTextColor, align);
583
 
  }
 
149
  const string& name = myMenu->getSelectedName();
 
150
  TextAlignment align = (_font->getStringWidth(name) > w-6) ?
 
151
                         kTextAlignRight : kTextAlignLeft;
 
152
  s.drawString(_font, name, x+2, _y+myTextY, w-6,
 
153
               !isEnabled() ? kColor : kTextColor, align);
584
154
}