Hi Leute,
kann mir wer von euch helfen?
Ich brauche Shortcuts in einer Listbox. Ich kann die Shortcuts nur darstellen, weil ich nicht weiter weiß.
C
#ifndef _eListBoxShortcutEntry_H_
#define _eListBoxShortcutEntry_H_
#include <cstdio>
#include <lib/base/estring.h>
#include <lib/gui/ebutton.h>
#include <lib/gui/ewindow.h>
#include <lib/gui/multipage.h>
#include <lib/gui/eprogress.h>
#include <lib/gui/listbox.h>
#include <lib/gdi/font.h>
#include <lib/gui/emessage.h>
class eListBoxShortcutEntry: public eListBoxEntry
{
friend class eListBox<eListBoxShortcutEntry>;
static gFont font;
static gPixmap *zero, *one, *two, *three, *four, *five, *six, *seven, *eight, *nine, *red, *green, *yellow, *blue, *pm;
eTextPara *para;
const eString &redraw(gPainter *rc, const eRect& rect, gColor coActiveB, gColor coActiveF, gColor coNormalB, gColor coNormalF, int hilited);
static int getEntryHeight();
eString mytext;
eString helptext;
int mode;
bool visible;
eString getHelpText();
public:
eString getText() { return mytext; };
eListBoxShortcutEntry(eListBox<eListBoxShortcutEntry> *listbox, const eString& text, const eString &hlptxt, int m, bool _visible = false);
~eListBoxShortcutEntry();
};
#endif /*_eListBoxShortcutEntry_H_*/
Alles anzeigen
Code
#include "eListBoxShortcutEntry.h"
gFont eListBoxShortcutEntry::font;
gPixmap *eListBoxShortcutEntry::zero = 0;
gPixmap *eListBoxShortcutEntry::one = 0;
gPixmap *eListBoxShortcutEntry::two = 0;
gPixmap *eListBoxShortcutEntry::three = 0;
gPixmap *eListBoxShortcutEntry::four = 0;
gPixmap *eListBoxShortcutEntry::five = 0;
gPixmap *eListBoxShortcutEntry::six = 0;
gPixmap *eListBoxShortcutEntry::seven = 0;
gPixmap *eListBoxShortcutEntry::eight = 0;
gPixmap *eListBoxShortcutEntry::nine = 0;
gPixmap *eListBoxShortcutEntry::red = 0;
gPixmap *eListBoxShortcutEntry::green = 0;
gPixmap *eListBoxShortcutEntry::yellow = 0;
gPixmap *eListBoxShortcutEntry::blue = 0;
gPixmap *eListBoxShortcutEntry::pm = 0;
eListBoxShortcutEntry::~eListBoxShortcutEntry()
{
if (para)
{
para->destroy();
para = 0;
}
}
int eListBoxShortcutEntry::getEntryHeight()
{
if (!font.pointSize)
{
font = eSkin::getActive()->queryFont("global.normal");
zero = eSkin::getActive()->queryImage("shortcut.0");
one = eSkin::getActive()->queryImage("shortcut.1");
two = eSkin::getActive()->queryImage("shortcut.2");
three = eSkin::getActive()->queryImage("shortcut.3");
four = eSkin::getActive()->queryImage("shortcut.4");
five = eSkin::getActive()->queryImage("shortcut.5");
six = eSkin::getActive()->queryImage("shortcut.6");
seven = eSkin::getActive()->queryImage("shortcut.7");
eight = eSkin::getActive()->queryImage("shortcut.8");
nine = eSkin::getActive()->queryImage("shortcut.9");
red = eSkin::getActive()->queryImage("shortcut.red");
green = eSkin::getActive()->queryImage("shortcut.green");
yellow = eSkin::getActive()->queryImage("shortcut.yellow");
blue = eSkin::getActive()->queryImage("shortcut.blue");
pm = eSkin::getActive()->queryImage("listbox.separator");
eTextPara *test;
test = new eTextPara(eRect(0, 0, 100, 50));
test->setFont(font);
test->renderString("Mjdyl");
test->getBoundBox().height();
test->destroy();
}
// distance entrys
return calcFontHeight(font) + 4;
}
eListBoxShortcutEntry::eListBoxShortcutEntry(eListBox < eListBoxShortcutEntry > *listbox, const eString & text, const eString & hlptxt, int m, bool _visible):eListBoxEntry((eListBox < eListBoxEntry > *)listbox, hlptxt)
{
mytext = text;
helptext = hlptxt;
mode = m;
visible = _visible;
para = 0;
if (m==14)
selectable=0;
}
const eString & eListBoxShortcutEntry::redraw(gPainter * rc, const eRect & rect, gColor coActiveB, gColor coActiveF, gColor coNormalB, gColor coNormalF, int hilited)
{
drawEntryRect(rc, rect, coActiveB, coActiveF, coNormalB, coNormalF, hilited);
int xpos = rect.left() + 5;
int ypos = (rect.height() - red->y) / 2;
if(visible)
{
switch (mode)
{
case 0:
rc->blit(*zero, ePoint(xpos, rect.top() + ypos), eRect(), gPixmap::blitAlphaTest);
break;
case 1:
rc->blit(*one, ePoint(xpos, rect.top() + ypos), eRect(), gPixmap::blitAlphaTest);
break;
case 2:
rc->blit(*two, ePoint(xpos, rect.top() + ypos), eRect(), gPixmap::blitAlphaTest);
break;
case 3:
rc->blit(*three, ePoint(xpos, rect.top() + ypos), eRect(), gPixmap::blitAlphaTest);
break;
case 4:
rc->blit(*four, ePoint(xpos, rect.top() + ypos), eRect(), gPixmap::blitAlphaTest);
break;
case 5:
rc->blit(*five, ePoint(xpos, rect.top() + ypos), eRect(), gPixmap::blitAlphaTest);
break;
case 6:
rc->blit(*six, ePoint(xpos, rect.top() + ypos), eRect(), gPixmap::blitAlphaTest);
break;
case 7:
rc->blit(*seven, ePoint(xpos, rect.top() + ypos), eRect(), gPixmap::blitAlphaTest);
break;
case 8:
rc->blit(*eight, ePoint(xpos, rect.top() + ypos), eRect(), gPixmap::blitAlphaTest);
break;
case 9:
rc->blit(*nine, ePoint(xpos, rect.top() + ypos), eRect(), gPixmap::blitAlphaTest);
break;
case 10:
rc->blit(*red, ePoint(xpos, rect.top() + ypos), eRect(), gPixmap::blitAlphaTest);
break;
case 11:
rc->blit(*green, ePoint(xpos, rect.top() + ypos), eRect(), gPixmap::blitAlphaTest);
break;
case 12:
rc->blit(*yellow, ePoint(xpos, rect.top() + ypos), eRect(), gPixmap::blitAlphaTest);
break;
case 13:
rc->blit(*blue, ePoint(xpos, rect.top() + ypos), eRect(), gPixmap::blitAlphaTest);
break;
case 14:
{
int x = 0;
rc->clip(rect);
eSize psize = pm->getSize(), esize = rect.size();
int yOffs = rect.top() + ((esize.height() - psize.height()) / 2);
do
{
rc->blit(*pm, ePoint(x, yOffs), eRect(x, yOffs, psize.width(), psize.height()), gPixmap::blitAlphaTest);
//x += distance;
x += psize.width();
}
while (x < esize.width());
rc->clippop();
break;
}
default:
printf("\nfalse pix !!! \07\n");
}
}
xpos += 35;
if (!para)
{
para = new eTextPara(eRect(0, 0, rect.width(), rect.height() / 2));
para->setFont(font);
para->renderString(mytext);
}
rc->renderPara(*para, ePoint(xpos, rect.top()));
return mytext;
}
eString eListBoxShortcutEntry::getHelpText()
{
return this->helptext;
}
Alles anzeigen
Bitte helft mir weiter.
CU Emanuel