27
27
#include <libintl.h>
28
28
#include "jwm-desktop.h"
30
void DesktopUI::cb_background_displayer_thingie_i(Fl_Box*, void*) {
30
void DesktopUI::cb_background_displayer_thingie_i(Fl_Box* o, void*) {
31
31
flDesktop desktop;desktop.loadTemp();
32
32
const char * bg = desktop.getBackground();
33
desktop.setFlImage(o,bg);
35
35
void DesktopUI::cb_background_displayer_thingie(Fl_Box* o, void* v) {
36
36
((DesktopUI*)(o->parent()->user_data()))->cb_background_displayer_thingie_i(o,v);
100
100
void DesktopUI::cb_Icons_i(Fl_Check_Button*, void*) {
101
101
flDesktop desktop;desktop.loadTemp();
102
bool choice = desktop.roxActive();
104
desktop.useRox(choice);
106
//call relevant function
103
112
void DesktopUI::cb_Icons(Fl_Check_Button* o, void* v) {
104
113
((DesktopUI*)(o->parent()->user_data()))->cb_Icons_i(o,v);
107
116
void DesktopUI::cb_Choose1_i(Fl_Button*, void*) {
108
flDesktop desktop;desktop.loadTemp();
110
119
void DesktopUI::cb_Choose1(Fl_Button* o, void* v) {
111
120
((DesktopUI*)(o->parent()->user_data()))->cb_Choose1_i(o,v);
856
865
{ desktop_window = new Fl_Double_Window(530, 540);
857
866
desktop_window->color((Fl_Color)31);
858
867
desktop_window->user_data((void*)(this));
859
{ background_displayer_thingie = new Fl_Box(35, 80, 345, 270);
868
{ Fl_Box* o = background_displayer_thingie = new Fl_Box(35, 80, 345, 270);
860
869
background_displayer_thingie->box(FL_GTK_DOWN_BOX);
861
870
background_displayer_thingie->color((Fl_Color)37);
862
871
background_displayer_thingie->callback((Fl_Callback*)cb_background_displayer_thingie);
863
872
background_displayer_thingie->when(FL_WHEN_RELEASE_ALWAYS);
864
873
flDesktop desktop;desktop.loadTemp();
865
874
const char * bg = desktop.getBackground();
875
desktop.setFlImage(o,bg);
867
876
} // Fl_Box* background_displayer_thingie
868
877
{ Fl_Button* o = new Fl_Button(395, 90, 125, 25, gettext("Choose Image"));
869
878
o->callback((Fl_Callback*)cb_Choose);
932
941
{ Fl_Button* o = new Fl_Button(395, 150, 125, 25, gettext("Choose Gradient"));
933
942
o->tooltip(gettext("Make the background a Color Gradient"));
934
943
o->callback((Fl_Callback*)cb_Choose1);
936
944
} // Fl_Button* o
937
945
{ Fl_Button* o = new Fl_Button(390, 250, 135, 25, gettext("Choose Command"));
938
946
o->tooltip(gettext("Use a command to set the background"));
950
958
o->box(FL_GTK_UP_BOX);
951
959
o->callback((Fl_Callback*)cb_Choose3);
952
960
} // Fl_Button* o
953
{ color_display = new Fl_Box(35, 80, 345, 270);
954
color_display->box(FL_GTK_DOWN_BOX);
955
color_display->color((Fl_Color)37);
956
color_display->when(FL_WHEN_RELEASE_ALWAYS);
957
color_display->hide();
958
} // Fl_Box* color_display
961
{ color_display1 = new Fl_Box(35, 80, 345, 270);
962
color_display1->box(FL_GTK_DOWN_BOX);
963
color_display1->color((Fl_Color)37);
964
color_display1->when(FL_WHEN_RELEASE_ALWAYS);
965
color_display1->hide();
966
} // Fl_Box* color_display1
967
{ color_display2 = new Fl_Box(35, 210, 345, 140);
968
color_display2->box(FL_GTK_DOWN_BOX);
969
color_display2->color((Fl_Color)37);
970
color_display2->when(FL_WHEN_RELEASE_ALWAYS);
971
color_display2->hide();
972
} // Fl_Box* color_display2
959
973
desktop_window->end();
960
974
} // Fl_Double_Window* desktop_window
961
975
return desktop_window;
964
void DesktopUI::display(const char* filename) {
965
std::string extention, filenameStr, isColor, noBg;
966
filenameStr = filename;
967
unsigned int visibleImage = background_displayer_thingie->visible();
968
//unsigned int visibleColor = color_display->visible();
969
///HOW DO I DO THIS?????
970
noBg ="No Background Set\n";
971
if(filenameStr.compare(noBg)!=0){
972
isColor = filenameStr.substr(0,1);
974
extention = filenameStr.substr((strlen(filename)-4),4);
975
std::transform(extention.begin(), extention.end(), extention.begin(), ::tolower);
977
if (extention == ".png"){
978
image = new Fl_PNG_Image(filename);
979
Fl_Image * image2 = image->copy(345,270);
980
// if(visibleColor !=0 && visibleImage ==0){
981
// color_display->hide();
982
background_displayer_thingie->image(image2);
983
// background_displayer_thingie->show();
984
background_displayer_thingie->redraw();
986
else if(visibleColor ==0 && visibleImage !=0){
987
background_displayer_thingie->image(image2);
988
background_displayer_thingie->redraw();
991
else if(extention == ".jpg"){
992
image = new Fl_JPEG_Image(filename);
993
Fl_Image * image2 = image->copy(345,270);
994
//if(visibleColor !=0 && visibleImage ==0){
995
// color_display->hide();
996
background_displayer_thingie->image(image2);
997
// background_displayer_thingie->show();
998
background_displayer_thingie->redraw();
1000
else if(visibleColor ==0 && visibleImage !=0){
1001
background_displayer_thingie->image(image2);
1002
background_displayer_thingie->redraw();
1007
std::cout<<"it is a color\n";
1012
978
void DesktopUI::bg_chooser_cb() {
1013
979
flDesktop desktop;
1014
980
desktop.loadTemp();
1027
993
current_bg->value(result);
1028
994
const char* type="image";
1029
995
desktop.setBackground(type,result);
996
color_display1->hide();
997
color_display2->hide();
998
desktop.setFlImage(background_displayer_thingie,result);
1035
void DesktopUI::one_color(Fl_Box *o) {
1003
void DesktopUI::one_color() {
1036
1004
flDesktop desktop;desktop.loadTemp();
1040
Fl::get_color((o->color()),r,g,b);
1043
1010
const char * label ="choose";
1052
1019
desktop.setBackground(colors);
1053
1020
unsigned int unusedColor;
1054
1021
unsigned int colorSet = desktop.getBackground(unusedColor);
1055
color_display->color(colorSet);
1056
color_display->show();
1022
color_display1->color(colorSet);
1023
color_display1->show();
1024
color_display2->hide();
1025
background_displayer_thingie->hide();
1026
desktop.saveChangesTemp();
1061
void DesktopUI::two_color(Fl_Box *o, Fl_Box *o2) {
1030
void DesktopUI::two_color() {
1062
1031
flDesktop desktop;desktop.loadTemp();
1067
Fl::get_color((o->color()),r,g,b);
1069
double* colors = new double[4];
1079
Fl::get_color((o2->color()),r,g,b);
1082
const char * label2 ="choose";
1083
c2= fl_color_chooser(label2,r2,g2,b2,2);
1085
double* colors2 = new double[4];
1086
colors2[0] = int(r2);
1087
colors2[1] = int(g2);
1088
colors2[2] = int(b2);
1090
if(c2!=0){ //If color chooser isn't canceled... do stuff
1092
//desktop.setBackground(colors,colors2);
1093
unsigned int usedColor;
1094
unsigned int unusedColor = desktop.getBackground(usedColor);
1095
o2->color(usedColor);
1036
const char * label ="Choose 1st Color";
1037
c= fl_color_chooser(label,r,g,b,2);
1038
double* gradient1 = new double[4];
1039
gradient1[0] = int(r);
1040
gradient1[1] = int(g);
1041
gradient1[2] = int(b);
1043
if(c!=0){ //If color chooser isn't canceled... do stuff
1048
const char * label2 ="Choose 2nd Color";
1049
c2= fl_color_chooser(label2,r2,g2,b2,2);
1050
double* gradient2 = new double[4];
1051
gradient2[0] = int(r2);
1052
gradient2[1] = int(g2);
1053
gradient2[2] = int(b2);
1055
if(c2!=0){ //If color chooser isn't canceled... do stuff
1056
desktop.setBackground(gradient1,gradient2);
1057
unsigned int color2;
1058
unsigned int color1 = desktop.getBackground(color2);
1059
color_display1->color(color1);
1060
color_display2->color(color2);
1061
color_display1->show();
1062
color_display2->show();
1063
background_displayer_thingie->hide();
1064
color_display1->redraw();
1065
color_display2->redraw();
1066
desktop.saveChangesTemp();