Update gtk117
This commit is contained in:
parent
da8e5a64bf
commit
dd2656a9ff
|
@ -9,14 +9,15 @@ MyWin::MyWin()
|
||||||
hbox(Gtk::ORIENTATION_HORIZONTAL,5),
|
hbox(Gtk::ORIENTATION_HORIZONTAL,5),
|
||||||
btnbox(Gtk::ORIENTATION_VERTICAL,5),
|
btnbox(Gtk::ORIENTATION_VERTICAL,5),
|
||||||
frame_pos("Position"),
|
frame_pos("Position"),
|
||||||
frame_css_rgba("rgba() for css3"),
|
frame_css_rgba("rgb()/rgba() for css3"),
|
||||||
frame_rgba_str("RGBA Code"),
|
frame_rgba_str("RGB(A) Code"),
|
||||||
label_pos("(640,480)"),
|
label_pos("(640,480)"),
|
||||||
label_css_rgba("rgba(255,255,255,255)"),
|
label_css_rgba("rgba(255,255,255,255)"),
|
||||||
label_test("Color Settings And Position info"),
|
label_test("Color Settings And Position info"),
|
||||||
label_color_str("#00000000"),
|
label_color_str("#00000000"),
|
||||||
btn_css_code("Copy Css3 Code"),
|
btn_css_code("Copy Css3 Code"),
|
||||||
btn_color_str("Copy RGB(A) String")
|
btn_color_str("Copy RGB(A) String"),
|
||||||
|
btn_select("Pick Color")
|
||||||
{
|
{
|
||||||
set_title("Color Picker");
|
set_title("Color Picker");
|
||||||
set_icon_name("org.gtk.daleclack");
|
set_icon_name("org.gtk.daleclack");
|
||||||
|
@ -36,6 +37,10 @@ btn_color_str("Copy RGB(A) String")
|
||||||
btn_color_str.set_halign(Gtk::ALIGN_CENTER);
|
btn_color_str.set_halign(Gtk::ALIGN_CENTER);
|
||||||
btn_color_str.signal_clicked().connect(sigc::mem_fun(*this,&MyWin::btncolor_clicked));
|
btn_color_str.signal_clicked().connect(sigc::mem_fun(*this,&MyWin::btncolor_clicked));
|
||||||
|
|
||||||
|
btn_select.set_active(false);
|
||||||
|
btn_select.set_halign(Gtk::ALIGN_CENTER);
|
||||||
|
btn_select.signal_clicked().connect(sigc::mem_fun(*this,&MyWin::btnselect_clicked));
|
||||||
|
|
||||||
//Add Gesture
|
//Add Gesture
|
||||||
gesture = Gtk::GestureMultiPress::create(draw_area);
|
gesture = Gtk::GestureMultiPress::create(draw_area);
|
||||||
gesture->set_button(1);
|
gesture->set_button(1);
|
||||||
|
@ -46,7 +51,7 @@ btn_color_str("Copy RGB(A) String")
|
||||||
|
|
||||||
//Set image
|
//Set image
|
||||||
gtk_image_set_from_pixbuf(background.gobj(),sized->gobj());
|
gtk_image_set_from_pixbuf(background.gobj(),sized->gobj());
|
||||||
//get_pixel_color(320,180);
|
get_pixel_color(320,180);
|
||||||
|
|
||||||
//Add Color and Image Button
|
//Add Color and Image Button
|
||||||
color_btn.set_use_alpha();
|
color_btn.set_use_alpha();
|
||||||
|
@ -64,6 +69,7 @@ btn_color_str("Copy RGB(A) String")
|
||||||
|
|
||||||
btnbox.pack_start(color_btn);
|
btnbox.pack_start(color_btn);
|
||||||
btnbox.pack_start(btn_back);
|
btnbox.pack_start(btn_back);
|
||||||
|
btnbox.pack_start(btn_select);
|
||||||
btnbox.pack_start(btn_css_code);
|
btnbox.pack_start(btn_css_code);
|
||||||
btnbox.pack_start(btn_color_str);
|
btnbox.pack_start(btn_color_str);
|
||||||
btnbox.set_valign(Gtk::ALIGN_CENTER);
|
btnbox.set_valign(Gtk::ALIGN_CENTER);
|
||||||
|
@ -105,10 +111,10 @@ void MyWin::get_pixel_color(int x,int y){
|
||||||
|
|
||||||
//Set Color to rgba
|
//Set Color to rgba
|
||||||
red/=25;blue/=25;green/=25;alpha/=25;
|
red/=25;blue/=25;green/=25;alpha/=25;
|
||||||
color_set.set_red(red/255.0);
|
color_set.set_red_u(red*257);
|
||||||
color_set.set_blue(blue/255.0);
|
color_set.set_blue_u(blue*257);
|
||||||
color_set.set_green(green/255.0);
|
color_set.set_green_u(green*257);
|
||||||
color_set.set_alpha(alpha/255.0);
|
color_set.set_alpha_u(alpha*257);
|
||||||
|
|
||||||
//Get Color set as a string
|
//Get Color set as a string
|
||||||
label_css_rgba.set_label(color_set.to_string());
|
label_css_rgba.set_label(color_set.to_string());
|
||||||
|
@ -127,10 +133,18 @@ void MyWin::get_pixel_color(int x,int y){
|
||||||
}
|
}
|
||||||
|
|
||||||
void MyWin::gesture_pressed(int n_press,double x,double y){
|
void MyWin::gesture_pressed(int n_press,double x,double y){
|
||||||
char pos[57];
|
if(btn_select.get_active()){
|
||||||
sprintf(pos,"(%.2f,%.2f)",x,y);
|
//Get Color at the position
|
||||||
label_pos.set_label(pos);
|
char pos[57];
|
||||||
get_pixel_color((int)x, (int)y);
|
sprintf(pos,"(%.2f,%.2f)",x,y);
|
||||||
|
label_pos.set_label(pos);
|
||||||
|
get_pixel_color((int)x, (int)y);
|
||||||
|
btn_select.set_active(false);
|
||||||
|
|
||||||
|
//Unset custom cursor
|
||||||
|
auto gdkwin = background.get_window();
|
||||||
|
gdkwin->set_cursor();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MyWin::btnback_clicked(){
|
void MyWin::btnback_clicked(){
|
||||||
|
@ -190,3 +204,11 @@ void MyWin::btncolor_clicked(){
|
||||||
Glib::ustring str = label_color_str.get_label();
|
Glib::ustring str = label_color_str.get_label();
|
||||||
clipboard->set_text(str);
|
clipboard->set_text(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MyWin::btnselect_clicked(){
|
||||||
|
//Set a cursor for selection on image
|
||||||
|
auto display = background.get_display();
|
||||||
|
auto gdkwin = background.get_window();
|
||||||
|
auto cursor = Gdk::Cursor::create(display,"crosshair");
|
||||||
|
gdkwin->set_cursor(cursor);
|
||||||
|
}
|
||||||
|
|
|
@ -15,6 +15,7 @@ class MyWin : public Gtk::Window{
|
||||||
Gtk::Label label_pos,label_css_rgba,label_test,label_color_str;
|
Gtk::Label label_pos,label_css_rgba,label_test,label_color_str;
|
||||||
Gtk::ColorButton color_btn;
|
Gtk::ColorButton color_btn;
|
||||||
Gtk::Button btn_css_code,btn_color_str;
|
Gtk::Button btn_css_code,btn_color_str;
|
||||||
|
Gtk::ToggleButton btn_select;
|
||||||
Gtk::DrawingArea draw_area;
|
Gtk::DrawingArea draw_area;
|
||||||
Glib::RefPtr<Gdk::Pixbuf> pixbuf;
|
Glib::RefPtr<Gdk::Pixbuf> pixbuf;
|
||||||
Glib::RefPtr<Gdk::Pixbuf> sized;
|
Glib::RefPtr<Gdk::Pixbuf> sized;
|
||||||
|
@ -30,4 +31,5 @@ class MyWin : public Gtk::Window{
|
||||||
void gesture_pressed(int n_press,double x,double y);
|
void gesture_pressed(int n_press,double x,double y);
|
||||||
void btncss_clicked();
|
void btncss_clicked();
|
||||||
void btncolor_clicked();
|
void btncolor_clicked();
|
||||||
|
void btnselect_clicked();
|
||||||
};
|
};
|
|
@ -1,32 +1,53 @@
|
||||||
//http://acm.hdu.edu.cn/showproblem.php?pid=2004
|
//http://acm.hdu.edu.cn/showproblem.php?pid=2005
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
|
||||||
int main(int argc,char ** argv){
|
int main(int argc,char ** argv){
|
||||||
int year,month,day,sum_day=0;
|
int year,month,day,sum_day=0;
|
||||||
while (scanf("%d/%d/%d",&year,&month,&day)!=EOF)
|
while (scanf("%d/%d/%d",&year,&month,&day)!=EOF)
|
||||||
{
|
{
|
||||||
|
sum_day=0;
|
||||||
switch(month){
|
switch(month){
|
||||||
case 1:
|
case 1:
|
||||||
sum_day+=31;
|
sum_day = day;
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
if(month%4 == 0 && month%100 != 0){
|
sum_day = 31+day;
|
||||||
sum_day += 60;
|
|
||||||
}else{
|
|
||||||
sum_day += 59;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
|
sum_day = 59+day;
|
||||||
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
|
sum_day = 90+day;
|
||||||
|
break;
|
||||||
case 5:
|
case 5:
|
||||||
|
sum_day = 120+day;
|
||||||
|
break;
|
||||||
case 6:
|
case 6:
|
||||||
|
sum_day = 151+day;
|
||||||
|
break;
|
||||||
case 7:
|
case 7:
|
||||||
|
sum_day = 181+day;
|
||||||
|
break;
|
||||||
case 8:
|
case 8:
|
||||||
|
sum_day = 212+day;
|
||||||
|
break;
|
||||||
case 9:
|
case 9:
|
||||||
|
sum_day = 243+day;
|
||||||
|
break;
|
||||||
case 10:
|
case 10:
|
||||||
|
sum_day = 273+day;
|
||||||
|
break;
|
||||||
case 11:
|
case 11:
|
||||||
|
sum_day = 304+day;
|
||||||
|
break;
|
||||||
case 12:
|
case 12:
|
||||||
|
sum_day = 334+day;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
if(year%4 == 0 && year%100 != 0 && month > 2){
|
||||||
|
sum_day += 1;
|
||||||
|
}
|
||||||
|
printf("%d\n",sum_day);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
Loading…
Reference in New Issue