Hi Leute,
Ich hätte da mal eine Frage:
Welches Prog (besser Linux, aber zur Not f. d. Teufel a. Winfliegen)
benutzt Ihr zur Erstellung der 8Bit transparent-Mode PNGs?
Gruß Emanuel
Hi Leute,
Ich hätte da mal eine Frage:
Welches Prog (besser Linux, aber zur Not f. d. Teufel a. Winfliegen)
benutzt Ihr zur Erstellung der 8Bit transparent-Mode PNGs?
Gruß Emanuel
Hi Dre,
Danke.
Das mit der OK Taste muß man wissen.
Ich habe es halt nie gebraucht.
Gruß Emanuel
Hi tyrel,
habe gerade im tuxCommander vergebens nach einer
Editor Funktion gesucht. Ist da nur Zeile löschen und einfügen drin??
Gruß Emanuel
Hi tyrel,
Ich hatte sie nur mal überflogen, aber es gibt eine /tuxbox/apps/tuxbox/neutrino/src/gui/filebrowser.cpp im cvs.
Da hast Du C++ und Filebrowser zum basteln.
Gruß Emanuel
Hi luke_s,
gefällt mir, werde ich testen.
Gruß Emanuel =)
Hi luke_s,
Ja, so hätte ich mir das auch gedacht. Ich habe mich aber noch nicht mit den
Sortierefunktionen aus dirent64 beschäftigt. (alphasort)...
Ich hab gerade mit meinem Plugin zu tun, da reicht die Ordnerausgabe.
Es wäre schön wenn wer weiter machen würde, denn das kann man immer brauchen.
Gruß Emu
Hi tyrel,
Enigma1 hat kein rewinddir(DIR *dir); also mußt ich das "dir" 2 x durchsuchen mit readdir64(DIR *dir); (ist alles ne schnelles Haurucklösung)
Du kannst ja noch Pixmaps reinbauen kannst jetzt ja nachlesen wie es geht.
Endungen abfragen wenn *.mp3 nimm Pic_mp3.png oder so.
filebrowser:
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <sys/types.h>
#include <sys/stat.h>
#include <dirent.h>
#include <plugin.h>
#include <lib/gui/elabel.h>
#include <lib/gui/ebutton.h>
#include <lib/gui/emessage.h>
#include <lib/gui/listbox.h>
#include <lib/gui/eskin.h>
#include <lib/gdi/font.h>
using namespace std;
class eListBoxEntryTextPixmap: public eListBoxEntryText{
static gPixmap *pm; // class member !!! the same pixmap for all entries...
bool pm_visible;
public:
eListBoxEntryTextPixmap(eListBox<eListBoxEntryTextPixmap>* lb, const char* txt=0, void *key=0, bool pm_visible=false, int align=0, const eString &hlptxt="", int keytype = value );
const eString& redraw(gPainter *rc, const eRect& rect, gColor coActiveB, gColor coActiveF, gColor coNormalB, gColor coNormalF, int state );
};
gPixmap *eListBoxEntryTextPixmap::pm; // class member !!! the same pixmap for all entries...
eListBoxEntryTextPixmap::eListBoxEntryTextPixmap( eListBox<eListBoxEntryTextPixmap> *lb, const char* text, void *key, bool pm_visible, int align, const eString& hlptxt, int keytype )
:eListBoxEntryText((eListBox<eListBoxEntryText> *)lb, text, key, align, hlptxt, keytype )
,pm_visible(pm_visible){
if (pm_visible && !pm){
pm = eSkin::getActive()->queryImage("sselect_folder");
// or pm = loadPNG("full_path_and_name_of_png_file");
}
}
const eString &eListBoxEntryTextPixmap::redraw(gPainter *rc, const eRect& complete_rect, gColor coActiveB, gColor coActiveF, gColor coNormalB, gColor coNormalF, int state){
bool b;
if ( (b = (state == 2)) )
state = 0;
drawEntryRect( rc, complete_rect, coActiveB, coActiveF, coNormalB, coNormalF, state );
eRect rect = complete_rect;
if (pm && pm_visible){ // center pixmap
int yPos = rect.top()+((rect.height() - pm->y) / 2);
rc->blit(*pm, ePoint(rect.left()+5, yPos), rect, gPixmap::blitAlphaTest);
rect.setLeft( rect.left() + pm->x + 20 );
}
if (!para){ // render text to render para
para = new eTextPara( eRect(0, 0, rect.width(), rect.height()) );
para->setFont(font);
para->renderString(text);
para->realign(align);
}
rc->renderPara(*para, ePoint(rect.left(), rect.top()) );
if (b)
drawEntryBorder( rc, complete_rect, coActiveB, coActiveF, coNormalB, coNormalF );
return text;
}
class eBrowserMainWindow: public eWindow{
eString cur_path,folder;
eListBox<eListBoxEntryTextPixmap> *theList;
eButton *select, *status;
void makelist();
void selectdir(eListBoxEntryTextPixmap *item);
void selectfolder();
void selectionChanged(eListBoxEntryTextPixmap *item);
public:
eBrowserMainWindow();
~eBrowserMainWindow();
};
extern "C" int plugin_exec( PluginParam *par ){
eBrowserMainWindow dlg;
dlg.show();
int result=dlg.exec();
dlg.hide();
return result;
}
eBrowserMainWindow::eBrowserMainWindow(): eWindow(1){ //setting up the dlg
cur_path="/var"; //the startdir
cmove(ePoint(100, 125));
cresize(eSize(520, 355));
setText(cur_path);
theList = new eListBox<eListBoxEntryTextPixmap>(this);
theList->move(ePoint(5, 5));
theList->resize(eSize(clientrect.width() - 10, clientrect.height() - 55));
theList->setColumns(1);
// connecting the listboxentrys with two object functions
CONNECT(theList->selchanged, eBrowserMainWindow::selectionChanged);
CONNECT(theList->selected, eBrowserMainWindow::selectdir);
select = new eButton(this);
select->move(ePoint(360, clientrect.height() - 45));
select->resize(eSize(155,40));
select->setText("OK");
select->setProperty("align", "center");
select->setShortcut("green");
select->setShortcutPixmap("green");
select->loadDeco();
CONNECT(select->selected, eBrowserMainWindow::selectfolder);
//used as a statuslabel
status = new eButton(this);
status->move(ePoint(5, clientrect.height() - 45));
status->resize(eSize(clientrect.width() - 165, 40));
status->setProperty("align", "left");
status->setText(cur_path);
status->loadDeco();
// making the listboxentrys
makelist();
}
void eBrowserMainWindow::selectdir(eListBoxEntryTextPixmap *item){
folder = item->getText();
if(folder.compare("[eine Ebene nach oben]")== 0){ //cutting the last folder of cur_path
int last_dir = cur_path.find_last_of("/");
cur_path.erase(last_dir);
makelist();
}
else{ //add new folder to cur_path
cur_path +="/" + folder;
makelist();
}
}
void eBrowserMainWindow::selectionChanged(eListBoxEntryTextPixmap *item){ //setting statustext and selectbutton
if (item){
folder = item->getText();
if(folder.compare("[eine Ebene nach oben]")== 0){
status->setText("cd ..");
select->hide();
}
else{
folder = item->getText();
if(cur_path.compare("")== 0)
setText("/");
status->setText(item->getText());
select->show();
}
}
}
void eBrowserMainWindow::makelist(){
int n=-1;
DIR *dir = opendir((cur_path +"/").c_str());
if (dir == 0) {
eMessageBox msg(("I/O Fehler"), "Fehler", eMessageBox::iconError|eMessageBox::btOK);
msg.show();
msg.exec();
msg.hide();
eWidget::accept();
}
else{
if(NULL != dir){
setText(cur_path);
theList->beginAtomic();
theList->clearList();
if(cur_path.compare("") != 0){
new eListBoxEntryTextPixmap(theList, "[eine Ebene nach oben]", (void *) (n++),false,2);
status->setText("cd ..");
}
else{
select->show();
}
struct dirent64 *entry;
for(; NULL != (entry = readdir64(dir)); ){
struct stat64 st;
// Skip dots
if( '.' == entry->d_name[0] && ( '\0' == entry->d_name[1] || ( '.' == entry->d_name[1] &&'\0' == entry->d_name[2]))){
// do nothing
}
else{
if(0 == stat64((cur_path + "/" + entry->d_name).c_str(), &st)){
if(S_IFDIR == (st.st_mode & S_IFDIR)){
new eListBoxEntryTextPixmap(theList, entry->d_name, (void *) (n++),true);
if(n == 0)status->setText(entry->d_name);
}
}
}
}
closedir(dir);
DIR *dir = opendir((cur_path +"/").c_str());
if(NULL != dir){
char space[] = " ";
for(; NULL != (entry = readdir64(dir)); ){
struct stat64 st;
if(0 == stat64((cur_path + "/" + entry->d_name).c_str(), &st)){
if(S_IFREG == (st.st_mode &S_IFREG)){
new eListBoxEntryTextPixmap(theList, strcat (space,entry->d_name), (void *) (n++));
if(n == 0)status->setText(entry->d_name);
strcpy(space, " ");
}
}
}
}
closedir(dir);
theList->endAtomic();
theList->moveSelection(eListBoxBase::dirFirst);
setFocus(theList);
}
}
}
void eBrowserMainWindow::selectfolder(){
// an info dlg to show the result
eMessageBox msg((cur_path + "/" + folder), "gewählt", eMessageBox::iconInfo|eMessageBox::btOK);
msg.show();
msg.exec();
msg.hide();
eWidget::accept(); // exit dlg
}
eBrowserMainWindow::~eBrowserMainWindow(){
}
Alles anzeigen
Gruß Emanuel
Hi,
popen hatte für meine Zwecke keine saubere Ausgabe,
Ich weiß auch nicht wieso.
Jetzt nehme ich einen Teil aus script.cpp
der meine Zwecke erfüllt.
/*
+--------------------------------------------------------------------------
|
| Enigma 1 GUI plugin
| executing a comand with buffering the result
|
+---------------------------------------------------------------------------
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <plugin.h>
#include <lib/gui/ewindow.h>
#include <lib/gui/elabel.h>
#include <lib/gui/ebutton.h>
#include <lib/gui/emessage.h>
#include <lib/gui/eprogress.h>
#include <lib/gui/eskin.h>
#include <lib/gdi/font.h>
#include <lib/gui/guiactions.h>
#include <lib/system/info.h>
class eShowFile: public eWindow
{
eTimer *timer;
eLabel *label;
eWidget *visible;
eProgress *scrollbar;
int pageHeight;
int total;
int eventHandler(const eWidgetEvent &event);
void updateScrollbar();
public:
eShowFile();
};
class eBibleMainWindow: public eWindow
{
eLabel *label;
void executeCom();
public:
eBibleMainWindow();
~eBibleMainWindow();
};
extern "C" int plugin_exec( PluginParam *par )
{
eBibleMainWindow dlg;
dlg.show();
int result=dlg.exec();
dlg.hide();
return result;
}
eBibleMainWindow::eBibleMainWindow(): eWindow(1){
cmove(ePoint(100, 100));
cresize(eSize(520, 376));
setText("system(Comand) > msg");
label=new eLabel(this);
label->move(ePoint(20, 50));
label->resize(eSize(400, 100));
label->setText("start a ls command!");
eButton * ok = new eButton(this);
ok->setText("OK");
ok->move(ePoint((clientrect.width() - 200)/2, clientrect.height() - 60));
ok->resize(eSize(90, 40));
ok->loadDeco();
CONNECT(ok->selected, eBibleMainWindow::executeCom);
setFocus(ok);
}
void eBibleMainWindow::executeCom(){
system(eString().sprintf("ls -l > /var/tmp/info.out 2>&1").c_str());
hide();
eShowFile execute;
execute.show();
execute.exec();
execute.hide();
show();
}
eShowFile::eShowFile():
eWindow(1){
cmove(ePoint(100, 150));
cresize(eSize(520, 200));
setText((_("Output")));
scrollbar = new eProgress(this);
scrollbar->setName("scrollbar");
scrollbar->setStart(0);
scrollbar->setPerc(100);
scrollbar->move(ePoint(width() - 30, 5));
scrollbar->resize(eSize(20, height() - 100));
scrollbar->setProperty("direction", "1");
visible = new eWidget(this);
visible->setName("visible");
visible->move(ePoint(10, 5));
visible->resize(eSize(width() - 40, height() - 100));
eString strview;
char buf[256];
FILE *f = fopen("/var/tmp/info.out", "rt");
if (f)
{
int len = 0;
while (fgets(buf, 256, f))
{
len += strlen(buf);
if (len <= 65536)
strview += eString().sprintf("%s", buf);
}
fclose(f);
}
::unlink("/var/tmp/info.out");
label = new eLabel(visible);
label->setFlags(RS_WRAP);
label->setFont(eSkin::getActive()->queryFont("eStatusBar"));
float lineheight = fontRenderClass::getInstance()->getLineHeight(label->getFont());
int lines = (int) (visible->getSize().height() / lineheight);
pageHeight = (int) (lines * lineheight);
visible->resize(eSize(visible->getSize().width(), pageHeight + (int) (lineheight / 6)));
label->resize(eSize(visible->getSize().width(), pageHeight * 16));
label->hide();
label->move(ePoint(0, 0));
label->setText(strview);
updateScrollbar();
label->show();
timer = new eTimer(eApp);
CONNECT(timer->timeout, eWidget::accept);
timer->start(10000);
}
int eShowFile::eventHandler(const eWidgetEvent & event){
switch (event.type)
{
case eWidgetEvent::evtAction:
if (total && event.action == &i_cursorActions->up)
{
ePoint curPos = label->getPosition();
if (curPos.y() < 0)
{
label->move(ePoint(curPos.x(), curPos.y() + pageHeight));
updateScrollbar();
}
}
else if (total && event.action == &i_cursorActions->down)
{
ePoint curPos = label->getPosition();
if ((total - pageHeight) >= abs(curPos.y() - pageHeight))
{
label->move(ePoint(curPos.x(), curPos.y() - pageHeight));
updateScrollbar();
}
}
else if (event.action == &i_cursorActions->cancel)
close(0);
else
break;
return 1;
default:
break;
}
return eWindow::eventHandler(event);
}
void eShowFile::updateScrollbar(){
total = pageHeight;
int pages = 1;
while (total < label->getExtend().height())
{
total += pageHeight;
pages++;
}
int start = -label->getPosition().y() * 100 / total;
int vis = pageHeight * 100 / total;
scrollbar->setParams(start, vis);
scrollbar->show();
if (pages == 1)
total = 0;
}
eBibleMainWindow::~eBibleMainWindow(){
}
Alles anzeigen
Gruß Emanuel
Hi,
Ich habe den browser mal in ein *.h zur besseren Übersicht.
Plugin läuft.
Plugin
#include <plugin.h>
#include <stdio.h>
#include <lib/gui/ewindow.h>
#include <lib/gui/elabel.h>
#include <lib/gui/ebutton.h>
#include <lib/gui/emessage.h>
#include <lib/gui/textinput.h>
#include <lib/gui/combobox.h>
#include <lib/gui/statusbar.h>
#include <lib/gui/eskin.h>
#include <lib/gdi/gfbdc.h>
#include "eseldir.h"
class ePixMainWindow: public eWindow{
gPixmap *folderpic;
eButton *btnfindpath;
void action();
public:
eString start_dir;
ePixMainWindow();
~ePixMainWindow();
};
// The plugin entry point
extern "C" int plugin_exec( PluginParam *par ){
ePixMainWindow dlg;
dlg.show();
int result=dlg.exec();
dlg.hide();
return result;
}
ePixMainWindow::ePixMainWindow(): eWindow(1){
start_dir = "/var";
folderpic = eSkin::getActive()->queryImage("sselect_folder");
cmove(ePoint(100, 100));
cresize(eSize(520, 376));
setText("Pixmapbutton");
//creating a pixmapbutton with folder-png
btnfindpath = new eButton(this);
if(folderpic){
btnfindpath->move(ePoint(5, 50));
btnfindpath->resize(eSize(clientrect.width() - 10, 40));
btnfindpath->setBlitFlags(BF_ALPHATEST);
btnfindpath->setProperty("align", "center");
btnfindpath->setPixmap(folderpic);
btnfindpath->setPixmapPosition(ePoint(40, 6));
btnfindpath->loadDeco();
btnfindpath->setText(start_dir);
CONNECT(btnfindpath->selected, ePixMainWindow::action);
setFocus(btnfindpath);
}
else{
eMessageBox msg(_("Error loading icon"), _("Error"), eMessageBox::iconWarning|eMessageBox::btOK);
msg.show(); msg.exec(); msg.hide();
}
}
void ePixMainWindow::action()
{
eSeldir wd(start_dir); //starting the eSeldir browser object
wd.show();
wd.exec();
wd.hide();
btnfindpath->setText(wd.selectedpath); //result the eSeldir browser selection "path"
this->show();
}
ePixMainWindow::~ePixMainWindow()
{
}
Alles anzeigen
"eseldir.h"
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <sys/types.h>
#include <sys/stat.h>
#include <dirent.h>
#include <lib/gui/elabel.h>
#include <lib/gui/ebutton.h>
#include <lib/gui/emessage.h>
#include <lib/gui/listbox.h>
#include <lib/gui/eskin.h>
#include <lib/gdi/font.h>
using namespace std;
class eListBoxEntryTextPixmap: public eListBoxEntryText{
static gPixmap *pm; // class member !!! the same pixmap for all entries...
bool pm_visible;
public:
eListBoxEntryTextPixmap(eListBox<eListBoxEntryTextPixmap>* lb, const char* txt=0, void *key=0, bool pm_visible=false, int align=0, const eString &hlptxt="", int keytype = value );
const eString& redraw(gPainter *rc, const eRect& rect, gColor coActiveB, gColor coActiveF, gColor coNormalB, gColor coNormalF, int state );
};
gPixmap *eListBoxEntryTextPixmap::pm; // class member !!! the same pixmap for all entries...
eListBoxEntryTextPixmap::eListBoxEntryTextPixmap( eListBox<eListBoxEntryTextPixmap> *lb, const char* text, void *key, bool pm_visible, int align, const eString& hlptxt, int keytype )
:eListBoxEntryText((eListBox<eListBoxEntryText> *)lb, text, key, align, hlptxt, keytype )
,pm_visible(pm_visible){
if (pm_visible && !pm){
pm = eSkin::getActive()->queryImage("sselect_folder");
// or pm = loadPNG("full_path_and_name_of_png_file");
}
}
const eString &eListBoxEntryTextPixmap::redraw(gPainter *rc, const eRect& complete_rect, gColor coActiveB, gColor coActiveF, gColor coNormalB, gColor coNormalF, int state){
bool b;
if ( (b = (state == 2)) )
state = 0;
drawEntryRect( rc, complete_rect, coActiveB, coActiveF, coNormalB, coNormalF, state );
eRect rect = complete_rect;
if (pm && pm_visible){ // center pixmap
int yPos = rect.top()+((rect.height() - pm->y) / 2);
rc->blit(*pm, ePoint(rect.left()+5, yPos), rect, gPixmap::blitAlphaTest);
rect.setLeft( rect.left() + pm->x + 20 );
}
if (!para){ // render text to render para
para = new eTextPara( eRect(0, 0, rect.width(), rect.height()) );
para->setFont(font);
para->renderString(text);
para->realign(align);
}
rc->renderPara(*para, ePoint(rect.left(), rect.top()) );
if (b)
drawEntryBorder( rc, complete_rect, coActiveB, coActiveF, coNormalB, coNormalF );
return text;
}
class eSeldir: public eWindow{
eString cur_path, folder;
eListBox<eListBoxEntryTextPixmap> *theList;
eButton *select, *status;
void makelist();
void selectdir(eListBoxEntryTextPixmap *item);
void selectfolder();
void selectionChanged(eListBoxEntryTextPixmap *item);
public:
eString selectedpath;
eSeldir(eString startpath);
~eSeldir();
};
eSeldir::eSeldir(eString startpath): eWindow(0){ //setting up the dlg
cur_path=startpath; //the startdir
cmove(ePoint(100, 125));
cresize(eSize(520, 355));
setText(cur_path);
theList = new eListBox<eListBoxEntryTextPixmap>(this);
theList->move(ePoint(5, 5));
theList->resize(eSize(clientrect.width() - 10, clientrect.height() - 55));
theList->setColumns(1);
// connecting the listboxentrys with two object functions
CONNECT(theList->selchanged, eSeldir::selectionChanged);
CONNECT(theList->selected, eSeldir::selectdir);
select = new eButton(this);
select->move(ePoint(360, clientrect.height() - 45));
select->resize(eSize(155,40));
select->setText("OK");
select->setProperty("align", "center");
select->setShortcut("green");
select->setShortcutPixmap("green");
select->loadDeco();
CONNECT(select->selected, eSeldir::selectfolder);
//used as a statuslabel
status = new eButton(this);
status->move(ePoint(5, clientrect.height() - 45));
status->resize(eSize(clientrect.width() - 165, 40));
status->setProperty("align", "left");
status->setText(cur_path);
status->loadDeco();
// making the listboxentrys
makelist();
}
void eSeldir::selectdir(eListBoxEntryTextPixmap *item){
folder = item->getText();
if(folder.compare("[eine Ebene nach oben]")== 0){ //cutting the last folder of cur_path
int last_dir = cur_path.find_last_of("/");
cur_path.erase(last_dir);
makelist();
}
else{ //add new folder to cur_path
cur_path +="/" + folder;
makelist();
}
}
void eSeldir::selectionChanged(eListBoxEntryTextPixmap *item){ //setting statustext and selectbutton
if (item){
folder = item->getText();
if(folder.compare("[eine Ebene nach oben]")== 0){
status->setText("cd ..");
select->hide();
}
else{
folder = item->getText();
if(cur_path.compare("")== 0)
setText("/");
status->setText(item->getText());
select->show();
}
}
}
void eSeldir::makelist(){
int n=-1;
DIR *dir = opendir((cur_path +"/").c_str());
if (dir == 0) {
eMessageBox msg(("I/O Fehler"), "Fehler", eMessageBox::iconError|eMessageBox::btOK);
msg.show();
msg.exec();
msg.hide();
eWidget::accept();
}
else{
if(NULL != dir){
setText(cur_path);
theList->beginAtomic();
theList->clearList();
if(cur_path.compare("") != 0){
new eListBoxEntryTextPixmap(theList, "[eine Ebene nach oben]", (void *) (n++),false,2);
status->setText("cd ..");
}
else{
select->show();
}
struct dirent64 *entry;
for(; NULL != (entry = readdir64(dir)); ){
struct stat64 st;
// Skip dots
if( '.' == entry->d_name[0] && ( '\0' == entry->d_name[1] || ( '.' == entry->d_name[1] &&'\0' == entry->d_name[2]))){
// do nothing
}
else{
if(0 == stat64((cur_path + "/" + entry->d_name).c_str(), &st)){
if(S_IFDIR == (st.st_mode & S_IFDIR)){
new eListBoxEntryTextPixmap(theList, entry->d_name, (void *) (n++),true);
if(n == 0)status->setText(entry->d_name);
}
}
}
}
closedir(dir);
theList->endAtomic();
theList->moveSelection(eListBoxBase::dirFirst);
setFocus(theList);
}
}
}
void eSeldir::selectfolder(){
// an info dlg to show the result
eMessageBox msg((cur_path + "/" + folder), "gewählt", eMessageBox::iconInfo|eMessageBox::btOK);
msg.show();
msg.exec();
msg.hide();
selectedpath = cur_path + "/" + folder;
close(0); // exit dlg
}
eSeldir::~eSeldir(){
}
Alles anzeigen
Gruß Emanuel
Hi,
wie schon angekündigt, habe ich mich mal mit den eStrings befaßt,
es läuft schön, ob die eString Syntax 100% richtig sind weiß ich nicht.
Ich wäre dankbar für Rückmeldungen!
/*
+--------------------------------------------------------------------------
|
| eBrowser
|
| Enigma 1 API GUI
|
+---------------------------------------------------------------------------
*/
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <sys/types.h>
#include <sys/stat.h>
#include <dirent.h>
#include <plugin.h>
#include <lib/gui/elabel.h>
#include <lib/gui/ebutton.h>
#include <lib/gui/emessage.h>
#include <lib/gui/listbox.h>
#include <lib/gui/eskin.h>
#include <lib/gdi/font.h>
using namespace std;
class eListBoxEntryTextPixmap: public eListBoxEntryText{
static gPixmap *pm; // class member !!! the same pixmap for all entries...
bool pm_visible;
public:
eListBoxEntryTextPixmap(eListBox<eListBoxEntryTextPixmap>* lb, const char* txt=0, void *key=0, bool pm_visible=false, int align=0, const eString &hlptxt="", int keytype = value );
const eString& redraw(gPainter *rc, const eRect& rect, gColor coActiveB, gColor coActiveF, gColor coNormalB, gColor coNormalF, int state );
};
gPixmap *eListBoxEntryTextPixmap::pm; // class member !!! the same pixmap for all entries...
eListBoxEntryTextPixmap::eListBoxEntryTextPixmap( eListBox<eListBoxEntryTextPixmap> *lb, const char* text, void *key, bool pm_visible, int align, const eString& hlptxt, int keytype )
:eListBoxEntryText((eListBox<eListBoxEntryText> *)lb, text, key, align, hlptxt, keytype )
,pm_visible(pm_visible){
if (pm_visible && !pm){
pm = eSkin::getActive()->queryImage("sselect_folder");
// or pm = loadPNG("full_path_and_name_of_png_file");
}
}
const eString &eListBoxEntryTextPixmap::redraw(gPainter *rc, const eRect& complete_rect, gColor coActiveB, gColor coActiveF, gColor coNormalB, gColor coNormalF, int state){
bool b;
if ( (b = (state == 2)) )
state = 0;
drawEntryRect( rc, complete_rect, coActiveB, coActiveF, coNormalB, coNormalF, state );
eRect rect = complete_rect;
if (pm && pm_visible){ // center pixmap
int yPos = rect.top()+((rect.height() - pm->y) / 2);
rc->blit(*pm, ePoint(rect.left()+5, yPos), rect, gPixmap::blitAlphaTest);
rect.setLeft( rect.left() + pm->x + 20 );
}
if (!para){ // render text to render para
para = new eTextPara( eRect(0, 0, rect.width(), rect.height()) );
para->setFont(font);
para->renderString(text);
para->realign(align);
}
rc->renderPara(*para, ePoint(rect.left(), rect.top()) );
if (b)
drawEntryBorder( rc, complete_rect, coActiveB, coActiveF, coNormalB, coNormalF );
return text;
}
class eBrowserMainWindow: public eWindow{
eString cur_path,folder;
eListBox<eListBoxEntryTextPixmap> *theList;
eButton *select, *status;
void makelist();
void selectdir(eListBoxEntryTextPixmap *item);
void selectfolder();
void selectionChanged(eListBoxEntryTextPixmap *item);
public:
eBrowserMainWindow();
~eBrowserMainWindow();
};
extern "C" int plugin_exec( PluginParam *par ){
eBrowserMainWindow dlg;
dlg.show();
int result=dlg.exec();
dlg.hide();
return result;
}
eBrowserMainWindow::eBrowserMainWindow(): eWindow(1){ //setting up the dlg
cur_path="/var"; //the startdir
cmove(ePoint(100, 125));
cresize(eSize(520, 355));
setText(cur_path);
theList = new eListBox<eListBoxEntryTextPixmap>(this);
theList->move(ePoint(5, 5));
theList->resize(eSize(clientrect.width() - 10, clientrect.height() - 55));
theList->setColumns(1);
// connecting the listboxentrys with two object functions
CONNECT(theList->selchanged, eBrowserMainWindow::selectionChanged);
CONNECT(theList->selected, eBrowserMainWindow::selectdir);
select = new eButton(this);
select->move(ePoint(360, clientrect.height() - 45));
select->resize(eSize(155,40));
select->setText("OK");
select->setProperty("align", "center");
select->setShortcut("green");
select->setShortcutPixmap("green");
select->loadDeco();
CONNECT(select->selected, eBrowserMainWindow::selectfolder);
//used as a statuslabel
status = new eButton(this);
status->move(ePoint(5, clientrect.height() - 45));
status->resize(eSize(clientrect.width() - 165, 40));
status->setProperty("align", "left");
status->setText(cur_path);
status->loadDeco();
// making the listboxentrys
makelist();
}
void eBrowserMainWindow::selectdir(eListBoxEntryTextPixmap *item){
folder = item->getText();
if(folder.compare("[eine Ebene nach oben]")== 0){ //cutting the last folder of cur_path
int last_dir = cur_path.find_last_of("/");
cur_path.erase(last_dir);
makelist();
}
else{ //add new folder to cur_path
cur_path +="/" + folder;
makelist();
}
}
void eBrowserMainWindow::selectionChanged(eListBoxEntryTextPixmap *item){ //setting statustext and selectbutton
if (item){
folder = item->getText();
if(folder.compare("[eine Ebene nach oben]")== 0){
status->setText("cd ..");
select->hide();
}
else{
folder = item->getText();
if(cur_path.compare("")== 0)
setText("/");
status->setText(item->getText());
select->show();
}
}
}
void eBrowserMainWindow::makelist(){
int n=-1;
DIR *dir = opendir((cur_path +"/").c_str());
if (dir == 0) {
eMessageBox msg(("I/O Fehler"), "Fehler", eMessageBox::iconError|eMessageBox::btOK);
msg.show();
msg.exec();
msg.hide();
eWidget::accept();
}
else{
if(NULL != dir){
setText(cur_path);
theList->beginAtomic();
theList->clearList();
if(cur_path.compare("") != 0){
new eListBoxEntryTextPixmap(theList, "[eine Ebene nach oben]", (void *) (n++),false,2);
status->setText("cd ..");
}
else{
select->show();
}
struct dirent64 *entry;
for(; NULL != (entry = readdir64(dir)); ){
struct stat64 st;
// Skip dots
if( '.' == entry->d_name[0] && ( '\0' == entry->d_name[1] || ( '.' == entry->d_name[1] &&'\0' == entry->d_name[2]))){
// do nothing
}
else{
if(0 == stat64((cur_path + "/" + entry->d_name).c_str(), &st)){
if(S_IFDIR == (st.st_mode & S_IFDIR)){
new eListBoxEntryTextPixmap(theList, entry->d_name, (void *) (n++),true);
if(n == 0)status->setText(entry->d_name);
}
}
}
}
closedir(dir);
theList->endAtomic();
theList->moveSelection(eListBoxBase::dirFirst);
setFocus(theList);
}
}
}
void eBrowserMainWindow::selectfolder(){
// an info dlg to show the result
eMessageBox msg((cur_path + "/" + folder), "gewählt", eMessageBox::iconInfo|eMessageBox::btOK);
msg.show();
msg.exec();
msg.hide();
eWidget::accept(); // exit dlg
}
eBrowserMainWindow::~eBrowserMainWindow(){
}
Alles anzeigen
Gruß Emanuel
Hi,
soweit so gut, es ist noch nicht das Ende (Stingverarbeitung, Dirverarbeitung checke ich noch)
aber hier mal eine funktionsfähige Vorabversion:
/*
+--------------------------------------------------------------------------
|
| eBrowser
|
| Enigma 1 API GUI
|
+---------------------------------------------------------------------------
*/
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <sys/types.h>
#include <sys/stat.h>
#include <dirent.h>
#include <plugin.h>
#include <lib/gui/elabel.h>
#include <lib/gui/ebutton.h>
#include <lib/gui/emessage.h>
#include <lib/gui/listbox.h>
#include <lib/gui/eskin.h>
#include <lib/gdi/font.h>
using namespace std;
class eListBoxEntryTextPixmap: public eListBoxEntryText{
static gPixmap *pm; // class member !!! the same pixmap for all entries...
bool pm_visible;
public:
eListBoxEntryTextPixmap(eListBox<eListBoxEntryTextPixmap>* lb, const char* txt=0, void *key=0, bool pm_visible=false, int align=0, const eString &hlptxt="", int keytype = value );
const eString& redraw(gPainter *rc, const eRect& rect, gColor coActiveB, gColor coActiveF, gColor coNormalB, gColor coNormalF, int state );
};
gPixmap *eListBoxEntryTextPixmap::pm; // class member !!! the same pixmap for all entries...
eListBoxEntryTextPixmap::eListBoxEntryTextPixmap( eListBox<eListBoxEntryTextPixmap> *lb, const char* text, void *key, bool pm_visible, int align, const eString& hlptxt, int keytype )
:eListBoxEntryText((eListBox<eListBoxEntryText> *)lb, text, key, align, hlptxt, keytype )
,pm_visible(pm_visible){
if (pm_visible && !pm){
pm = eSkin::getActive()->queryImage("sselect_folder");
// or pm = loadPNG("full_path_and_name_of_png_file");
}
}
const eString &eListBoxEntryTextPixmap::redraw(gPainter *rc, const eRect& complete_rect, gColor coActiveB, gColor coActiveF, gColor coNormalB, gColor coNormalF, int state){
bool b;
if ( (b = (state == 2)) )
state = 0;
drawEntryRect( rc, complete_rect, coActiveB, coActiveF, coNormalB, coNormalF, state );
eRect rect = complete_rect;
if (pm && pm_visible){ // center pixmap
int yPos = rect.top()+((rect.height() - pm->y) / 2);
rc->blit(*pm, ePoint(rect.left()+5, yPos), rect, gPixmap::blitAlphaTest);
rect.setLeft( rect.left() + pm->x + 10 );
}
if (!para){ // render text to render para
para = new eTextPara( eRect(10, 0, rect.width(), rect.height()) );
para->setFont(font);
para->renderString(text);
para->realign(align);
}
rc->renderPara(*para, ePoint(rect.left(), rect.top()) );
if (b)
drawEntryBorder( rc, complete_rect, coActiveB, coActiveF, coNormalB, coNormalF );
return text;
}
class eBrowserMainWindow: public eWindow{
char PATH[256];
eString folder;
eListBox<eListBoxEntryTextPixmap> *theList;
eButton *select, *status;
void makelist();
void selectdir(eListBoxEntryTextPixmap *item);
void selectfolder();
void selectionChanged(eListBoxEntryTextPixmap *item);
public:
eBrowserMainWindow();
~eBrowserMainWindow();
};
extern "C" int plugin_exec( PluginParam *par ){
eBrowserMainWindow dlg;
dlg.show();
int result=dlg.exec();
dlg.hide();
return result;
}
eBrowserMainWindow::eBrowserMainWindow(): eWindow(1){ //setting up the dlg
strcpy(PATH,"/var/"); //the startdir
cmove(ePoint(100, 125));
cresize(eSize(520, 355));
setText("/var");
theList = new eListBox<eListBoxEntryTextPixmap>(this);
theList->move(ePoint(5, 5));
theList->resize(eSize(clientrect.width() - 10, clientrect.height() - 55));
theList->setColumns(1);
select = new eButton(this);
select->move(ePoint(360, clientrect.height() - 45));
select->resize(eSize(155,40));
select->setText("OK");
select->setProperty("align", "center");
select->setShortcut("green");
select->setShortcutPixmap("green");
select->loadDeco();
CONNECT(select->selected, eBrowserMainWindow::selectfolder);
//used as a statuslabel
status = new eButton(this);
status->move(ePoint(5, clientrect.height() - 45));
status->resize(eSize(clientrect.width() - 165, 40));
status->setProperty("align", "left");
status->setText("/var");
status->loadDeco();
// making the listboxentrys
makelist();
// connecting the listboxentrys with two object functions
CONNECT(theList->selchanged, eBrowserMainWindow::selectionChanged);
CONNECT(theList->selected, eBrowserMainWindow::selectdir);
}
void eBrowserMainWindow::selectdir(eListBoxEntryTextPixmap *item){
folder = item->getText();
if(strcmp("[eine Ebene nach oben]", eString().sprintf("%s",folder.c_str()).c_str()) == 0){
//str cutting
int n = strlen(PATH);
while(PATH[n-2] != '/'){
n--;
}
PATH[n-1] = '\0';
makelist();
}
else{
strcat(PATH, eString().sprintf("%s/",folder.c_str()).c_str());
makelist();
}
}
void eBrowserMainWindow::selectionChanged(eListBoxEntryTextPixmap *item){
if (item){
folder = item->getText();
if(strcmp("[eine Ebene nach oben]", eString().sprintf("%s",folder.c_str()).c_str()) == 0){
status->setText("cd ..");
select->hide();
}
else{
status->setText(item->getText());
select->show();
}
}
}
void eBrowserMainWindow::makelist(){
int n=-1;
DIR *dir = opendir(PATH);
char PATHSHOW[256];
strcpy(PATHSHOW, PATH);
PATHSHOW[strlen(PATHSHOW)-1] = '\0';
if (dir == 0) { // check if fileload faild
eMessageBox msg(("I/O Fehler"), "Fehler", eMessageBox::iconError|eMessageBox::btOK);
msg.show();
msg.exec();
msg.hide();
eWidget::accept(); // exit dlg
}
else{
if(NULL != dir){
setText(PATHSHOW);
theList->beginAtomic();
theList->clearList();
if(strcmp("/",PATH) != 0){ // building cd .. entry if not rootdir
new eListBoxEntryTextPixmap(theList, "[eine Ebene nach oben]", (void *) (n++),false,2);
select->hide();
}
else{
setText(PATH);
select->show();
}
struct dirent *entry;
for(; NULL != (entry = readdir(dir)); ){
struct stat st;
// Skip dots
if( '.' == entry->d_name[0] && ( '\0' == entry->d_name[1] || ( '.' == entry->d_name[1] &&'\0' == entry->d_name[2]))){
// if . do nothing
}
else{
if(0 == stat((string(PATH) + entry->d_name).c_str(), &st)){ // building folderentrys if it is a dir
if(S_IFDIR == (st.st_mode & S_IFDIR)){
new eListBoxEntryTextPixmap(theList, entry->d_name, (void *) (n++),true);
}
}
}
}
closedir(dir);
theList->moveSelection(eListBoxBase::dirFirst);
theList->endAtomic();
setFocus(theList);
}
}
}
void eBrowserMainWindow::selectfolder(){
// an info dlg to show the result
eMessageBox msg((strcat(PATH, eString().sprintf("%s",status->getText().c_str()).c_str())), "gewählt", eMessageBox::iconInfo|eMessageBox::btOK);
msg.show();
msg.exec();
msg.hide();
eWidget::accept(); // exit dlg
}
eBrowserMainWindow::~eBrowserMainWindow(){
}
Alles anzeigen
Gruß Emanuel
Hi @all,
Ich will ein Kommando in einem Plugin ausführen.
die Ausgabe soll dann als Info-msg erscheinen.
bsp.
mit Ausgabe in einen Puffer (oder tmp-file) und anzeigen mit einem ewindow.
So kann ich das C-männisch Lösen.
Ich habe jetzt erfahren enigma hat bereits ein Objekt eConsoleAppContainer
> console.cpp,
das konnte ich aber noch nicht testet, und der src ist ca 10 mal so lang wie das, was ich vor habe also meine Frage:
hat jemand von euch Erfahrung mit eConsoleAppContainer?
Gruß Emanuel
Hi Ghost,
Ja toll, jetzt funktioniert es endlich.
Da waren ja einige Hürden drin.
Vielen Dank nochmal!
Emanuel
Hi Ghost Danke!
hätte ich selber sehen sollen ups.
______________________________________________________________________
Wie schalte ich die pixmap ein?
new eListBoxEntryTextPixmap(theList, "Kreuz", (void *) (1),true, 2,"Es ist ein Kreuz!");
das true kommt zwar an aber die pixmap wird nicht angezeigt!
Gruß Emanuel
Hi Ghost,
Ich habe die configure.ac im Pluginverzeichnis angepasst.
Ich habe den src von Dir ausprobiert.
Jetzt lässt sich das Plugin zwar problemlos kompilieren,
aber wenn ich es ausführen will, blitzt es nur ganz kurz am TV auf.
Es bleibt nicht sichtbar, selbst wenn ich hide(); rausnehme.
Es blizt zwar nur kurz auf,trotzdem habe ich versucht mit:
new eListBoxEntryTextPixmap(theList, "Kreuz", (void *) (1),(bool) (true));
die pixmap zu aktivieren ging auch nicht.
Gruß Emanuel
Hi Ghost,
Danke für die Mühe.
Ich teste es mal am Abend.
Ich hätte das nicht fixen können.
cu =)
Hi anbei:
#include <plugin.h>
#include <stdio.h>
#include <lib/gui/ewindow.h>
#include <lib/gui/elabel.h>
#include <lib/gui/ebutton.h>
#include <lib/gui/emessage.h>
#include <lib/gui/listbox.h>
#include "myplugin.h"
class eListboxMainWindow: public eWindow
{
eLabel *label;
eListBox<eListBoxEntryTextPixmap> *theList;
void message1(eListBoxEntryTextPixmap *item);
public:
eListboxMainWindow();
~eListboxMainWindow();
};
extern "C" int plugin_exec( PluginParam *par )
{
eListboxMainWindow dlg;
dlg.show();
dlg.hide();
return result;
}
eListboxMainWindow::eListboxMainWindow(): eWindow(1)
{
cmove(ePoint(100, 100));
cresize(eSize(520, 376));
setText("Pixlistbox");
label=new eLabel(this);
label->move(ePoint(10, 10));
label->resize(eSize(400, 60));
label->setText("Auswahl");
theList = new eListBox<eListBoxEntryTextPixmap>(this);
theList->move(ePoint(10, 100));
theList->resize(eSize(clientrect.width() - 20, clientrect.height() - 160));
theList->loadDeco();
theList->setColumns(1);
theList->beginAtomic();
theList->clearList();
new eListBoxEntryTextPixmap(theList, "Kreuz", (void *) (1));
new eListBoxEntryTextPixmap(theList, "Pic", (void *) (2));
new eListBoxEntryTextPixmap(theList, "Herz", (void *) (3));
new eListBoxEntryTextPixmap(theList, "Karo", (void *) (4));
theList->endAtomic();
CONNECT(theList->selected, eListboxMainWindow::message1);
setFocus(theList);
}
void eListboxMainWindow::message1(eListBoxEntryText *item)
{
eString message, message2;
message2 = item->getText();
message = "Farbe:\n " + message2;
eMessageBox msg((message), "Info", eMessageBox::iconInfo|eMessageBox::btOK);
msg.show();
msg.exec();
msg.hide();
}
eListboxMainWindow::~eListboxMainWindow()
{
}
Alles anzeigen
#include <lib/gui/epixmap.h>
#include <lib/driver/rc.h>
#include <lib/gdi/grc.h>
class eListBoxEntryTextPixmap: public eListBoxEntryText
{
static gPixmap *pm; // class member !!! the same pixmap for all entries...
bool pm_visible;
public:
eListBoxEntryTextPixmap(eListBox<eListBoxEntryTextPixmap>* lb, const char* txt=0, void *key=0, bool pm_visible=false, int align=0, const eString &hlptxt="", int keytype = value )
const eString& redraw(gPainter *rc, const eRect& rect, gColor coActiveB, gColor coActiveF, gColor coNormalB, gColor coNormalF, int state );
};
eListBoxEntryTextPixmap::eListBoxEntryTextPixmap( eListBox<eListBoxEntryMenu> *lb, const char* text, void *key, bool pm_visible, int align, const eString& hlptxt, int keytype )
:eListBoxEntryText(lb, text, key, align, hlptxt, keytype )
,pm(eSkin::getActive()->queryImage("eListBoxEntryCheck"))
,pm_visible(false)
{
if (pm_visible && !pm)
{
pm = eSkin::getActive()->queryImage("sselect_folder");
// load pixmap here... with pm = eSkin::getActive()->queryImage("bla");
// or pm = loadPNG("full_path_and_name_of_png_file");
}
}
const eString &eListBoxEntryTextPixmap::redraw(gPainter *rc, const eRect& complete_rect, gColor coActiveB, gColor coActiveF, gColor coNormalB, gColor, int state)
{
bool b;
if ( (b = (state == 2)) )
state = 0;
drawEntryRect( rc, complete_rect, coActiveB, coActiveF, coNormalB, coNormalF, state );
eRect rect = complete_rect;
if (pm && pm_visible)
{
int yPos = rect.top()+((rect.height() - pm->y) / 2); // center pixmap
rc->blit(*pm, ePoint(rect.left(), yPos), rect, gPixmap::blitAlphaTest );
rect.setLeft( rect.left() + pm->x + 10 );
}
if (!para) // render text to render para
{
para = new eTextPara( eRect(0, 0, rect.width(), rect.height()) );
para->setFont(font);
para->renderString(text);
para->realign(align);
}
rc->renderPara(*para, ePoint(rect.left(), rect.top()) );
if (b)
drawEntryBorder( rc, complete_rect, coActiveB, coActiveF, coNormalB, coNormalF );
return text;
}
Alles anzeigen
P.S. Die Fehlermeldung ist zu lang für die Seite
Gruß
Hi dre,
Ich wollte in den Quelltext des Browsers, der läuft, das
eListBoxEntryTextPixmap Objekt (src siehe Seite vorher von Ghost)
integrieren; aber Fehlanzeige.
Da habe ich was falsch gemacht. Ich habe den falschen src aber nicht mehr.
Emanuel
Hi tyrel,
Ich habe mal ein 7020er plugin auf ner 7000er probiert.
Da bekomme ich eine ähnliche Meldung.
Ich denke mal Du mußt das mit CSV für die 7000er
extra kompilieren, die verwendet andere Libs.
Gruß Emanuel
Hi dre,
Also ich bin vollauf zufrieden mit dem tuxcomander.
Der Browser ist eigentlich nur gedacht um in einem Plugin
per Fernbedienung, ohne viel eintippen, einen Pfad
auswählen zu können. Wenn wer mehr draus machen will, klar
kein Problem. Ist aber eine sau Arbeit, denk mal was ein
tuxcom so alles hat: Shell, Editor, Multifenster...
Aber der Realität mal ins Auge geblickt:
Das Main Plugin ist zum steuern von Apache & Php.
siehe: Wie OpenSouce patches in cdk kompilieren
Die Sache mit der font.h hat noch kein Ergebnis gebracht.
Im Moment steht alles; ich warte auf Hilfe von Ghost.
Ich habe mit C++/Gui enigma erst vor ganz kurzem begonnen.
Ich kenne sowas sonst nur von VCL-ObjektPascal und das ist gleich gar nichts
gegen enigma.
Gruß Emanuel