1 /* 2 3 Copyright (c) 2003-2013 uim Project https://github.com/uim/uim 4 5 All rights reserved. 6 7 Redistribution and use in source and binary forms, with or without 8 modification, are permitted provided that the following conditions 9 are met: 10 11 1. Redistributions of source code must retain the above copyright 12 notice, this list of conditions and the following disclaimer. 13 2. Redistributions in binary form must reproduce the above copyright 14 notice, this list of conditions and the following disclaimer in the 15 documentation and/or other materials provided with the distribution. 16 3. Neither the name of authors nor the names of its contributors 17 may be used to endorse or promote products derived from this software 18 without specific prior written permission. 19 20 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND 21 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE 24 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 26 OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29 OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 SUCH DAMAGE. 31 32 */ 33 34 #ifndef UIM_GTK_UIM_CAND_WIN_GTK_H 35 #define UIM_GTK_UIM_CAND_WIN_GTK_H 36 37 #include <gtk/gtk.h> 38 39 G_BEGIN_DECLS 40 41 #define UIM_TYPE_CAND_WIN_GTK (uim_cand_win_gtk_get_type ()) 42 #define UIM_CAND_WIN_GTK(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), UIM_TYPE_CAND_WIN_GTK, UIMCandWinGtk)) 43 #define UIM_CAND_WIN_GTK_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), UIM_TYPE_CAND_WIN_GTK, UIMCandWinGtkClass)) 44 #define UIM_IS_CAND_WIN_GTK(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), UIM_TYPE_CAND_WIN_GTK)) 45 #define UIM_IS_CAND_WIN_GTK_CLASS(klass)(G_TYPE_CHECK_CLASS_TYPE ((klass), UIM_TYPE_CAND_WIN_GTK)) 46 #define UIM_CAND_WIN_GTK_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), UIM_TYPE_CAND_WIN_GTK, UIMCandWinGtkClass)) 47 48 typedef struct _UIMCandWinGtk UIMCandWinGtk; 49 typedef struct _UIMCandWinGtkClass UIMCandWinGtkClass; 50 51 typedef enum { 52 UIM_CAND_WIN_POS_CARET, 53 UIM_CAND_WIN_POS_LEFT, 54 UIM_CAND_WIN_POS_RIGHT 55 } UimCandWinPos; 56 57 struct _UIMCandWinGtk { 58 GtkWindow parent; 59 60 GtkWidget *scrolled_window; 61 GtkWidget *view; 62 GtkWidget *num_label; 63 GtkWidget *prev_page_button; 64 GtkWidget *next_page_button; 65 66 GPtrArray *stores; 67 68 guint nr_candidates; 69 guint display_limit; 70 gint candidate_index; 71 gint page_index; 72 73 UimCandWinPos position; 74 75 GdkRectangle cursor; 76 gboolean block_index_selection; 77 gboolean index_changed; 78 79 /* sub window */ 80 struct sub_window { 81 GtkWidget *window; 82 GtkWidget *scrolled_window; 83 GtkWidget *text_view; 84 gboolean active; 85 } sub_window; 86 }; 87 88 struct _UIMCandWinGtkClass { 89 GtkWindowClass parent_class; 90 91 /* signals */ 92 void (*index_changed) (UIMCandWinGtkClass *cwin); 93 94 /* member functions */ 95 void (*set_index) (UIMCandWinGtk *cwin, gint index); 96 void (*set_page) (UIMCandWinGtk *cwin, gint page); 97 void (*create_sub_window) (UIMCandWinGtk *cwin); 98 void (*layout_sub_window) (UIMCandWinGtk *cwin); 99 }; 100 101 102 GType uim_cand_win_gtk_register_type (GTypeModule *module); 103 GType uim_cand_win_gtk_get_type (void); 104 UIMCandWinGtk *uim_cand_win_gtk_new (void); 105 106 void uim_cand_win_gtk_set_candidates (UIMCandWinGtk *cwin, 107 guint disp_limit, 108 GSList *candidates); 109 void uim_cand_win_gtk_set_page_candidates (UIMCandWinGtk *cwin, 110 guint page, 111 GSList *candidates); 112 void uim_cand_win_gtk_set_nr_candidates (UIMCandWinGtk *cwin, 113 guint nr, 114 guint disp_limit); 115 void uim_cand_win_gtk_clear_candidates (UIMCandWinGtk *cwin); 116 guint uim_cand_win_gtk_get_nr_candidates (UIMCandWinGtk *cwin); 117 gint uim_cand_win_gtk_get_index (UIMCandWinGtk *cwin); 118 void uim_cand_win_gtk_set_index (UIMCandWinGtk *cwin, 119 gint index); 120 121 guint uim_cand_win_gtk_get_nr_pages (UIMCandWinGtk *cwin); 122 gint uim_cand_win_gtk_get_page (UIMCandWinGtk *cwin); 123 void uim_cand_win_gtk_set_page (UIMCandWinGtk *cwin, 124 gint page); 125 void uim_cand_win_gtk_shift_page (UIMCandWinGtk *cwin, 126 gboolean forward); 127 guint uim_cand_win_gtk_query_new_page_by_cand_select 128 (UIMCandWinGtk *cwin, 129 gint index); 130 guint uim_cand_win_gtk_query_new_page_by_shift_page 131 (UIMCandWinGtk *cwin, 132 gboolean forward); 133 134 void uim_cand_win_gtk_set_scrollable (UIMCandWinGtk *cwin, 135 gboolean scrollable); 136 137 void uim_cand_win_gtk_layout (UIMCandWinGtk *cwin, 138 gint topwin_x, 139 gint topwin_y, 140 gint topwin_width, 141 gint topwin_height); 142 void uim_cand_win_gtk_set_cursor_location (UIMCandWinGtk *cwin, 143 GdkRectangle *area); 144 void uim_cand_win_gtk_get_window_pos_type (UIMCandWinGtk *cwin); 145 146 void uim_cand_win_gtk_update_label (UIMCandWinGtk *cwin); 147 148 void uim_cand_win_gtk_create_sub_window(UIMCandWinGtk *cwin); 149 void uim_cand_win_gtk_layout_sub_window(UIMCandWinGtk *cwin); 150 151 G_END_DECLS 152 153 #endif /*UIM_GTK_UIM_CAND_WIN_GTK_H */ 154