From 1d598acbe61bb7f93936584d6e34fc8ace5d43f1 Mon Sep 17 00:00:00 2001 From: Phil Cowans Date: Thu, 11 May 2006 16:21:22 +0000 Subject: [PATCH] Various small changes * Various small changes --- Src/DasherCore/Alphabet/AlphIO.cpp | 4 +- Src/DasherCore/DasherButtons.cpp | 13 ++- Src/DasherCore/DasherButtons.h | 3 + Src/DasherCore/DasherModel.cpp | 5 + Src/DasherCore/Parameters.h | 2 +- Src/Gtk2/FontDialogues.cpp | 36 ++++--- Src/Gtk2/dasher.glade | 209 +++++++++++++++++++++---------------- Src/Gtk2/dasher_main.cpp | 10 +- 8 files changed, 169 insertions(+), 113 deletions(-) diff --git a/Src/DasherCore/Alphabet/AlphIO.cpp b/Src/DasherCore/Alphabet/AlphIO.cpp index 1054d734..75c42d6e 100644 --- a/Src/DasherCore/Alphabet/AlphIO.cpp +++ b/Src/DasherCore/Alphabet/AlphIO.cpp @@ -114,8 +114,8 @@ const CAlphIO::AlphInfo & CAlphIO::GetInfo(const std::string &AlphID) { if(AlphID == "") { // FIXME - really broken, code duplicated in Win32/Widgets/AlphabetBox.cpp // Eww. If no alphabet is configured, default to this one... - if(Alphabets.count("English alphabet - limited punctuation") != 0) { - return Alphabets["English alphabet - limited punctuation"]; + if(Alphabets.count("English with limited punctuation") != 0) { + return Alphabets["English with limited punctuation"]; } else { // unless it doesn't exist, in which case return default diff --git a/Src/DasherCore/DasherButtons.cpp b/Src/DasherCore/DasherButtons.cpp index 213cefb1..d4bc98ae 100644 --- a/Src/DasherCore/DasherButtons.cpp +++ b/Src/DasherCore/DasherButtons.cpp @@ -314,7 +314,7 @@ bool CDasherButtons::DecorateView(CDasherView *pView) { if(i != iActiveBox) pView->NewDrawGoTo(m_pBoxes[i].iDisplayTop, m_pBoxes[i].iDisplayBottom, false); } - pView->NewDrawGoTo(m_pBoxes[iActiveBox].iDisplayTop, m_pBoxes[iActiveBox].iDisplayBottom, m_bMenu); + pView->NewDrawGoTo(m_pBoxes[iActiveBox].iDisplayTop, m_pBoxes[iActiveBox].iDisplayBottom, m_bMenu || m_bHighlight); } return true; @@ -366,17 +366,22 @@ void CDasherButtons::KeyDown(int iTime, int iId, CDasherModel *pModel) { if(iId == 100) // Ignore mouse events return; if(iId == 1) - pModel->ScheduleZoom((m_pBoxes[m_iNumBoxes - 1].iBottom - m_pBoxes[m_iNumBoxes - 1].iTop)/2, (m_pBoxes[m_iNumBoxes - 1].iBottom + m_pBoxes[m_iNumBoxes - 1].iTop)/2); + iActiveBox = m_iNumBoxes - 1; else if(iId <= m_iNumBoxes) - pModel->ScheduleZoom((m_pBoxes[iId-2].iBottom - m_pBoxes[iId-2].iTop)/2, (m_pBoxes[iId-2].iBottom + m_pBoxes[iId-2].iTop)/2); + iActiveBox = iId-2; else - pModel->ScheduleZoom((m_pBoxes[m_iNumBoxes-2].iBottom - m_pBoxes[m_iNumBoxes-2].iTop)/2, (m_pBoxes[m_iNumBoxes-2].iBottom + m_pBoxes[m_iNumBoxes-2].iTop)/2); + iActiveBox = m_iNumBoxes-2; + + m_iLastTime = iTime; + + pModel->ScheduleZoom((m_pBoxes[iActiveBox].iBottom - m_pBoxes[iActiveBox].iTop)/2, (m_pBoxes[iActiveBox].iBottom + m_pBoxes[iActiveBox].iTop)/2); } } } void CDasherButtons::Timer(int Time, CDasherView *m_pDasherView, CDasherModel *m_pDasherModel) { + m_bHighlight = (Time - m_iLastTime < 200); m_pDasherModel->Tap_on_display(0, 0, Time, 0, 0); } diff --git a/Src/DasherCore/DasherButtons.h b/Src/DasherCore/DasherButtons.h index fb769ac7..d5600535 100644 --- a/Src/DasherCore/DasherButtons.h +++ b/Src/DasherCore/DasherButtons.h @@ -57,6 +57,9 @@ class CDasherButtons : public CInputFilter int iTargetWidth; + int m_iLastTime; + bool m_bHighlight; + }; #endif diff --git a/Src/DasherCore/DasherModel.cpp b/Src/DasherCore/DasherModel.cpp index 87227bbe..66984b1e 100644 --- a/Src/DasherCore/DasherModel.cpp +++ b/Src/DasherCore/DasherModel.cpp @@ -55,6 +55,11 @@ m_Rootmax_max(0), m_dAddProb(0.0), m_dMaxRate(0.0) { // -- put all this in a separate method // TODO: Think about having 'prefered' values here, which get // retrieved by DasherInterfaceBase and used to set parameters + + // TODO: We might get a different alphabet to the one we asked for - + // if this is the case then the parameter value should be updated, + // but not in such a way that it causes everything to be rebuilt. + CAlphIO::AlphInfo oAlphInfo = pAlphIO->GetInfo(GetStringParameter(SP_ALPHABET_ID)); m_pcAlphabet = new CAlphabet(oAlphInfo); diff --git a/Src/DasherCore/Parameters.h b/Src/DasherCore/Parameters.h index 5ac20c09..e9da2200 100644 --- a/Src/DasherCore/Parameters.h +++ b/Src/DasherCore/Parameters.h @@ -133,7 +133,7 @@ static lp_table longparamtable[] = { {LP_MAX_BITRATE, "MaxBitRateTimes100", PERS, 80, "Max Bit Rate Times 100"}, {LP_VIEW_ID, "ViewID", PERS, 1, "ViewID"}, {LP_LANGUAGE_MODEL_ID, "LanguageModelID", PERS, 0, "LanguageModelID"}, - {LP_DASHER_FONTSIZE, "DasherFontSize", PERS, 1, "DasherFontSize"}, + {LP_DASHER_FONTSIZE, "DasherFontSize", PERS, 2, "DasherFontSize"}, {LP_UNIFORM, "UniformTimes1000", PERS, 50, "UniformTimes1000"}, {LP_YSCALE, "YScaling", PERS, 0, "YScaling"}, {LP_MOUSEPOSDIST, "MousePositionBoxDistance", PERS, 50, "MousePositionBoxDistance"}, diff --git a/Src/Gtk2/FontDialogues.cpp b/Src/Gtk2/FontDialogues.cpp index 5c8440de..28afbccb 100644 --- a/Src/Gtk2/FontDialogues.cpp +++ b/Src/Gtk2/FontDialogues.cpp @@ -24,50 +24,60 @@ void InitialiseFontDialogues(GladeXML *pGladeWidgets) { } -extern "C" gboolean fontsel_hide(GtkWidget *widget, gpointer user_data) { +extern "C" gboolean dasher_font_cancel_cb(GtkWidget *widget, gpointer user_data) { gtk_widget_hide(GTK_WIDGET(dasher_fontselector)); return FALSE; } -extern "C" void get_font_from_dialog(GtkWidget *one, GtkWidget *two) { +extern "C" void dasher_font_ok_cb(GtkWidget *one, GtkWidget *two) { char *font_name; font_name = gtk_font_selection_dialog_get_font_name(dasher_fontselector); if(font_name) { gtk_dasher_control_set_parameter_string(GTK_DASHER_CONTROL(pDasherWidget), SP_DASHER_FONT, font_name); } - fontsel_hide(NULL, NULL); - // dasher_redraw(); + gtk_widget_hide(GTK_WIDGET(dasher_fontselector)); } +extern "C" void dasher_font_apply_cb(GtkWidget *one, GtkWidget *two) { + char *font_name; + font_name = gtk_font_selection_dialog_get_font_name(dasher_fontselector); + if(font_name) { + gtk_dasher_control_set_parameter_string(GTK_DASHER_CONTROL(pDasherWidget), SP_DASHER_FONT, font_name); + } +} + + extern "C" void set_dasher_font(GtkWidget *widget, gpointer user_data) { - g_signal_connect(dasher_fontselector->ok_button, "clicked", G_CALLBACK(get_font_from_dialog), (gpointer) dasher_fontselector); gtk_font_selection_dialog_set_font_name(dasher_fontselector,gtk_dasher_control_get_parameter_string(GTK_DASHER_CONTROL(pDasherWidget),SP_DASHER_FONT)); gtk_window_present(GTK_WINDOW(dasher_fontselector)); } // Edit box font selector -extern "C" gboolean edit_fontsel_hide(GtkWidget *widget, gpointer user_data) { +extern "C" gboolean edit_font_cancel_cb(GtkWidget *widget, gpointer user_data) { gtk_widget_hide(GTK_WIDGET(edit_fontselector)); return FALSE; } -extern "C" void get_edit_font_from_dialog(GtkWidget *one, GtkWidget *two) { +extern "C" void edit_font_ok_cb(GtkWidget *one, GtkWidget *two) { char *font_name; font_name = gtk_font_selection_dialog_get_font_name(edit_fontselector); if(font_name) { dasher_app_settings_set_string(g_pDasherAppSettings, APP_SP_EDIT_FONT, font_name); } - edit_fontsel_hide(NULL, NULL); + gtk_widget_hide(GTK_WIDGET(edit_fontselector)); } -extern "C" void set_edit_font(GtkWidget *widget, gpointer user_data) { - g_signal_connect(edit_fontselector->ok_button, "clicked", G_CALLBACK(get_edit_font_from_dialog), (gpointer) edit_fontselector); +extern "C" void edit_font_apply_cb(GtkWidget *one, GtkWidget *two) { + char *font_name; + font_name = gtk_font_selection_dialog_get_font_name(edit_fontselector); + if(font_name) { + dasher_app_settings_set_string(g_pDasherAppSettings, APP_SP_EDIT_FONT, font_name); + } +} - // FIXME - REIMPLEMENT - // GtkWidget *cancel_butto3 = glade_xml_get_widget(widgets,"cancel_butto3"); - // gtk_widget_hide(cancel_butto3); +extern "C" void set_edit_font(GtkWidget *widget, gpointer user_data) { gtk_font_selection_dialog_set_font_name(edit_fontselector, dasher_app_settings_get_string(g_pDasherAppSettings, APP_SP_EDIT_FONT)); gtk_window_present(GTK_WINDOW(edit_fontselector)); } diff --git a/Src/Gtk2/dasher.glade b/Src/Gtk2/dasher.glade index 6ea1575b..80834ede 100644 --- a/Src/Gtk2/dasher.glade +++ b/Src/Gtk2/dasher.glade @@ -455,112 +455,126 @@ - + True - True + 0.5 + 0.5 + 1 + 1 + 0 + 0 + 0 + 0 - + True True - True - create_dasher_control - 0 - 0 - Sun, 05 Mar 2006 19:33:03 GMT - - - - - - - - - - - - - - True - False - - - - - - True - False - 0 - + True True - GTK_POLICY_NEVER - GTK_POLICY_NEVER - GTK_SHADOW_NONE - GTK_CORNER_TOP_LEFT - - - - True - GTK_SHADOW_IN - - - - True - True - True - GDK_BUTTON_PRESS_MASK | GDK_KEY_PRESS_MASK - True - False - True - GTK_JUSTIFY_LEFT - GTK_WRAP_WORD - True - 0 - 0 - 0 - 0 - 0 - 0 - - - - - + True + create_dasher_control + 0 + 0 + Sun, 05 Mar 2006 19:33:03 GMT + + + + + + + + + + + - 0 - True - True + True + False - + + True False 0 - + + True + True + GTK_POLICY_AUTOMATIC + GTK_POLICY_AUTOMATIC + GTK_SHADOW_NONE + GTK_CORNER_TOP_LEFT + + + + True + GTK_SHADOW_IN + + + + True + True + True + GDK_BUTTON_PRESS_MASK | GDK_KEY_PRESS_MASK + True + False + True + GTK_JUSTIFY_LEFT + GTK_WRAP_WORD + True + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + + + 0 + True + True + - + + False + 0 + + + + + + + + + + + 0 + False + True + - 0 - False - True + True + True - - True - True - @@ -2717,37 +2731,44 @@ You must have gconf-editor installed and available in your path in order to acce False GDK_WINDOW_TYPE_HINT_DIALOG GDK_GRAVITY_NORTH_WEST - + - + + True True True + gtk-cancel + True GTK_RELIEF_NORMAL True - + - + + True True True - gtk-cancel + gtk-apply True GTK_RELIEF_NORMAL True - + - + True True True + gtk-ok + True GTK_RELIEF_NORMAL True + @@ -2778,34 +2799,44 @@ You must have gconf-editor installed and available in your path in order to acce False GDK_WINDOW_TYPE_HINT_DIALOG GDK_GRAVITY_NORTH_WEST + - + + True True True + gtk-cancel + True GTK_RELIEF_NORMAL True - + - + True True True + gtk-apply + True GTK_RELIEF_NORMAL True + - + True True True + gtk-ok + True GTK_RELIEF_NORMAL True + diff --git a/Src/Gtk2/dasher_main.cpp b/Src/Gtk2/dasher_main.cpp index 40d3b51d..5fe036b5 100644 --- a/Src/Gtk2/dasher_main.cpp +++ b/Src/Gtk2/dasher_main.cpp @@ -274,9 +274,10 @@ void dasher_main_refresh_font(DasherMain *pSelf) { DasherMainPrivate *pPrivate = (DasherMainPrivate *)(pSelf->private_data); const gchar *szFontName = dasher_app_settings_get_string(pPrivate->pAppSettings, APP_SP_EDIT_FONT); - - if(!strcmp(szFontName, "")) { - gtk_widget_modify_font(pPrivate->pBufferView, pango_font_description_from_string(szFontName)); + PangoFontDescription *pFD = pango_font_description_from_string(szFontName); + + if(strcmp(szFontName, "")) { + gtk_widget_modify_font(pPrivate->pBufferView, pFD); } } @@ -519,7 +520,8 @@ void dasher_main_setup_window_style(DasherMain *pSelf, bool bTopMost) { GtkWidget *pOldParent = gtk_widget_get_parent(pPrivate->pDivider); gtk_widget_destroy(pPrivate->pDivider); - gtk_box_pack_start(GTK_BOX(pOldParent), pDividerNew, true, true, 0); + // gtk_box_pack_start(GTK_BOX(pOldParent), pDividerNew, true, true, 0); + gtk_container_add(GTK_CONTAINER(pOldParent), pDividerNew); gtk_widget_show(pDividerNew); pPrivate->pDivider = pDividerNew; -- 2.11.4.GIT