1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147
|
#ifndef __STAR_DICT_H__
#define __STAR_DICT_H__
#include <gtk/gtk.h>
#ifndef _WIN32
#include <bonobo/bonobo-object.h>
#endif
class AppCore;
class AppFrame;
#include "skin.h"
#include "lib.h"
#include "mainwin.h"
#ifdef _WIN32
#include "win32/clipboard.h"
#include "win32/winconf.h"
#include "win32/systray.h"
#else
#include "conf.h"
#include "docklet.h"
#endif
#include "floatwin.h"
#include "selection.h"
#include "prefsdlg.h"
#include "dictmanagedlg.h"
#include "readword.h"
extern AppFrame * gpAppFrame;
//notice!!! when you change these DEFAULT const value,remember that you'd better change data/stardict.schemas.in too!
const int MAX_MATCH_ITEM_PER_LIB=100;
const int MAX_FUZZY_MATCH_ITEM=100;
const int MAX_FLOAT_WINDOW_FUZZY_MATCH_ITEM=5;
const int LIST_WIN_ROW_NUM = 30; //how many words show in the list win.
const int MAX_FUZZY_DISTANCE= 3; // at most MAX_FUZZY_DISTANCE-1 differences allowed when find similar words
class AppCore
{
private:
AppFrame* poAppFrame;
PrefsDlg *prefs_dlg;
DictManageDlg *dict_manage_dlg;
// struct
struct Fuzzystruct {
char * pMatchWord;
int iMatchWordDistance;
};
int iMaxFuzzyDistance;
static int FuzzystructCompare(const void * s1, const void * s2);
static int MatchWordCompare(const void * s1, const void * s2);
static gboolean on_delete_event(GtkWidget * window, GdkEvent *event , AppCore *oAppCore);
static gboolean on_window_state_event(GtkWidget * window, GdkEventWindowState *event , AppCore *oAppCore);
static gboolean on_window_visibility_notify(GtkWidget * window, GdkEventVisibility *event , AppCore *oAppCore);
static gboolean vKeyPressReleaseCallback(GtkWidget * window, GdkEventKey *event , AppCore *oAppCore);
public:
glong *iCurrentIndex;
GtkWidget *window;
GtkTooltips *tooltips;
TopWin oTopWin;
MidWin oMidWin;
BottomWin oBottomWin;
Selection oSelection;
#ifdef _WIN32
Clipboard oClipboard;
#endif
FloatWin oFloatWin;
DockLet oDockLet;
Libs oLibs;
TreeDicts oTreeDicts;
AppCore(AppFrame* pAppFrame);
~AppCore();
void Create(gchar *queryword);
void ProcessGtkEvent();
void End();
void Query(const gchar *word);
gboolean SimpleLookupToFloat(const gchar* sWord,gboolean bShowIfNotFound);
gboolean SimpleLookupToTextWin(const gchar* sWord,glong* piIndex, gboolean piIndexValid = false, gboolean bTryMoreIfNotFound = false);
void LookupWithFuzzyToMainWin(const gchar* word);
void LookupWithFuzzyToFloatWin(const gchar * word);
void LookupWithRuleToMainWin(const gchar* word);
void ShowDataToTextWin(gchar ** ppWord, gchar ** ppWordData,const gchar * sOriginWord);
void ShowTreeDictDataToTextWin(glong offset, glong size, gint iTreeDict);
void ShowNotFoundToTextWin(const char* sWord,const char* sReason, TextWinQueryResult query_result);
void ShowDataToFloatWin(gchar ** ppWord, gchar ** ppWordData,const gchar * sOriginWord);
void ShowDatasToFloatWin(gchar *** pppWord, gchar *** pppWordData, const gchar ** ppOriginWord, gint count, const gchar * sOriginWord);
void ShowNotFoundToFloatWin(const char* sWord,const char* sReason, gboolean fuzzy);
void TopWinEnterWord(const gchar *text);
void TopWinWordChange(const gchar* sWord);
void ListWords(glong * iStartIndex);
void ListClick(const gchar *word);
void PopupPrefsDlg();
void PopupDictManageDlg();
};
class AppFrame
{
private:
public:
#ifndef _WIN32
AppConf oAppConf;
#endif
AppCore oAppCore;
AppSkin oAppSkin;
ReadWord oReadWord;
gboolean enable_sound_event;
#ifndef _WIN32
BonoboObject *stardict_app_server;
#endif
AppFrame();
~AppFrame();
void Init(gchar *queryword);
void ProcessGtkEvent();
void Quit();
};
#ifdef _WIN32
extern HINSTANCE stardictexe_hInstance;
extern gchar stardict_data_dir[256];
#endif
extern gint stardict_strcmp(const gchar *s1, const gchar *s2);
extern gboolean bContainRule(const char* sWord);
extern gboolean bIsPureEnglish(const gchar *str);
extern gchar* GetPureEnglishAlpha(gchar *str);
extern gchar* GetHeadWord(gchar *str);
extern gboolean stardict_on_enter_notify (GtkWidget * widget, GdkEventCrossing * event, gpointer data);
#endif
|