1 /* vim:expandtab:ts=2 sw=2: 2 */ 3 /* Grafx2 - The Ultimate 256-color bitmap paint program 4 5 Copyright owned by various GrafX2 authors, see COPYRIGHT.txt for details. 6 7 Grafx2 is free software; you can redistribute it and/or 8 modify it under the terms of the GNU General Public License 9 as published by the Free Software Foundation; version 2 10 of the License. 11 12 Grafx2 is distributed in the hope that it will be useful, 13 but WITHOUT ANY WARRANTY; without even the implied warranty of 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 GNU General Public License for more details. 16 17 You should have received a copy of the GNU General Public License 18 along with Grafx2; if not, see <http://www.gnu.org/licenses/> 19 */ 20 21 ////////////////////////////////////////////////////////////////////////////// 22 ///@file windows.h 23 /// Graphical interface management functions (windows, menu, cursor) 24 ////////////////////////////////////////////////////////////////////////////// 25 26 #ifndef __WINDOWS_H_ 27 #define __WINDOWS_H_ 28 29 #include "struct.h" 30 31 #define ToWinX(x) (((x)*Menu_factor_X)+Window_pos_X) 32 #define ToWinY(y) (((y)*Menu_factor_Y)+Window_pos_Y) 33 #define ToWinL(l) ((l)*Menu_factor_X) 34 #define ToWinH(h) ((h)*Menu_factor_Y) 35 36 #define Update_window_area(x,y,w,h) Update_rect(Window_pos_X+(x)*Menu_factor_X,Window_pos_Y+(y)*Menu_factor_Y,(w)*Menu_factor_X,(h)*Menu_factor_Y); 37 38 void Display_cursor(void); 39 void Hide_cursor(void); 40 41 void Remap_screen_after_menu_colors_change(void); 42 void Compute_optimal_menu_colors(const T_Components * palette); 43 44 void Position_screen_according_to_zoom(void); 45 void Compute_separator_data(void); 46 void Compute_magnifier_data(void); 47 void Clip_magnifier_offsets(short *x_offset, short *y_offset); 48 void Compute_limits(void); 49 void Compute_paintbrush_coordinates(void); 50 51 void Pixel_in_menu(word bar, word x, word y, byte color); 52 void Pixel_in_menu_and_skin(word bar, word x, word y, byte color); 53 void Pixel_in_window(word x,word y,byte color); 54 void Set_fore_color(byte color); 55 void Set_back_color(byte color); 56 void Frame_menu_color(byte id); 57 void Display_menu_palette(void); 58 void Display_menu(void); 59 void Display_layerbar(void); 60 void Reposition_palette(void); 61 void Change_palette_cells(void); 62 int Pick_color_in_palette(void); 63 word Palette_cells_X(void); 64 word Palette_cells_Y(void); 65 66 void Print_general(short x,short y,const char * str,byte text_color,byte background_color); 67 void Print_general_unicode(short x,short y,const word * str,byte text_color,byte background_color); 68 void Print_in_window_underscore(short x,short y,const char * str,byte text_color,byte background_color, byte undersc_letter); 69 void Print_in_window(short x,short y,const char * str,byte text_color,byte background_color); 70 void Print_in_window_unicode(short x,short y,const word * str,byte text_color,byte background_color); 71 void Print_in_window_limited(short x,short y,const char * str,byte size,byte text_color,byte background_color); 72 void Print_in_window_limited_unicode(short x, short y, const word * str, byte size, byte text_color, byte background_color); 73 void Print_char_in_window(short x_pos,short y_pos, unsigned int c,byte text_color,byte background_color); 74 void Print_in_menu(const char * str, short position); 75 void Print_coordinates(void); 76 void Print_filename(void); 77 void Print_counter(short x,short y,const char * str,byte text_color,byte background_color); 78 79 /** @defgroup dialog Dialog windows 80 * Popups that show or ask an information to the user 81 * @{ */ 82 byte Confirmation_box(const char * message); 83 void Warning_message(const char * message); 84 void Warning_with_format(const char * message, ...); 85 void Verbose_message(const char * caption, const char * message); 86 int Requester_window(const char* message, int initial_value); 87 typedef struct { 88 int value; ///< integer value 89 const char * label; ///< label for dropdown 90 const char * hint; ///< optional help text 91 } T_MultipleChoice; 92 int Dialog_multiple_choice(const char * title, const T_MultipleChoice * choices, int initial_choice); 93 /** @} */ 94 95 void Display_image_limits(void); 96 void Display_all_screen(void); 97 void Window_rectangle(word x_pos,word y_pos,word width,word height,byte color); 98 void Window_display_frame_generic(word x_pos,word y_pos,word width,word height, 99 byte color_tl,byte color_br,byte color_s,byte color_tlc,byte color_brc); 100 void Window_display_frame_mono(word x_pos,word y_pos,word width,word height,byte color); 101 void Window_display_frame_in(word x_pos,word y_pos,word width,word height); 102 void Window_display_frame_out(word x_pos,word y_pos,word width,word height); 103 void Window_display_frame(word x_pos,word y_pos,word width,word height); 104 105 void Display_sprite_in_menu(int btn_number,char sprite_number); 106 void Display_paintbrush_in_menu(void); 107 void Display_paintbrush_in_window(word x,word y,int number); 108 109 void Draw_thingumajig(word x,word y, byte color, short direction); 110 void Display_grad_block_in_window(word x_pos,word y_pos,word width,word height,word block_start,word block_end); 111 void Window_display_icon_sprite(word x_pos,word y_pos,byte type); 112 113 byte Best_color(byte red,byte green,byte blue); 114 byte Best_color_nonexcluded(byte red,byte green,byte blue); 115 byte Best_color_range(byte red,byte green,byte blue,byte max); 116 byte Best_color_perceptual(byte r,byte g,byte b); 117 byte Best_color_perceptual_except(byte r,byte g,byte b, byte except); 118 119 void Horizontal_XOR_line_zoom(short x_pos, short y_pos, short width); 120 void Vertical_XOR_line_zoom(short x_pos, short y_pos, short height); 121 122 void Change_magnifier_factor(byte factor_index, byte point_at_mouse); 123 124 /// Width of one layer button, in pixels before scaling 125 extern word Layer_button_width; 126 127 /// Copy viewport settings and offsets from the Main to the Spare. 128 void Copy_view_to_spare(void); 129 130 /// Definition of a toolbar button 131 typedef struct 132 { 133 // Button aspect 134 word X_offset; ///< Position relative to menu's left 135 word Y_offset; ///< Position relative to menu's top 136 word Width; ///< Button's active width 137 word Height; ///< Button's active heigth 138 byte Pressed; ///< Button is currently pressed 139 byte Shape; ///< Shape, listed in enum ::BUTTON_SHAPES 140 signed char Icon; ///< Which icon to display: Either the one from the toolbar (-1) or one of ::MENU_SPRITE 141 142 // Triggers on mouse/keyboard 143 Func_btn_action Left_action; ///< Action triggered by a left mouseclick on the button 144 Func_btn_action Right_action; ///< Action triggered by a right mouseclick on the button 145 word Left_shortcut[2]; ///< Keyboard shortcut for a left mouseclick 146 word Right_shortcut[2];///< Keyboard shortcut for a right mouseclick 147 byte Left_instant; ///< Will not wait for mouse release before triggering action 148 byte Right_instant; ///< Will not wait for mouse release before triggering action 149 const char * Tooltip; ///< Text in status bar when button is hovered 150 151 // Data used when the button is unselected 152 Func_btn_action Unselect_action; ///< Action triggered by unselecting the button 153 byte Family; ///< enum ::FAMILY_OF_BUTTONS. 154 155 } T_Toolbar_button; 156 157 extern T_Toolbar_button Buttons_Pool[NB_BUTTONS]; 158 159 // A menubar. 160 typedef struct { 161 word Width; 162 word Height; 163 byte Visible; 164 word Top; ///< Relative to the top line of the menu, hidden bars don't count. 165 byte* Skin[3]; ///< [0] has normal buttons, [1] has selected buttons, [2] is current. 166 word Skin_width; 167 byte Last_button_index; 168 } T_Menu_Bar; 169 170 enum { 171 MENUBAR_STATUS = 0, // MUST be 0 172 MENUBAR_ANIMATION, 173 MENUBAR_LAYERS, 174 MENUBAR_TOOLS, 175 MENUBAR_COUNT 176 }; 177 178 extern T_Menu_Bar Menu_bars[MENUBAR_COUNT]; 179 180 #endif 181