+PaletteHexButton::PaletteHexButton(ColorWindow *window, int x, int y)
+ : BC_GenericButton(x, y, 50, "#")
+{
+ this->window = window;
+ set_tooltip(_("hex rgb color"));
+}
+PaletteHexButton::~PaletteHexButton()
+{
+}
+int PaletteHexButton::handle_event()
+{
+ const char *hex = window->hex_box->get_text();
+ window->update_rgb_hex(hex);
+ return 1;
+}
+
+PaletteHex::PaletteHex(ColorWindow *window, int x, int y, const char *hex)
+ : BC_TextBox(x, y, 100, 1, hex)
+{
+ this->window = window;
+}
+PaletteHex::~PaletteHex()
+{
+}
+void PaletteHex::update()
+{
+ char hex[BCSTRLEN]; sprintf(hex,"%06x",window->rgb888());
+ BC_TextBox::update(hex);
+}
+
+int PaletteHex::keypress_event()
+{
+ if( get_keypress() != RETURN )
+ return BC_TextBox::keypress_event();
+ window->update_rgb_hex(get_text());
+ return 1;
+}
+
+#include "grabpick_up_png.h"
+#include "grabpick_hi_png.h"
+#include "grabpick_dn_png.h"
+
+PaletteGrabButton::PaletteGrabButton(ColorWindow *window, int x, int y)
+ : BC_Button(x, y, vframes)
+{
+ this->window = window;
+ vframes[0] = new VFramePng(grabpick_up_png);
+ vframes[1] = new VFramePng(grabpick_hi_png);
+ vframes[2] = new VFramePng(grabpick_dn_png);
+ set_tooltip(_("grab from anywhere picker"));
+}
+PaletteGrabButton::~PaletteGrabButton()
+{
+ for( int i=0; i<3; ++i )
+ delete vframes[i];
+}
+int PaletteGrabButton::handle_event()
+{
+ if( window->grab_buttons() ) {
+ grab_cursor();
+ window->button_grabbed = 1;
+ button_press_event(); // redraw face HI
+ }
+ return 1;
+}
+
+PaletteHistory::PaletteHistory(ColorWindow *window, int x, int y)
+ : BC_SubWindow(x,y, 200, 24)
+{
+ this->window = window;
+ button_down = 0;
+ set_tooltip(_("color history"));
+}
+PaletteHistory::~PaletteHistory()
+{
+}
+void PaletteHistory::update(int flush)
+{
+ int x1 = 0, x2 = 0;
+ for( int i=0; i<PALLETTE_HISTORY_SIZE; x1=x2 ) {
+ int rgb = window->palette_history[i];
+ x2 = (++i * get_w())/PALLETTE_HISTORY_SIZE;
+ draw_3d_box(x1,0,x2-x1,get_h(),WHITE,BLACK,rgb,LTBLUE,DKBLUE);
+ }
+ flash(flush);
+}
+
+int PaletteHistory::button_press_event()
+{
+ if( button_down || !is_event_win() ) return 0;
+ button_down = 1;
+ cursor_motion_event();
+ return 1;
+}
+int PaletteHistory::button_release_event()
+{
+ if( !button_down || !is_event_win() ) return 0;
+ cursor_motion_event();
+ if( button_down > 0 ) {
+ window->handle_event();
+ window->update_display();
+ window->update_history();
+ }
+ button_down = 0;
+ return 1;
+}
+int PaletteHistory::cursor_motion_event()
+{
+ if( !button_down || !is_event_win() ) return 0;
+ hide_tooltip();
+ int pick = (PALLETTE_HISTORY_SIZE * get_cursor_x()) / get_w();
+ bclamp(pick, 0, PALLETTE_HISTORY_SIZE-1);
+ int color = window->palette_history[pick];
+ float r = ((color>>16) & 0xff) / 255.;
+ float g = ((color>>8) & 0xff) / 255.;
+ float b = ((color>>0) & 0xff) / 255.;
+ if( window->rgb.r != r || window->rgb.g != g || window->rgb.b != b ) {
+ window->rgb.r = r; window->rgb.g = g; window->rgb.b = b;
+ window->update_rgb();
+ }
+ return 1;
+}
+
+int PaletteHistory::cursor_leave_event()
+{
+ hide_tooltip();
+ return 0;
+}
+int PaletteHistory::repeat_event(int64_t duration)
+{
+ int result = 0;
+
+ if( duration == get_resources()->tooltip_delay &&
+ get_tooltip() && *get_tooltip() && cursor_above() ) {
+ show_tooltip();
+ result = 1;
+ }
+ return result;
+}
+