mirror of
https://github.com/edeproject/ede.git
synced 2023-08-10 21:13:03 +03:00
Update ede2-fltk2 branch with stuff from my disk
This commit is contained in:
parent
a00fb8164f
commit
4335ce706a
@ -1,71 +0,0 @@
|
||||
#
|
||||
# This is a default data for control panel.
|
||||
#
|
||||
# You can change them, and howto for this
|
||||
# you can find in econtrol documentation.
|
||||
|
||||
|
||||
# This is the main key, and must be present if
|
||||
# you want to control panel read it
|
||||
[Control Panel]
|
||||
Position = true
|
||||
X = 2
|
||||
Y = 3
|
||||
Width = 58
|
||||
Height = 34
|
||||
# reads econtrol.conf from user home, appending
|
||||
# values to this one
|
||||
ReadUserConf = true
|
||||
|
||||
# main items
|
||||
Items = edewmconf,ekeyconf,esvrconf,einstall,evolume, edatetime,etipconf
|
||||
|
||||
[edewmconf]
|
||||
Name = Window manager
|
||||
Tip = This item will run window manager configuration
|
||||
Exec = ewmconf
|
||||
Icon = preferences-system-windows
|
||||
IconPathAbsolute = false
|
||||
|
||||
[ekeyconf]
|
||||
Name = Keyboard configuration
|
||||
Tip = This item will run keyboard configuration
|
||||
Exec = konqueror
|
||||
#Icon = preferences-desktop-font
|
||||
Icon = accessories-character-map
|
||||
IconPathAbsolute = false
|
||||
|
||||
[esvrconf]
|
||||
Name = Screensaver configuration
|
||||
Tip = This item will configure screensaver
|
||||
Exec = esvrconf
|
||||
Icon = preferences-desktop-screensaver
|
||||
IconPathAbsolute = false
|
||||
|
||||
[einstall]
|
||||
Name = Install new software
|
||||
Tip = This item will run installer
|
||||
Exec = einstall
|
||||
Icon = system-installer
|
||||
IconPathAbsolute = false
|
||||
|
||||
[evolume]
|
||||
Name = Sound preferences
|
||||
Tip = This item will set sound preferences
|
||||
Exec = evolume
|
||||
Icon = multimedia-volume-control
|
||||
IconPathAbsolute = false
|
||||
|
||||
[edatetime]
|
||||
Name = Date and time
|
||||
Tip = This item will configure date and time
|
||||
Exec = edatetime
|
||||
Icon = preferences-date-time
|
||||
IconPathAbsolute = false
|
||||
|
||||
[etipconf]
|
||||
Name = Tips
|
||||
Tip = This item will configure tips
|
||||
Exec = etipconf
|
||||
Icon = preferences-user-information
|
||||
IconPathAbsolute = false
|
@ -1,162 +1,371 @@
|
||||
/*
|
||||
* $Id$
|
||||
*
|
||||
* The EDE control center
|
||||
* Part of Equinox Desktop Environment (EDE).
|
||||
* Copyright (c) 2000-2006 EDE Authors.
|
||||
*
|
||||
* This program is licenced under terms of the
|
||||
* GNU General Public Licence version 2 or newer.
|
||||
* See COPYING for details.
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
#include <fltk/run.h>
|
||||
|
||||
#include "econtrol.h"
|
||||
|
||||
#include <edelib/Config.h>
|
||||
#include <edelib/StrUtil.h>
|
||||
#include <edelib/Debug.h>
|
||||
#include <edelib/Nls.h>
|
||||
#include "../edelib2/Run.h"
|
||||
#include "../edelib2/about_dialog.h"
|
||||
#include "../edelib2/NLS.h"
|
||||
#include "../edelib2/Icon.h"
|
||||
|
||||
#include <FL/Fl.h>
|
||||
#include <FL/Fl_Shared_Image.h>
|
||||
#include <FL/fl_draw.h>
|
||||
#include "../edeconf.h"
|
||||
|
||||
using namespace fltk;
|
||||
using namespace edelib;
|
||||
|
||||
ControlButton::ControlButton(Fl_Box* t, String tv, int x, int y, int w, int h, const char* l) :
|
||||
Fl_Button(x, y, w, h, l) {
|
||||
tip = t;
|
||||
tipval = tv;
|
||||
box(FL_FLAT_BOX);
|
||||
align(FL_ALIGN_WRAP);
|
||||
color(FL_WHITE);
|
||||
|
||||
|
||||
// Widgets
|
||||
|
||||
Window *configPanelWindow=(Window *)0;
|
||||
MenuBar *main_menubar=(MenuBar *)0;
|
||||
StatusBarGroup *status_bar=(StatusBarGroup *)0;
|
||||
ScrollGroup *scroll=(ScrollGroup *)0;
|
||||
Group *main_view=(Group *)0;
|
||||
InvisibleBox *help_window=(InvisibleBox *)0;
|
||||
|
||||
|
||||
// Callbacks
|
||||
|
||||
static void cb_Quit(Item*, void*)
|
||||
{
|
||||
exit(0);
|
||||
}
|
||||
|
||||
ControlButton::~ControlButton() {
|
||||
static void cb_About(Item*, void*)
|
||||
{
|
||||
about_dialog("Control panel", "1.99");
|
||||
}
|
||||
|
||||
int ControlButton::handle(int event) {
|
||||
switch(event) {
|
||||
case FL_ENTER:
|
||||
tip->label(tipval.c_str());
|
||||
return 1;
|
||||
case FL_LEAVE:
|
||||
tip->label("");
|
||||
return 1;
|
||||
case FL_PUSH:
|
||||
return 1;
|
||||
case FL_RELEASE:
|
||||
return 1;
|
||||
default:
|
||||
return Fl_Button::handle(event);
|
||||
}
|
||||
return Fl_Button::handle(event);
|
||||
|
||||
static void cb_Icons(Button*, void*)
|
||||
{
|
||||
help_window->label(_("Change behaviour of your desktop icons."));
|
||||
help_window->redraw();
|
||||
//if (Fl::event_clicks())
|
||||
run_program("eiconsconf &");
|
||||
}
|
||||
|
||||
void close_cb(Fl_Widget*, void* w) {
|
||||
ControlWin* cw = (ControlWin*)w;
|
||||
cw->do_close();
|
||||
|
||||
static void cb_Colors(Button*, void*)
|
||||
{
|
||||
help_window->label(_("Configure global colors and fonts used by EDE applications."));
|
||||
help_window->redraw();
|
||||
//if (Fl::event_clicks())
|
||||
run_program("ecolorconf &");
|
||||
}
|
||||
|
||||
ControlWin::ControlWin(const char* title, int w, int h) : Fl_Window(w, h, title) {
|
||||
|
||||
IconTheme::init("edeneu");
|
||||
|
||||
fl_register_images();
|
||||
load_icons();
|
||||
init();
|
||||
static void cb_Screen(Button*, void*)
|
||||
{
|
||||
help_window->label(_("Configure the screensaver."));
|
||||
help_window->redraw();
|
||||
//if (Fl::event_clicks())
|
||||
run_program("esvrconf &");
|
||||
}
|
||||
|
||||
ControlWin::~ControlWin() {
|
||||
IconTheme::shutdown();
|
||||
static void cb_Window(Button*, void*)
|
||||
{
|
||||
help_window->label(_("Setup window decorations and other options."));
|
||||
help_window->redraw();
|
||||
//if (Fl::event_clicks())
|
||||
run_program("ewmconf &");
|
||||
}
|
||||
|
||||
void ControlWin::load_icons(void) {
|
||||
Config c;
|
||||
static void cb_Display(Button*, void*)
|
||||
{
|
||||
help_window->label(_("Set various options for the X windowing system."));
|
||||
help_window->redraw();
|
||||
//if (Fl::event_clicks())
|
||||
run_program("edisplayconf &");
|
||||
}
|
||||
|
||||
if(!c.load("econtrol.conf")) {
|
||||
EWARNING("Can't load config\n");
|
||||
return;
|
||||
}
|
||||
static void cb_Install(Button*, void*)
|
||||
{
|
||||
help_window->label(_("This utility helps you to install new software."));
|
||||
help_window->redraw();
|
||||
//if (Fl::event_clicks())
|
||||
run_program("einstaller",false);
|
||||
}
|
||||
|
||||
char buff[1024];
|
||||
if(!c.get("Control Panel", "Items", buff, sizeof(buff))) {
|
||||
EWARNING("Can't find Items key\n");
|
||||
return;
|
||||
}
|
||||
static void cb_Time(Button*, void*)
|
||||
{
|
||||
help_window->label(_("Show and set computer time and date."));
|
||||
help_window->redraw();
|
||||
//if (Fl::event_clicks())
|
||||
run_program("etimedate",false);
|
||||
}
|
||||
|
||||
vector<String> spl;
|
||||
stringtok(spl, buff, ",");
|
||||
char* sect;
|
||||
static void cb_Panel(Button*, void*)
|
||||
{
|
||||
help_window->label(_("Change panel behaviour and choose applets."));
|
||||
help_window->redraw();
|
||||
//if (Fl::event_clicks())
|
||||
run_program("epanelconf",false);
|
||||
}
|
||||
|
||||
ControlIcon cicon;
|
||||
for(unsigned int i = 0; i < spl.size(); i++) {
|
||||
sect = (char*)spl[i].c_str();
|
||||
str_trim(sect);
|
||||
static void cb_Keyboard(Button*, void*)
|
||||
{
|
||||
help_window->label(_("Configure keyboard shortcuts and other options."));
|
||||
help_window->redraw();
|
||||
//if (Fl::event_clicks())
|
||||
run_program("ekeyconf",false);
|
||||
}
|
||||
|
||||
if(c.get(sect, "Name", buff, sizeof(buff)))
|
||||
cicon.name = buff;
|
||||
else {
|
||||
EWARNING("No %s, skipping...\n", spl[i].c_str());
|
||||
continue;
|
||||
static void cb_Color(Item* i, void*)
|
||||
{
|
||||
const char* label = i->label();
|
||||
if (strcmp(label,"White")==0) { scroll->color(WHITE); }
|
||||
if (strcmp(label,"Gray")==0) { scroll->color(GRAY75); }
|
||||
if (strcmp(label,"Black")==0) { scroll->color(BLACK); }
|
||||
if (strcmp(label,"Red")==0) { scroll->color(RED); }
|
||||
if (strcmp(label,"Blue")==0) { scroll->color(BLUE); }
|
||||
scroll->redraw();
|
||||
}
|
||||
|
||||
|
||||
// Main program
|
||||
|
||||
int main (int argc, char **argv) {
|
||||
|
||||
//fl_init_locale_support("econtrol", PREFIX"/share/locale");
|
||||
Window* configPanelWindow = new Window(450, 310, "Control panel");
|
||||
configPanelWindow->begin();
|
||||
{main_menubar = new MenuBar(0, 0, 450, 26);
|
||||
main_menubar->begin();
|
||||
{ItemGroup* o = new ItemGroup(_("&File"));
|
||||
o->begin();
|
||||
{Item* o = new Item(_("&Quit"));
|
||||
o->shortcut(0x40071);
|
||||
o->callback((Callback*)cb_Quit);
|
||||
//o->x_offset(18);
|
||||
}
|
||||
|
||||
if(c.get(sect, "Tip", buff, sizeof(buff)))
|
||||
cicon.tip = buff;
|
||||
if(c.get(sect, "Exec", buff, sizeof(buff)))
|
||||
cicon.exec = buff;
|
||||
if(c.get(sect, "Icon", buff, sizeof(buff))) {
|
||||
cicon.icon = buff;
|
||||
EDEBUG("setting icon (%s): %s\n", spl[i].c_str(), cicon.icon.c_str());
|
||||
}
|
||||
|
||||
c.get(spl[i].c_str(), "IconPathAbsolute", cicon.abspath, false);
|
||||
c.get(spl[i].c_str(), "Position", cicon.abspath, -1);
|
||||
|
||||
iconlist.push_back(cicon);
|
||||
o->end();
|
||||
}
|
||||
}
|
||||
|
||||
void ControlWin::init(void) {
|
||||
begin();
|
||||
titlegrp = new Fl_Group(0, 0, 455, 50);
|
||||
titlegrp->box(FL_FLAT_BOX);
|
||||
titlegrp->color(138);
|
||||
titlegrp->begin();
|
||||
title = new Fl_Box(10, 10, 435, 30, label());
|
||||
title->color(138);
|
||||
title->align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE);
|
||||
title->labelcolor(23);
|
||||
title->labelfont(FL_HELVETICA_BOLD);
|
||||
title->labelsize(16);
|
||||
titlegrp->end();
|
||||
titlegrp->resizable(title);
|
||||
|
||||
icons = new ExpandableGroup(10, 60, 435, 225);
|
||||
icons->box(FL_DOWN_BOX);
|
||||
icons->color(FL_BACKGROUND2_COLOR);
|
||||
icons->end();
|
||||
|
||||
tipbox = new Fl_Box(10, 295, 240, 25, _("Double click on desired item"));
|
||||
tipbox->box(FL_FLAT_BOX);
|
||||
tipbox->align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE|FL_ALIGN_CLIP);
|
||||
|
||||
for(unsigned int i = 0; i < iconlist.size(); i++) {
|
||||
ControlButton* b = new ControlButton(tipbox, iconlist[i].tip, 0, 0, 80, 100);
|
||||
//String iconpath = IconTheme::get(iconlist[i].icon.c_str(), ICON_SIZE_MEDIUM);
|
||||
String iconpath = IconTheme::get(iconlist[i].icon.c_str(), ICON_SIZE_LARGE);
|
||||
b->label(iconlist[i].name.c_str());
|
||||
|
||||
if(!iconpath.empty())
|
||||
b->image(Fl_Shared_Image::get(iconpath.c_str()));
|
||||
icons->add(b);
|
||||
{ItemGroup* o = new ItemGroup(_("&Color"));
|
||||
o->align(ALIGN_CENTER);
|
||||
o->begin();
|
||||
{Item* o = new Item("White");
|
||||
o->callback((Callback*)cb_Color);
|
||||
o->type(Item::RADIO);
|
||||
o->set();
|
||||
}
|
||||
|
||||
//options = new Fl_Button(260, 295, 90, 25, _("&Options"));
|
||||
close = new Fl_Button(355, 295, 90, 25, _("&Close"));
|
||||
close->callback(close_cb, this);
|
||||
|
||||
// resizable invisible box
|
||||
rbox = new Fl_Box(10, 220, 120, 65);
|
||||
resizable(rbox);
|
||||
end();
|
||||
{Item* o = new Item("Gray");
|
||||
o->callback((Callback*)cb_Color);
|
||||
o->type(Item::RADIO);
|
||||
}
|
||||
{Item* o = new Item("Black");
|
||||
o->callback((Callback*)cb_Color);
|
||||
o->type(Item::RADIO);
|
||||
}
|
||||
{Item* o = new Item("Red");
|
||||
o->callback((Callback*)cb_Color);
|
||||
o->type(Item::RADIO);
|
||||
}
|
||||
{Item* o = new Item("Blue");
|
||||
o->callback((Callback*)cb_Color);
|
||||
o->type(Item::RADIO);
|
||||
}
|
||||
o->end();
|
||||
}
|
||||
{ItemGroup* o = new ItemGroup(_("&Help"));
|
||||
o->align(ALIGN_CENTER);
|
||||
o->begin();
|
||||
{Item* o = new Item(_("&About"));
|
||||
o->shortcut(0x40061);
|
||||
o->callback((Callback*)cb_About);
|
||||
//o->x_offset(18);
|
||||
}
|
||||
o->end();
|
||||
}
|
||||
main_menubar->end();
|
||||
}
|
||||
{main_view = new Group(0, 26, 450, 280);
|
||||
main_view->begin();
|
||||
{InvisibleBox* o = new InvisibleBox(0, 0, 450, 41, _("Control panel"));
|
||||
o->box(FLAT_BOX);
|
||||
o->labeltype(SHADOW_LABEL);
|
||||
o->color((Color)0xd089d00);
|
||||
o->buttoncolor((Color)0xe6e7e600);
|
||||
o->labelcolor((Color)0xffffff00);
|
||||
o->highlight_color((Color)0xe6e7e600);
|
||||
o->labelsize(20);
|
||||
o->textsize(29);
|
||||
o->align(ALIGN_INSIDE);
|
||||
}
|
||||
{TiledGroup* o = new TiledGroup(0, 40, 450, 215);
|
||||
o->box(FLAT_BOX);
|
||||
o->color((Color)0xd93b4300);
|
||||
o->begin();
|
||||
{help_window = new InvisibleBox(0, 0, 110, 195, _("Welcome to the control panel. Here you can setup most things on your computer."));
|
||||
help_window->set_vertical();
|
||||
help_window->box(DOWN_BOX);
|
||||
help_window->color((Color)0xfff9e400);
|
||||
help_window->labelcolor((Color)32);
|
||||
help_window->align(ALIGN_WRAP);
|
||||
//help_window->set_value();
|
||||
}
|
||||
{scroll = new ScrollGroup(110, 0, 340, 195);
|
||||
scroll->box(DOWN_BOX);
|
||||
scroll->color(WHITE);
|
||||
scroll->align(ALIGN_CENTER);
|
||||
scroll->begin();
|
||||
{Button* o = new Button(0, 15, 60, 75, _("Icons"));
|
||||
o->set_vertical();
|
||||
// o->image(SharedImage::get("icons/behaviour.xpm"));
|
||||
// o->image(EDE_Icon::get("desktop-mdk",EDE_Icon::SMALL));
|
||||
// o->image(EDE_Icon::get("kappfinder",EDE_Icon::SMALL));
|
||||
o->image(Icon::get("desktop",Icon::SMALL));
|
||||
o->box(HIGHLIGHT_DOWN_BOX);
|
||||
o->buttonbox(NO_BOX);
|
||||
o->color((Color)7);
|
||||
o->highlight_color((Color)7);
|
||||
o->highlight_textcolor((Color)32);
|
||||
o->labelsize(10);
|
||||
o->callback((Callback*)cb_Icons);
|
||||
o->align(ALIGN_WRAP);
|
||||
o->tooltip(_("Icons settings"));
|
||||
}
|
||||
{Button* o = new Button(75, 15, 60, 75, _("Colors and Fonts"));
|
||||
o->set_vertical();
|
||||
// o->image(SharedImage::get("icons/themes.xpm"));
|
||||
o->image(Icon::get("fonts",Icon::SMALL));
|
||||
o->box(HIGHLIGHT_DOWN_BOX);
|
||||
o->color((Color)7);
|
||||
o->highlight_color((Color)7);
|
||||
o->highlight_textcolor((Color)32);
|
||||
o->labelsize(10);
|
||||
o->callback((Callback*)cb_Colors);
|
||||
o->align(ALIGN_WRAP);
|
||||
o->tooltip(_("Colors settings"));
|
||||
}
|
||||
{Button* o = new Button(140, 15, 60, 75, _("Screen Saver"));
|
||||
o->set_vertical();
|
||||
// o->image(SharedImage::get("icons/screensaver.xpm"));
|
||||
o->image(Icon::get("terminal",Icon::SMALL));
|
||||
o->box(HIGHLIGHT_DOWN_BOX);
|
||||
o->color((Color)7);
|
||||
o->highlight_color((Color)7);
|
||||
o->highlight_textcolor((Color)32);
|
||||
o->labelsize(10);
|
||||
o->callback((Callback*)cb_Screen);
|
||||
o->align(ALIGN_WRAP);
|
||||
o->tooltip(_("Screensaver configuration"));
|
||||
}
|
||||
{Button* o = new Button(10, 95, 60, 75, _("Window Manager"));
|
||||
o->set_vertical();
|
||||
// o->image(SharedImage::get("icons/windowmanager.xpm"));
|
||||
// o->image(EDE_Icon::get("kcmkwm",EDE_Icon::SMALL));
|
||||
// o->image(EDE_Icon::get("kpersonalizer",EDE_Icon::SMALL));
|
||||
o->image(Icon::get("window_list",Icon::SMALL));
|
||||
o->box(HIGHLIGHT_DOWN_BOX);
|
||||
o->color((Color)7);
|
||||
o->highlight_color((Color)7);
|
||||
o->highlight_textcolor((Color)32);
|
||||
o->labelsize(10);
|
||||
o->callback((Callback*)cb_Window);
|
||||
o->align(ALIGN_WRAP);
|
||||
o->tooltip(_("Window manager settings"));
|
||||
}
|
||||
{Button* o = new Button(75, 95, 60, 75, _("Display"));
|
||||
o->set_vertical();
|
||||
// o->image(SharedImage::get("icons/display.xpm"));
|
||||
// o->image(EDE_Icon::get("kcmx",EDE_Icon::SMALL));
|
||||
// o->image(EDE_Icon::get("randr",EDE_Icon::SMALL));
|
||||
o->image(Icon::get("looknfeel",Icon::SMALL));
|
||||
o->box(HIGHLIGHT_DOWN_BOX);
|
||||
o->color((Color)7);
|
||||
o->highlight_color((Color)7);
|
||||
o->highlight_textcolor((Color)32);
|
||||
o->labelsize(10);
|
||||
o->callback((Callback*)cb_Display);
|
||||
o->tooltip(_("Display settings"));
|
||||
}
|
||||
{Button* o = new Button(140, 95, 60, 75, _("Install New Software"));
|
||||
o->set_vertical();
|
||||
// o->image(SharedImage::get("icons/newsoft.xpm"));
|
||||
// o->image(EDE_Icon::get("ark",EDE_Icon::SMALL));
|
||||
o->image(Icon::get("package",Icon::SMALL));
|
||||
o->box(HIGHLIGHT_DOWN_BOX);
|
||||
o->color((Color)7);
|
||||
o->highlight_color((Color)7);
|
||||
o->highlight_textcolor((Color)32);
|
||||
o->labelsize(10);
|
||||
o->callback((Callback*)cb_Install);
|
||||
o->align(ALIGN_WRAP);
|
||||
o->tooltip(_("Software installation."));
|
||||
}
|
||||
{Button* o = new Button(205, 95, 60, 75, _("Time and Date"));
|
||||
o->set_vertical();
|
||||
// o->image(SharedImage::get("icons/timedate.xpm"));
|
||||
o->image(Icon::get("date",Icon::SMALL));
|
||||
// o->image(EDE_Icon::get("karm",EDE_Icon::SMALL));
|
||||
o->box(HIGHLIGHT_DOWN_BOX);
|
||||
o->color((Color)7);
|
||||
o->highlight_color((Color)7);
|
||||
o->highlight_textcolor((Color)32);
|
||||
o->labelsize(10);
|
||||
o->callback((Callback*)cb_Time);
|
||||
o->align(ALIGN_WRAP);
|
||||
o->tooltip(_("Time and date settings."));
|
||||
}
|
||||
{Button* o = new Button(205, 15, 60, 75, _("Panel"));
|
||||
o->set_vertical();
|
||||
// o->image(SharedImage::get("icons/panel.xpm"));
|
||||
o->image(Icon::get("kcmkicker",Icon::SMALL));
|
||||
o->box(HIGHLIGHT_DOWN_BOX);
|
||||
o->color((Color)7);
|
||||
o->highlight_color((Color)7);
|
||||
o->highlight_textcolor((Color)32);
|
||||
o->labelsize(10);
|
||||
o->callback((Callback*)cb_Panel);
|
||||
o->tooltip(_("Panel configuration."));
|
||||
}
|
||||
{Button* o = new Button(265, 15, 60, 75, _("Keyboard"));
|
||||
o->set_vertical();
|
||||
// o->image(SharedImage::get("icons/keyboard.xpm"));
|
||||
// o->image(EDE_Icon::get("kxkb",EDE_Icon::SMALL));
|
||||
o->image(Icon::get("keyboard",Icon::SMALL));
|
||||
o->box(HIGHLIGHT_DOWN_BOX);
|
||||
o->buttonbox(NO_BOX);
|
||||
o->color((Color)7);
|
||||
o->highlight_color((Color)7);
|
||||
o->highlight_textcolor((Color)32);
|
||||
o->labelsize(10);
|
||||
o->callback((Callback*)cb_Keyboard);
|
||||
o->tooltip(_("Keyboard settings"));
|
||||
}
|
||||
scroll->end();
|
||||
//o->edge_offset(10);
|
||||
}
|
||||
o->end();
|
||||
o->parent()->resizable(o);
|
||||
Group::current()->resizable(o);
|
||||
}
|
||||
main_view->end();
|
||||
Group::current()->resizable(main_view);
|
||||
}
|
||||
{status_bar = new StatusBarGroup(0, 281, 450, 24, _("Ready"));
|
||||
status_bar->box(DOWN_BOX);
|
||||
}
|
||||
|
||||
void ControlWin::do_close(void) {
|
||||
hide();
|
||||
}
|
||||
configPanelWindow->end();
|
||||
configPanelWindow->size_range(configPanelWindow->w(), configPanelWindow->h());
|
||||
|
||||
int main() {
|
||||
ControlWin cw(_("EDE Control Panel"));
|
||||
cw.show();
|
||||
return Fl::run();
|
||||
|
||||
// configPanelWindow->menu(main_menubar);
|
||||
// configPanelWindow->view(main_view);
|
||||
// configPanelWindow->status(status_bar);
|
||||
configPanelWindow->show(argc, argv);
|
||||
return run();
|
||||
}
|
||||
|
@ -1,38 +0,0 @@
|
||||
# data file for the Fltk User Interface Designer (fluid)
|
||||
version 1.0108
|
||||
header_name {.h}
|
||||
code_name {.cxx}
|
||||
Function {} {open
|
||||
} {
|
||||
Fl_Window {} {open
|
||||
xywh {392 251 455 330} type Double resizable visible
|
||||
} {
|
||||
Fl_Group {} {open
|
||||
xywh {0 0 455 50} box FLAT_BOX color 138
|
||||
} {
|
||||
Fl_Box {} {
|
||||
label {EDE Control Panel}
|
||||
xywh {10 10 435 30} box FLAT_BOX color 138 labelfont 1 labelsize 16 labelcolor 23 align 20 resizable
|
||||
}
|
||||
}
|
||||
Fl_Button {} {
|
||||
label {&Close}
|
||||
xywh {355 295 90 25}
|
||||
}
|
||||
Fl_Button {} {
|
||||
label {&Options}
|
||||
xywh {260 295 90 25}
|
||||
}
|
||||
Fl_Box {} {
|
||||
label {This is some label }
|
||||
xywh {10 295 240 25} box FLAT_BOX align 84
|
||||
}
|
||||
Fl_Box {} {
|
||||
xywh {10 60 435 225} box DOWN_BOX color 7
|
||||
}
|
||||
Fl_Box {} {selected
|
||||
xywh {10 220 120 65} resizable
|
||||
code0 {/* invisible resizable box */}
|
||||
}
|
||||
}
|
||||
}
|
193
econtrol/econtrol.fld
Executable file
193
econtrol/econtrol.fld
Executable file
@ -0,0 +1,193 @@
|
||||
# data file for the FLTK User Interface Designer (FLUID)
|
||||
version 2.0100
|
||||
images_dir ./
|
||||
header_name {.h}
|
||||
code_name {.cpp}
|
||||
gridx 5
|
||||
gridy 5
|
||||
snap 3
|
||||
decl {// The EDE control center.} {}
|
||||
|
||||
decl {// Copyright (c) 2000. - 2005. EDE Authors} {}
|
||||
|
||||
decl {// This program is licenced under terms of the} {}
|
||||
|
||||
decl {// GNU General Public Licence version 2 or newer.} {}
|
||||
|
||||
decl {// See COPYING for details} {}
|
||||
|
||||
decl {//} {}
|
||||
|
||||
decl {\#include <stdlib.h>} {}
|
||||
|
||||
decl {//\#include <efltk/Fl_Locale.h>} {}
|
||||
|
||||
decl {//\#include <efltk/Fl_Util.h>} {}
|
||||
|
||||
decl {//\#include <edeconf.h>} {}
|
||||
|
||||
decl {\#include "EDE_Run.h"} {}
|
||||
|
||||
decl {\#include "../common/aboutdialog.h"} {}
|
||||
|
||||
Function {} {open
|
||||
} {
|
||||
code {fl_init_locale_support("econtrol", PREFIX"/share/locale");} {}
|
||||
{fltk::Window} configPanelWindow {
|
||||
label {Control panel} open
|
||||
xywh {467 224 450 310} resizable
|
||||
extra_code {\#include <efltk/Fl_Main_Window.h>
|
||||
o->size_range(o->w(), o->h());} visible
|
||||
} {
|
||||
{fltk::MenuBar} main_menubar {
|
||||
xywh {0 0 450 26}
|
||||
} {
|
||||
{fltk::ItemGroup} {} {
|
||||
label {&File} open
|
||||
} {
|
||||
{fltk::Item} {} {
|
||||
label {&Quit}
|
||||
callback {exit(0);}
|
||||
shortcut 0x40071
|
||||
extra_code {o->x_offset(18);}
|
||||
}
|
||||
}
|
||||
{fltk::ItemGroup} {} {
|
||||
label {&Help} open
|
||||
align 0
|
||||
} {
|
||||
{fltk::Item} {} {
|
||||
label {&About}
|
||||
callback {AboutDialog("Control panel", "1.0");}
|
||||
shortcut 0x40061
|
||||
extra_code {o->x_offset(18);}
|
||||
}
|
||||
}
|
||||
}
|
||||
{fltk::Group} main_view {open
|
||||
xywh {0 0 450 280} resizable
|
||||
} {
|
||||
{fltk::InvisibleBox} {} {
|
||||
label {Control panel}
|
||||
xywh {0 24 450 41} align 32 box FLAT_BOX labeltype SHADOW_LABEL color 0xd089d00 buttoncolor 0xe6e7e600 labelcolor 0xffffff00 highlight_color 0xe6e7e600 labelsize 20 textsize 29
|
||||
}
|
||||
{fltk::TiledGroup} {} {open
|
||||
xywh {0 65 450 215} resizable box FLAT_BOX color 0xd93b4300
|
||||
extra_code {o->parent()->resizable(o);}
|
||||
} {
|
||||
{fltk::InvisibleBox} help_window {
|
||||
label {Welcome to the control panel. Here you can setup most things on your computer.}
|
||||
xywh {0 0 110 195} align 128 box DOWN_BOX color 0xfff9e400 labelcolor 32
|
||||
extra_code {o->set_value();}
|
||||
}
|
||||
{fltk::Group} {} {open
|
||||
private xywh {110 0 340 195} align 0 box DOWN_BOX color 7
|
||||
extra_code {\#include <efltk/Fl_Scroll.h>
|
||||
o->edge_offset(10);}
|
||||
class {fltk::ScrollGroup}
|
||||
} {
|
||||
{fltk::Button} {} {
|
||||
label Icons
|
||||
callback {help_window->label(_("Change behaviour of your desktop icons."));
|
||||
help_window->redraw();
|
||||
//if (Fl::event_clicks())
|
||||
run_program("eiconsconf &");}
|
||||
tooltip {Icons settings.}
|
||||
private xywh {10 15 60 75} align 128 box HIGHLIGHT_DOWN_BOX buttonbox NO_BOX
|
||||
image {icons/behaviour.xpm} color 7 highlight_color 7 highlight_textcolor 32 labelsize 10
|
||||
}
|
||||
{fltk::Button} {} {
|
||||
label {Colors and Fonts}
|
||||
callback {help_window->label(_("Configure global colors and fonts used by EDE applications."));
|
||||
help_window->redraw();
|
||||
//if (Fl::event_clicks())
|
||||
run_program("ecolorconf &");}
|
||||
tooltip {Colors settings.}
|
||||
private xywh {75 15 60 75} align 128 box HIGHLIGHT_DOWN_BOX
|
||||
image {icons/themes.xpm} color 7 highlight_color 7 highlight_textcolor 32 labelsize 10
|
||||
}
|
||||
{fltk::Button} {} {
|
||||
label {Screen Saver}
|
||||
callback {help_window->label(_("Configure the screensaver."));
|
||||
help_window->redraw();
|
||||
//if (Fl::event_clicks())
|
||||
run_program("esvrconf &");}
|
||||
tooltip {Screensaver configuration.}
|
||||
private xywh {140 15 60 75} align 128 box HIGHLIGHT_DOWN_BOX
|
||||
image {icons/screensaver.xpm} color 7 highlight_color 7 highlight_textcolor 32 labelsize 10
|
||||
}
|
||||
{fltk::Button} {} {
|
||||
label {Window Manager}
|
||||
callback {help_window->label(_("Setup window decorations and other options."));
|
||||
help_window->redraw();
|
||||
//if (Fl::event_clicks())
|
||||
run_program("ewmconf &");}
|
||||
tooltip {Window manager settings.}
|
||||
private xywh {10 95 60 75} align 128 box HIGHLIGHT_DOWN_BOX
|
||||
image {icons/windowmanager.xpm} color 7 highlight_color 7 highlight_textcolor 32 labelsize 10
|
||||
}
|
||||
{fltk::Button} {} {
|
||||
label Display
|
||||
callback {help_window->label(_("Set various options for the X windowing system."));
|
||||
help_window->redraw();
|
||||
//if (Fl::event_clicks())
|
||||
run_program("edisplayconf &");}
|
||||
tooltip {Display settings. }
|
||||
private xywh {75 95 60 75} box HIGHLIGHT_DOWN_BOX
|
||||
image {icons/display.xpm} color 7 highlight_color 7 highlight_textcolor 32 labelsize 10
|
||||
}
|
||||
{fltk::Button} {} {
|
||||
label {Install New Software}
|
||||
callback {help_window->label(_("This utility helps you to install new software."));
|
||||
help_window->redraw();
|
||||
//if (Fl::event_clicks())
|
||||
run_program("einstaller",false);} selected
|
||||
tooltip {Software installation.}
|
||||
private xywh {140 95 60 75} align 128 box HIGHLIGHT_DOWN_BOX
|
||||
image {icons/newsoft.xpm} color 7 highlight_color 7 highlight_textcolor 32 labelsize 10
|
||||
}
|
||||
{fltk::Button} {} {
|
||||
label {Time and Date}
|
||||
callback {help_window->label(_("Show and set computer time and date."));
|
||||
help_window->redraw();
|
||||
//if (Fl::event_clicks())
|
||||
run_program("etimedate",false);}
|
||||
tooltip {Time and date settings.}
|
||||
private xywh {205 95 60 75} align 128 box HIGHLIGHT_DOWN_BOX
|
||||
image {icons/timedate.xpm} color 7 highlight_color 7 highlight_textcolor 32 labelsize 10
|
||||
}
|
||||
{fltk::Button} {} {
|
||||
label Panel
|
||||
callback {help_window->label(_("Change panel behaviour and choose applets."));
|
||||
help_window->redraw();
|
||||
//if (Fl::event_clicks())
|
||||
run_program("epanelconf",false);}
|
||||
tooltip {Panel configuration.}
|
||||
private xywh {205 15 60 75} box HIGHLIGHT_DOWN_BOX
|
||||
image {icons/panel.xpm} color 7 highlight_color 7 highlight_textcolor 32 labelsize 10
|
||||
}
|
||||
{fltk::Button} {} {
|
||||
label Keyboard
|
||||
callback {help_window->label(_("Configure keyboard shortcuts and other options."));
|
||||
help_window->redraw();
|
||||
//if (Fl::event_clicks())
|
||||
run_program("ekeyconf",false);}
|
||||
tooltip {Keyboard settings}
|
||||
private xywh {265 15 60 75} box HIGHLIGHT_DOWN_BOX buttonbox NO_BOX
|
||||
image {icons/keyboard.xpm} color 7 highlight_color 7 highlight_textcolor 32 labelsize 10
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
{fltk::InvisibleBox} status_bar {
|
||||
label Ready
|
||||
private xywh {0 281 450 24} box DOWN_BOX
|
||||
class {fltk::StatusBarGroup}
|
||||
}
|
||||
}
|
||||
code {configPanelWindow->menu(main_menubar);
|
||||
configPanelWindow->view(main_view);
|
||||
configPanelWindow->status(status_bar);} {}
|
||||
}
|
||||
|
||||
decl {\#include "NLS.h"} {}
|
@ -1,53 +1,25 @@
|
||||
#ifndef __ECONTROL_H__
|
||||
#define __ECONTROL_H__
|
||||
|
||||
#include <FL/Fl_Window.h>
|
||||
#include <FL/Fl_Group.h>
|
||||
#include <FL/Fl_Box.h>
|
||||
#include <FL/Fl_Button.h>
|
||||
|
||||
#include <edelib/IconTheme.h>
|
||||
#include <edelib/ExpandableGroup.h>
|
||||
|
||||
struct ControlIcon {
|
||||
edelib::String name;
|
||||
edelib::String tip;
|
||||
edelib::String exec;
|
||||
edelib::String icon;
|
||||
bool abspath;
|
||||
int pos;
|
||||
};
|
||||
|
||||
class ControlButton : public Fl_Button {
|
||||
private:
|
||||
Fl_Box* tip;
|
||||
edelib::String tipval;
|
||||
public:
|
||||
ControlButton(Fl_Box* t, edelib::String tv, int x, int y, int w, int h, const char* l = 0);
|
||||
~ControlButton();
|
||||
int handle(int event);
|
||||
};
|
||||
|
||||
class ControlWin : public Fl_Window {
|
||||
private:
|
||||
Fl_Group* titlegrp;
|
||||
Fl_Box* title;
|
||||
Fl_Button* close;
|
||||
//Fl_Button* options;
|
||||
edelib::ExpandableGroup* icons;
|
||||
Fl_Box* rbox;
|
||||
Fl_Box* tipbox;
|
||||
|
||||
edelib::vector<ControlIcon> iconlist;
|
||||
|
||||
void init(void);
|
||||
void load_icons(void);
|
||||
|
||||
public:
|
||||
ControlWin(const char* title, int w = 455, int h = 330);
|
||||
~ControlWin();
|
||||
void do_close(void);
|
||||
};
|
||||
|
||||
/*
|
||||
* $Id$
|
||||
*
|
||||
* The EDE control center
|
||||
* Part of Equinox Desktop Environment (EDE).
|
||||
* Copyright (c) 2000-2006 EDE Authors.
|
||||
*
|
||||
* This program is licenced under terms of the
|
||||
* GNU General Public Licence version 2 or newer.
|
||||
* See COPYING for details.
|
||||
*/
|
||||
|
||||
#ifndef econtrol_h
|
||||
#define econtrol_h
|
||||
#include <fltk/Window.h>
|
||||
#include <fltk/MenuBar.h>
|
||||
#include <fltk/ItemGroup.h>
|
||||
#include <fltk/Item.h>
|
||||
#include <fltk/Group.h>
|
||||
#include <fltk/InvisibleBox.h>
|
||||
#include <fltk/TiledGroup.h>
|
||||
#include <fltk/ScrollGroup.h>
|
||||
#include <fltk/Button.h>
|
||||
#include <fltk/StatusBarGroup.h>
|
||||
#endif
|
||||
|
@ -282,6 +282,7 @@ DirTree::load()
|
||||
}
|
||||
}
|
||||
}
|
||||
fclose(mtab);
|
||||
|
||||
this->end();
|
||||
system->set_flag(fltk::OPENED);
|
||||
|
@ -607,6 +607,9 @@ void do_paste() {
|
||||
}
|
||||
|
||||
// Draw progress dialog
|
||||
// NOTE: sometimes when copying/moving just one file, the window
|
||||
// can get "stuck"
|
||||
// See: fltk STR 1255, http://www.fltk.org/str.php?L1255
|
||||
Window* progress_window = new Window(350,150);
|
||||
if (operation_is_copy)
|
||||
progress_window->label(_("Copying files"));
|
||||
@ -660,6 +663,8 @@ void do_paste() {
|
||||
caption->redraw();
|
||||
if (stop_now || !my_copy(files_list[i], dest))
|
||||
break;
|
||||
// Delete file after moving
|
||||
if (!operation_is_copy) unlink(files_list[i]);
|
||||
cut_copy_progress->position(cut_copy_progress->position()+1);
|
||||
fltk::check(); // check to see if user pressed Stop
|
||||
}
|
||||
|
@ -1,14 +0,0 @@
|
||||
#
|
||||
# $Id$
|
||||
#
|
||||
# Part of Equinox Desktop Environment (EDE).
|
||||
# Copyright (c) 2000-2007 EDE Authors.
|
||||
#
|
||||
# This program is licenced under terms of the
|
||||
# GNU General Public Licence version 2 or newer.
|
||||
# See COPYING for details.
|
||||
|
||||
SubDir TOP eimage ;
|
||||
|
||||
MakeProgram eimage : eimage.cpp ;
|
||||
ExtractStrings locale : eimage.cpp ;
|
@ -1,72 +1,76 @@
|
||||
#include <Fl/Fl.h>
|
||||
#include <Fl/Fl_Window.h>
|
||||
#include <Fl/Fl_Button.h>
|
||||
#include <Fl/Fl_Shared_Image.h>
|
||||
#include <Fl/Fl_Scroll.h>
|
||||
#include <Fl/Fl_Widget.h>
|
||||
#include <Fl/Fl_File_Chooser.h>
|
||||
#include <Fl/filename.h>
|
||||
|
||||
#include <fltk/run.h>
|
||||
#include <fltk/Window.h>
|
||||
#include <fltk/DoubleBufferWindow.h>
|
||||
#include <fltk/Button.h>
|
||||
#include <fltk/SharedImage.h>
|
||||
#include <fltk/ScrollGroup.h>
|
||||
#include <fltk/Widget.h>
|
||||
#include <fltk/filename.h>
|
||||
#include <fltk/events.h>
|
||||
#include <fltk/PopupMenu.h>
|
||||
#include <fltk/Item.h>
|
||||
#include <fltk/Divider.h>
|
||||
#include <fltk/Divider.h>
|
||||
#include <fltk/file_chooser.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
|
||||
#define DEBUG 1
|
||||
using namespace fltk;
|
||||
|
||||
|
||||
|
||||
// Supported image types
|
||||
const char* supported[] = {"bm","bmp","gif","jpg","pbm","pgm","png","ppm","xbm","xpm",0};
|
||||
// Automatic detection of image type still doesn't work in fltk :(
|
||||
static struct {
|
||||
const char* filename;
|
||||
SharedImage* (*func)(const char*, const uchar*);
|
||||
} supported[] = {
|
||||
{ "*.png", pngImage::get},
|
||||
{"*.jpg", jpegImage::get},
|
||||
{"*.gif", gifImage::get},
|
||||
{"*.bmp", bmpImage::get},
|
||||
{"*.xpm", xpmFileImage::get},
|
||||
{0, 0}
|
||||
};
|
||||
|
||||
|
||||
|
||||
// Global variables used everywhere
|
||||
char filename[FL_PATH_MAX], directory[FL_PATH_MAX];
|
||||
Fl_Window* w;
|
||||
|
||||
// Making these global vastly simplifies the code
|
||||
// cause they're used a lot
|
||||
// The proper thing to do is to make the whole program one big class
|
||||
char filename[PATH_MAX], directory[PATH_MAX];
|
||||
Window* w;
|
||||
class CenteredInScroll;
|
||||
CenteredInScroll* c;
|
||||
float zoomfactor;
|
||||
bool autozoom=false;
|
||||
Fl_Shared_Image *im;
|
||||
|
||||
class ScrolledImage;
|
||||
ScrolledImage* s;
|
||||
|
||||
|
||||
// Directory list cache used in prevnext()
|
||||
// Variables used in nextpic & prevpic
|
||||
dirent **files;
|
||||
int nfiles;
|
||||
|
||||
|
||||
// Forward declaration of funcs for use from callbacks
|
||||
// Forward declaration of funcs for use from event handler
|
||||
void nextpic();
|
||||
void prevpic();
|
||||
void loadimage();
|
||||
void newdir();
|
||||
|
||||
|
||||
|
||||
// Callbacks for main menu
|
||||
void next_cb(Fl_Widget*,void*) { nextpic(); }
|
||||
void prev_cb(Fl_Widget*,void*) { prevpic(); }
|
||||
void open_cb(Fl_Widget*,void*) {
|
||||
// construct filename filter
|
||||
char filter[FL_PATH_MAX];
|
||||
snprintf(filter, FL_PATH_MAX, "Image files(*.{%s", supported[0]);
|
||||
for (int i=1; supported[i]; i++)
|
||||
snprintf(filter, FL_PATH_MAX, "%s,%s", filter, supported[i]);
|
||||
snprintf(filter, FL_PATH_MAX, "%s})", filter);
|
||||
|
||||
const char* f = fl_file_chooser("Choose image or directory",filter,directory);
|
||||
// Callbacks for popup menu
|
||||
void next_cb(Widget*) { nextpic(); }
|
||||
void prev_cb(Widget*) { prevpic(); }
|
||||
void open_cb(Widget*) {
|
||||
const char* f = file_chooser("Choose image or directory","Image Files (*.{bmp,gif,jpg,png,xpm})",directory);
|
||||
if (!f) return;
|
||||
|
||||
strncpy(filename,f,FL_PATH_MAX);
|
||||
strncpy(filename,f,PATH_MAX);
|
||||
newdir();
|
||||
loadimage();
|
||||
}
|
||||
|
||||
void manage_cb(Fl_Widget* b,void*) {} // call file manager
|
||||
void fullscreen_cb(Fl_Widget* b,void*) {
|
||||
void manage_cb(Widget* b) {} // call file manager
|
||||
void fullscr_cb(Widget* b) {
|
||||
static bool isfull=false;
|
||||
static int X,Y,W,H;
|
||||
if (isfull) {
|
||||
@ -78,116 +82,136 @@ void fullscreen_cb(Fl_Widget* b,void*) {
|
||||
isfull=true;
|
||||
}
|
||||
}
|
||||
void zoomin_cb(Fl_Widget* b,void*) {
|
||||
void exit_cb(Widget* b) { exit(0); }
|
||||
void zoomin_cb(Widget* b) {
|
||||
if (zoomfactor>=1) zoomfactor += 0.2; else zoomfactor += zoomfactor/5;
|
||||
autozoom=false;
|
||||
loadimage();
|
||||
}
|
||||
void zoomout_cb(Fl_Widget* b,void*) {
|
||||
void zoomout_cb(Widget* b) {
|
||||
if (zoomfactor>=1) zoomfactor -= 0.2; else zoomfactor -= zoomfactor/5;
|
||||
autozoom=false;
|
||||
loadimage();
|
||||
}
|
||||
void zoomrestore_cb(Fl_Widget* b,void*) { zoomfactor = 1; autozoom=false; loadimage(); }
|
||||
void zoomauto_cb(Fl_Widget *b,void*) { autozoom = !autozoom; loadimage(); }
|
||||
void about_cb(Fl_Widget* b,void*) {} // about window
|
||||
void exit_cb(Fl_Widget* b,void*) { exit(0); }
|
||||
|
||||
|
||||
|
||||
// Main popup menu
|
||||
Fl_Menu_Item mainmenu[] = {
|
||||
{"&Open", FL_CTRL+'o', open_cb},
|
||||
{"&Manage", 0, manage_cb, 0, FL_MENU_DIVIDER},
|
||||
|
||||
{"&Previous", FL_Page_Up, prev_cb},
|
||||
{"&Next", FL_Page_Down, next_cb, 0, FL_MENU_DIVIDER},
|
||||
|
||||
{"&Zoom in", '+', zoomin_cb},
|
||||
{"Zoom &out", '-', zoomout_cb},
|
||||
{"Zoom &auto", FL_CTRL+'a', zoomauto_cb},
|
||||
{"&Restore", '/', zoomrestore_cb, 0, FL_MENU_DIVIDER},
|
||||
|
||||
{"&Fullscreen", FL_F+11, fullscreen_cb, 0, FL_MENU_DIVIDER},
|
||||
|
||||
{"A&bout", 0, about_cb},
|
||||
{"&Exit", FL_Escape, exit_cb},
|
||||
{0}
|
||||
};
|
||||
void zoomrestore_cb(Widget* b) { zoomfactor = 1; autozoom=false; loadimage(); }
|
||||
void zoomauto_cb(Widget *b) { autozoom = !autozoom; loadimage(); }
|
||||
|
||||
|
||||
|
||||
|
||||
class ScrolledImage : public Fl_Scroll {
|
||||
class CenteredInScroll : public Button {
|
||||
private:
|
||||
Fl_Box* b;
|
||||
Fl_Menu_Button* mb;
|
||||
|
||||
PopupMenu* popup;
|
||||
public:
|
||||
ScrolledImage(int x, int y, int w, int h, const char*l = 0)
|
||||
: Fl_Scroll(x,y,w,h,l) {
|
||||
align(FL_ALIGN_INSIDE|FL_ALIGN_CENTER);
|
||||
begin();
|
||||
|
||||
b = new Fl_Box(w/2,h/2,0,0);
|
||||
CenteredInScroll(int x, int y, int w, int h, const char*l = 0)
|
||||
: Button(x,y,w,h,l) {
|
||||
popup = new PopupMenu(0, 0, 0, 0);
|
||||
if(popup->parent())
|
||||
popup->parent()->remove(popup);
|
||||
popup->parent(0);
|
||||
popup->type(PopupMenu::POPUP3);
|
||||
popup->begin();
|
||||
|
||||
mb = new Fl_Menu_Button (0,0,0,0,"");
|
||||
mb->type(Fl_Menu_Button::POPUP3);
|
||||
mb->menu(0);
|
||||
|
||||
end();
|
||||
redraw();
|
||||
}
|
||||
|
||||
void image(Fl_Image* a) { b->image(a); }
|
||||
void image(Fl_Image& a) { b->image(a); }
|
||||
Fl_Image* image() { return b->image(); }
|
||||
void label(const char* a) {
|
||||
if (a) resizebox(0,0); // center label
|
||||
b->label(a);
|
||||
}
|
||||
|
||||
// Resize the box containing image
|
||||
void resizebox(int W, int H) {
|
||||
int X=0,Y=0;
|
||||
int aw = w()-scrollbar.w(); int ah=h()-hscrollbar.h();
|
||||
if(aw>W) X=(aw-W)/2;
|
||||
if(ah>H) Y=(ah-H)/2;
|
||||
b->resize(X,Y,W,H);
|
||||
{Item *i = new Item("&Open...");
|
||||
i->callback(open_cb);
|
||||
i->shortcut(CTRL+'o');
|
||||
}
|
||||
|
||||
void resize(int x,int y,int w,int h) {
|
||||
Fl_Scroll::resize(x,y,w,h);
|
||||
resizebox(b->w(),b->h()); // refresh image position
|
||||
redraw();
|
||||
{Item *i = new Item("&Manage...");
|
||||
i->callback(manage_cb);
|
||||
}
|
||||
|
||||
virtual int handle(int event) {
|
||||
if (event == FL_PUSH) {
|
||||
if(Fl::event_button()==3 && mb->menu()!=0) {
|
||||
mb->popup();
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
// sometimes PgUp and PgDown aren't handled
|
||||
else if (event == FL_SHORTCUT && mb->menu()!=0) {
|
||||
int key = Fl::event_key();
|
||||
if (key==FL_Page_Up || key==FL_Page_Down)
|
||||
return mb->handle(event);
|
||||
}
|
||||
return Fl_Scroll::handle(event);
|
||||
new Divider();
|
||||
|
||||
{Item *i = new Item("&Next");
|
||||
i->callback(next_cb);
|
||||
i->shortcut(DownKey);
|
||||
}
|
||||
|
||||
void setmenu(Fl_Menu_Item* menu) {
|
||||
if (menu!=0) {
|
||||
mb->menu(menu);
|
||||
{Item *i = new Item("&Previous");
|
||||
i->callback(prev_cb);
|
||||
i->shortcut(UpKey);
|
||||
}
|
||||
|
||||
new Divider();
|
||||
|
||||
{Item *i = new Item("&Zoom in");
|
||||
i->callback(zoomin_cb);
|
||||
i->shortcut('+');
|
||||
}
|
||||
|
||||
{Item *i = new Item("Zoom &out");
|
||||
i->callback(zoomout_cb);
|
||||
i->shortcut('-');
|
||||
}
|
||||
|
||||
{Item *i = new Item("Zoom &auto");
|
||||
i->callback(zoomauto_cb);
|
||||
i->shortcut(CTRL+'a');
|
||||
}
|
||||
|
||||
{Item *i = new Item("&Restore");
|
||||
i->callback(zoomrestore_cb);
|
||||
i->shortcut('/');
|
||||
}
|
||||
|
||||
new Divider();
|
||||
|
||||
{Item *i = new Item("&Fullscreen");
|
||||
i->callback(fullscr_cb);
|
||||
i->shortcut(F11Key);
|
||||
}
|
||||
|
||||
new Divider();
|
||||
|
||||
{Item *i = new Item("A&bout");
|
||||
i->callback(exit_cb);
|
||||
}
|
||||
|
||||
{Item *i = new Item("&Exit");
|
||||
i->callback(exit_cb);
|
||||
i->shortcut(EscapeKey);
|
||||
}
|
||||
|
||||
|
||||
|
||||
popup->end();
|
||||
}
|
||||
|
||||
virtual void draw() {
|
||||
int ix, iy;
|
||||
if (w() < parent()->w()) { ix=((parent()->w() - w())/2); } else { ix=0; }
|
||||
if (h() < parent()->h()) { iy=((parent()->h() - h())/2); } else { iy=0; }
|
||||
Image *i = (Image*)image();
|
||||
i->draw(Rectangle(ix,iy,w(),h()));
|
||||
}
|
||||
|
||||
virtual int handle(int event) {
|
||||
if (event == KEY) {
|
||||
int key = event_key();
|
||||
const char* text = event_text(); // needed to detect some keys
|
||||
if (key == LeftKey || key == UpKey) prevpic();
|
||||
else if (key == RightKey || key == DownKey) nextpic();
|
||||
// Shortcuts from popup menu wont work unless we define them here
|
||||
// The 'this' is just to pass something to callback, it wont be used
|
||||
else if (key == CTRL+'o') open_cb(this);
|
||||
else if (strcmp(text,"+")==0 || key == AddKey) zoomin_cb(this);
|
||||
else if (strcmp(text,"-")==0 || key == SubtractKey) zoomout_cb(this);
|
||||
else if (strcmp(text,"/")==0 || key == DivideKey) zoomrestore_cb(this);
|
||||
else if (key == CTRL+'a') zoomauto_cb(this);
|
||||
else if (key == F11Key) fullscr_cb(this);
|
||||
}
|
||||
else if (event == PUSH) {
|
||||
if(event_button()==3) {
|
||||
popup->popup();
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return Button::handle(event);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
// Directory changed, get new directory from filename
|
||||
void newdir() {
|
||||
int p=0;
|
||||
@ -203,114 +227,66 @@ void newdir() {
|
||||
|
||||
// Load the image given in char[] filename
|
||||
void loadimage() {
|
||||
char tmp[FL_PATH_MAX]; // the string buffer
|
||||
|
||||
if (DEBUG) fprintf(stderr, "Loadimage() - file: %s\n",filename);
|
||||
fprintf(stderr, "Loadimage() - file: %s\n",filename);
|
||||
|
||||
// Load image
|
||||
if (im) { im->release(); im=0; }
|
||||
im = Fl_Shared_Image::get(filename); // image type is autodetected now
|
||||
|
||||
if (!im) {
|
||||
if (DEBUG) fprintf(stderr, "Fl_Shared_Image::get() failed!\n");
|
||||
s->image(0);
|
||||
snprintf(tmp, FL_PATH_MAX, "Can't load image %s\n",filename);
|
||||
s->label(strdup(tmp));
|
||||
s->redraw();
|
||||
return;
|
||||
}
|
||||
|
||||
// Measure image
|
||||
int realw=im->w(), realh=im->h();
|
||||
int scaledw,scaledh;
|
||||
SharedImage *im;
|
||||
for (int j=0; supported[j].filename; j++)
|
||||
if (filename_match(filename,supported[j].filename)) {
|
||||
im = supported[j].func(filename,0);
|
||||
break;
|
||||
}
|
||||
|
||||
int W,H;
|
||||
im->measure(W,H); // Should this wait until image is loaded?
|
||||
if (autozoom) {
|
||||
// Adjust zoom factor so picture fits inside window
|
||||
// When user switches to manual zooming, this factor will remain
|
||||
float fw=(float)s->w()/realw; float fh=(float)s->h()/realh;
|
||||
if (fw < fh) zoomfactor=fw; else zoomfactor=fh;
|
||||
// Adjust zoom factor so picture fits on screen
|
||||
// When switch to manual zooming, this factor will be used
|
||||
float pw=c->parent()->w()+1, ph=c->parent()->h()+1;
|
||||
// use float to avoid rounding
|
||||
if (pw/W < ph/H) zoomfactor=pw/W; else zoomfactor=ph/H;
|
||||
}
|
||||
|
||||
// Resample image to new size
|
||||
scaledw=realw*zoomfactor;
|
||||
scaledh=realh*zoomfactor;
|
||||
c->w((int)W*zoomfactor-1); // cast to int and -1 help avoid
|
||||
c->h((int)H*zoomfactor-1); // scrollbars when autozoom is on
|
||||
c->image(im);
|
||||
|
||||
if (zoomfactor!=1) {
|
||||
Fl_Image *temp = im->copy(scaledw,scaledh);
|
||||
im = (Fl_Shared_Image*) temp;
|
||||
}
|
||||
c->parent()->relayout(); // remove scrollbars if necessary
|
||||
c->parent()->redraw(); // remove traces of old picture
|
||||
|
||||
// Set image
|
||||
s->resizebox(scaledw,scaledh);
|
||||
s->image(im);
|
||||
c->label(""); // clear any previous labels
|
||||
|
||||
s->label(0); // clear any previous labels
|
||||
s->redraw();
|
||||
|
||||
// set window title
|
||||
char tmp[PATH_MAX]; // set window title
|
||||
if (zoomfactor==1)
|
||||
snprintf(tmp,FL_PATH_MAX,"%s (%dx%d) - View picture",fl_filename_name(filename),realw,realh);
|
||||
snprintf(tmp,PATH_MAX,"%s (%dx%d) - View picture",filename_name(filename),W,H);
|
||||
else
|
||||
snprintf(tmp,FL_PATH_MAX,"%s (%dx%d) - zoom %1.1fx - View picture",fl_filename_name(filename),realw,realh,zoomfactor);
|
||||
snprintf(tmp,PATH_MAX,"%s (%dx%d) - zoom %1.1fx - View picture",filename_name(filename),W,H,zoomfactor);
|
||||
w->label(strdup(tmp));
|
||||
}
|
||||
|
||||
|
||||
// Get next/previous picture file in directory
|
||||
// (universal func. to be called from nextpic() and prevpic() )
|
||||
// Get next/previous picture file in directory d
|
||||
// (universal func. to be called from nextpic() and prevpic()
|
||||
void prevnext(int direction) {
|
||||
char tmp[FL_PATH_MAX]; // the string buffer
|
||||
|
||||
if (DEBUG)
|
||||
fprintf(stderr, "Prevnext() - file: %s dir: %s direction: %d\n",filename,directory,direction);
|
||||
fprintf(stderr, "Nextpic() - file: %s dir: %s direction: %d\n",filename,directory,direction);
|
||||
|
||||
if (nfiles == 0) { // read directory
|
||||
nfiles = fl_filename_list(directory,&files);
|
||||
nfiles = filename_list(directory,&files);
|
||||
}
|
||||
|
||||
// Select next picture after current
|
||||
bool found=false;
|
||||
if (filename[0]) {
|
||||
const char* justname = fl_filename_name(filename);
|
||||
|
||||
// this basically means: if direction is 1 go from first to last, else from last to first
|
||||
for (int i=(direction?0:nfiles-1); (direction?i<nfiles:i>=0); i+=(direction?1:-1)) {
|
||||
if (strncmp(justname,files[i]->d_name,FL_PATH_MAX) == 0) {
|
||||
found=true;
|
||||
continue; // skip to next file
|
||||
}
|
||||
if (found) {
|
||||
for (int j=0; supported[j]; j++) {
|
||||
snprintf(tmp,FL_PATH_MAX,"*.%s",supported[j]);
|
||||
if (fl_filename_match(files[i]->d_name,tmp)) {
|
||||
snprintf(filename,FL_PATH_MAX,"%s/%s",directory,files[i]->d_name);
|
||||
loadimage();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
const char* justname = filename_name(filename);
|
||||
// this basically means: if direction is 1 go from first to last, else from last to first
|
||||
for (int i=(direction?0:nfiles-1); (direction?i<nfiles:i>=0); i+=(direction?1:-1)) {
|
||||
if (strncmp(justname,files[i]->d_name,PATH_MAX) == 0) {
|
||||
found=true;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (found) { //this means that the current picture is the last/first in directory
|
||||
if (im) { im->release(); im=0; }
|
||||
s->image(0);
|
||||
filename[0]=0;
|
||||
|
||||
if (direction)
|
||||
s->label("This was the last picture.\nPress 'Next' again for first one.");
|
||||
else
|
||||
s->label("This was the first picture.\nPress 'Previous' again for last one.");
|
||||
s->redraw();
|
||||
return;
|
||||
|
||||
} else {
|
||||
// Just give first (or last) picture in directory
|
||||
for (int i=(direction?0:nfiles-1); (direction?i<nfiles:i>=0); i+=(direction?1:-1)) {
|
||||
for (int j=0; supported[j]; j++) {
|
||||
snprintf(tmp,FL_PATH_MAX,"*.%s",supported[j]);
|
||||
if (fl_filename_match(files[i]->d_name,tmp)) {
|
||||
snprintf(filename,FL_PATH_MAX,"%s/%s",directory,files[i]->d_name);
|
||||
if (found) {
|
||||
for (int j=0; supported[j].filename; j++) {
|
||||
if (filename_match(files[i]->d_name,supported[j].filename)) {
|
||||
snprintf(filename,PATH_MAX,"%s/%s",directory,files[i]->d_name);
|
||||
loadimage();
|
||||
return;
|
||||
}
|
||||
@ -318,18 +294,31 @@ void prevnext(int direction) {
|
||||
}
|
||||
}
|
||||
|
||||
// Current picture not found, give first in directory
|
||||
for (int i=(direction?0:nfiles-1); (direction?i<nfiles:i>=0); i+=(direction?1:-1)) {
|
||||
for (int j=0; supported[j].filename; j++) {
|
||||
if (filename_match(files[i]->d_name,supported[j].filename)) {
|
||||
snprintf(filename,PATH_MAX,"%s/%s",directory,files[i]->d_name);
|
||||
loadimage();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Nothing found...
|
||||
if (DEBUG) fprintf(stderr, "Nextpic() - nothing found\n");
|
||||
|
||||
if (im) { im->release(); im=0; }
|
||||
s->image(0);
|
||||
filename[0]=0;
|
||||
snprintf(tmp,FL_PATH_MAX,"No pictures in directory %s",directory);
|
||||
s->label(strdup(tmp));
|
||||
s->redraw();
|
||||
|
||||
fprintf(stderr, "Nextpic() - nothing found\n");
|
||||
char tmp[PATH_MAX];
|
||||
snprintf(tmp,PATH_MAX,"No pictures in directory %s",directory);
|
||||
c->label(strdup(tmp));
|
||||
// Position label on center and redraw everything
|
||||
c->w(1); c->h(1);
|
||||
c->x(c->parent()->w()/2);
|
||||
c->y(c->parent()->h()/2);
|
||||
c->redraw();
|
||||
c->parent()->relayout();
|
||||
c->parent()->redraw();
|
||||
// Window title
|
||||
snprintf(tmp,FL_PATH_MAX,"View picture - nothing found in %s",directory);
|
||||
snprintf(tmp,PATH_MAX,"View picture - nothing found in %s",directory);
|
||||
w->label(strdup(tmp));
|
||||
}
|
||||
|
||||
@ -339,47 +328,59 @@ void prevpic() { prevnext(0); }
|
||||
|
||||
|
||||
int main (int argc, char **argv) {
|
||||
filename[0]='\0'; directory[0]='\0'; zoomfactor=1; im=0;
|
||||
fl_register_images();
|
||||
filename[0]='\0'; directory[0]='\0'; zoomfactor=1;
|
||||
|
||||
|
||||
// Main window
|
||||
|
||||
w = new Fl_Window(200, 200, "View picture");
|
||||
s = new ScrolledImage(0,0,200,200);
|
||||
s->color(33);
|
||||
s->labelcolor(FL_WHITE);
|
||||
s->setmenu(mainmenu);
|
||||
w->resizable(s);
|
||||
w = new Window(200, 200, "View picture");
|
||||
w->set_vertical();
|
||||
w->set_double_buffer();
|
||||
w->begin();
|
||||
{ScrollGroup* g = new ScrollGroup(0, 0, 200, 200);
|
||||
//g->set_vertical();
|
||||
// Group::current()->resizable(o);
|
||||
g->box(FLAT_BOX);
|
||||
g->color(GRAY05);
|
||||
// g->color(WHITE);
|
||||
g->align(ALIGN_RIGHT);
|
||||
g->resize_align(ALIGN_RIGHT);
|
||||
g->begin();
|
||||
{c = new CenteredInScroll(0,0,200,200);
|
||||
g->align(ALIGN_LEFT|ALIGN_TOP);
|
||||
c->box(NO_BOX);
|
||||
c->focusbox(NO_BOX);
|
||||
g->color(GRAY05);
|
||||
c->labelcolor(WHITE);
|
||||
c->labelsize(14);
|
||||
c->tooltip("Right click for menu");
|
||||
c->take_focus();
|
||||
}
|
||||
g->end();
|
||||
}
|
||||
w->end();
|
||||
w->align(FL_ALIGN_INSIDE|FL_ALIGN_CENTER);
|
||||
|
||||
|
||||
w->resizable(w);
|
||||
|
||||
// Analyze command line
|
||||
|
||||
if (argc==1) { // No params
|
||||
strncpy (directory, getenv("HOME"), FL_PATH_MAX);
|
||||
strncpy (directory, getenv("HOME"), PATH_MAX);
|
||||
nextpic();
|
||||
|
||||
} else if (fl_filename_isdir(argv[1])) { // Param is directory
|
||||
strncpy (directory, argv[1], FL_PATH_MAX);
|
||||
} else if (filename_isdir(argv[1])) { // Param is directory
|
||||
strncpy (directory, argv[1], PATH_MAX);
|
||||
nextpic();
|
||||
argc--; argv++; // ignore this param and forward rest to fltk
|
||||
|
||||
} else { // Param is file
|
||||
if (argv[1][0] == '~' && argv[1][1] == '/') // expand home dir
|
||||
snprintf (filename, FL_PATH_MAX, "%s/%s", getenv("HOME"), argv[1]+2);
|
||||
snprintf (filename, PATH_MAX, "%s/%s", getenv("HOME"), argv[1]+2);
|
||||
else if (argv[1][0] != '/') // relative filename
|
||||
snprintf (filename, FL_PATH_MAX, "%s/%s", getenv("PWD"), argv[1]);
|
||||
snprintf (filename, PATH_MAX, "%s/%s", getenv("PWD"), argv[1]);
|
||||
else // absolute filename
|
||||
strncpy (filename, argv[1], FL_PATH_MAX);
|
||||
strncpy (filename, argv[1], PATH_MAX);
|
||||
|
||||
struct stat last_stat; // Does file exist?
|
||||
if (stat(argv[0], &last_stat)!=0) {
|
||||
char tmp[FL_PATH_MAX];
|
||||
snprintf(tmp,FL_PATH_MAX,"File not found - %s",filename);
|
||||
s->label(tmp);
|
||||
if (!filename_exist(argv[1])) {
|
||||
char tmp[PATH_MAX];
|
||||
snprintf(tmp,PATH_MAX,"File not found - %s",filename);
|
||||
c->label(tmp);
|
||||
} else
|
||||
loadimage();
|
||||
|
||||
@ -387,14 +388,7 @@ int main (int argc, char **argv) {
|
||||
argc--; argv++; // ignore this param and forward rest to fltk
|
||||
}
|
||||
|
||||
// Resize window to image size or screen
|
||||
int W,H;
|
||||
if (im->w()>Fl::w()) W=Fl::w(); else W=im->w();
|
||||
if (im->h()>Fl::h()) H=Fl::h(); else H=im->h();
|
||||
w->resize(0,0,W,H);
|
||||
// Window manager should make sure that window is fully visible
|
||||
|
||||
w->show(argc,argv);
|
||||
return Fl::run();
|
||||
return run();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user