~israeldahl/jwm-settings-manager/trunk

« back to all changes in this revision

Viewing changes to fltk/jwm-desktop.cxx

  • Committer: Israel Dahl
  • Date: 2014-07-06 02:48:28 UTC
  • Revision ID: israeldahl@gmail.com-20140706024828-1bt17riyy2ep06bt
actually added the themes, buttons, etc...
* Alpha Version update
 * Desktop
 - Added Rox checkers, and getters and setters, but haven't finished/enabled it
 - Finished gradient support
 - finished Single color support
 - moved the image setting code to flDesktop(h/cpp)
 * Window
 - fixed Window icon code to reliably open the directory containing icons
 - added 'BoxShaped' window buttons

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
#include <libintl.h>
28
28
#include "jwm-desktop.h"
29
29
 
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
 
display(bg);
 
33
desktop.setFlImage(o,bg);
34
34
}
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);
99
99
 
100
100
void DesktopUI::cb_Icons_i(Fl_Check_Button*, void*) {
101
101
  flDesktop desktop;desktop.loadTemp();
 
102
bool choice = desktop.roxActive();
 
103
choice = !choice;
 
104
desktop.useRox(choice);
 
105
if (choice){
 
106
        //call relevant function
 
107
}
 
108
else{
 
109
        //use JWM
 
110
};
102
111
}
103
112
void DesktopUI::cb_Icons(Fl_Check_Button* o, void* v) {
104
113
  ((DesktopUI*)(o->parent()->user_data()))->cb_Icons_i(o,v);
105
114
}
106
115
 
107
116
void DesktopUI::cb_Choose1_i(Fl_Button*, void*) {
108
 
  flDesktop desktop;desktop.loadTemp();
 
117
  two_color();
109
118
}
110
119
void DesktopUI::cb_Choose1(Fl_Button* o, void* v) {
111
120
  ((DesktopUI*)(o->parent()->user_data()))->cb_Choose1_i(o,v);
846
855
static Fl_RGB_Image image_jsm(idata_jsm, 62, 62, 4, 0);
847
856
 
848
857
void DesktopUI::cb_Choose3_i(Fl_Button*, void*) {
849
 
  one_color(background_displayer_thingie);
 
858
  one_color();
850
859
}
851
860
void DesktopUI::cb_Choose3(Fl_Button* o, void* v) {
852
861
  ((DesktopUI*)(o->parent()->user_data()))->cb_Choose3_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();
866
 
      display(bg);
 
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);
935
 
      o->deactivate();
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;
962
976
}
963
977
 
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);
973
 
  if(isColor !="#"){
974
 
        extention = filenameStr.substr((strlen(filename)-4),4);
975
 
        std::transform(extention.begin(), extention.end(), extention.begin(), ::tolower);
976
 
        Fl_Image* image;
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();
985
 
  /*            }
986
 
                else if(visibleColor ==0 && visibleImage !=0){
987
 
                        background_displayer_thingie->image(image2);
988
 
                        background_displayer_thingie->redraw();
989
 
                }*/
990
 
        }
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();
999
 
  /*            }
1000
 
                else if(visibleColor ==0 && visibleImage !=0){
1001
 
                        background_displayer_thingie->image(image2);
1002
 
                        background_displayer_thingie->redraw();
1003
 
                }*/
1004
 
        }
1005
 
  }
1006
 
  else{
1007
 
  std::cout<<"it is a color\n";
1008
 
  }
1009
 
  }
1010
 
}
1011
 
 
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);
1030
 
                display(result);
 
996
                color_display1->hide();
 
997
                color_display2->hide();
 
998
                desktop.setFlImage(background_displayer_thingie,result);
1031
999
        }
1032
1000
  }
1033
1001
}
1034
1002
 
1035
 
void DesktopUI::one_color(Fl_Box *o) {
 
1003
void DesktopUI::one_color() {
1036
1004
  flDesktop desktop;desktop.loadTemp();
1037
1005
  uchar r;
1038
1006
  uchar g;
1039
1007
  uchar b;
1040
 
  Fl::get_color((o->color()),r,g,b);
1041
1008
  
1042
1009
  int c;
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();
1057
 
        o->hide();
 
1022
        color_display1->color(colorSet);
 
1023
        color_display1->show();
 
1024
        color_display2->hide();
 
1025
        background_displayer_thingie->hide();
 
1026
        desktop.saveChangesTemp();
1058
1027
  }
1059
1028
}
1060
1029
 
1061
 
void DesktopUI::two_color(Fl_Box *o, Fl_Box *o2) {
 
1030
void DesktopUI::two_color() {
1062
1031
  flDesktop desktop;desktop.loadTemp();
1063
1032
  uchar r;
1064
1033
  uchar g;
1065
1034
  uchar b;
1066
 
  
1067
 
  Fl::get_color((o->color()),r,g,b);
1068
 
  
1069
 
  double* colors = new double[4];
1070
 
  colors[0] = int(r); 
1071
 
  colors[1] = int(g);
1072
 
  colors[2] = int(b);
1073
 
  colors[3] = 0;
1074
 
  
1075
 
  uchar r2;
1076
 
  uchar g2;
1077
 
  uchar b2;
1078
 
  
1079
 
  Fl::get_color((o2->color()),r,g,b);
1080
 
  
1081
 
  int c2;
1082
 
  const char * label2 ="choose";
1083
 
  c2= fl_color_chooser(label2,r2,g2,b2,2);
1084
 
  
1085
 
  double* colors2 = new double[4];
1086
 
  colors2[0] = int(r2); 
1087
 
  colors2[1] = int(g2);
1088
 
  colors2[2] = int(b2);
1089
 
  colors2[3] = 0;
1090
 
  if(c2!=0){ //If color chooser isn't canceled... do stuff
1091
 
  
1092
 
        //desktop.setBackground(colors,colors2);
1093
 
        unsigned int usedColor;
1094
 
        unsigned int unusedColor = desktop.getBackground(usedColor);
1095
 
        o2->color(usedColor);
1096
 
        o2->redraw();
 
1035
  int c;
 
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);
 
1042
  gradient1[3] = 0;
 
1043
  if(c!=0){ //If color chooser isn't canceled... do stuff
 
1044
        uchar r2;
 
1045
        uchar g2;
 
1046
        uchar b2;
 
1047
        int c2;
 
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);
 
1054
        gradient2[3] = 0;
 
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();
 
1067
        }
1097
1068
  }
1098
1069
}