X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Fmathed%2Fmath_symbols.C;h=8d268a9a93ff8add142c9eb4420cd518f9186664;hb=8dccec5c46a1689fe3ea37144252e952771e1e1c;hp=72b103638db1b97b7bb5e1cb21270cd1425f2d7a;hpb=d8a6abd63afb7e88a014e2f7acf84069396d52ff;p=lyx.git diff --git a/src/mathed/math_symbols.C b/src/mathed/math_symbols.C index 72b103638d..8d268a9a93 100644 --- a/src/mathed/math_symbols.C +++ b/src/mathed/math_symbols.C @@ -39,14 +39,12 @@ using std::max; #include "math_panel.h" #include "math_parser.h" -extern void SmallUpdate(signed char); extern void BeforeChange(); extern void Update(signed char); -extern int UnlockInset(UpdatableInset*); +extern int UnlockInset(UpdatableInset *); extern short greek_kb_flag; -extern MiniBuffer *minibuffer; -extern BufferView *current_view; +extern BufferView * current_view; /* Bitmaps */ #include "greek.xbm" @@ -58,7 +56,7 @@ extern BufferView *current_view; #include "dots.xbm" /* Latex code for those bitmaps */ -static char const *latex_greek[] = { +static char const * latex_greek[] = { "Gamma", "Delta", "Theta", "Lambda", "Xi", "Pi", "Sigma", "Upsilon", "Phi", "Psi", "Omega", "alpha", "beta", "gamma", "delta", "epsilon", "varepsilon", "zeta", @@ -67,7 +65,7 @@ static char const *latex_greek[] = { "tau", "upsilon", "phi", "varphi", "chi", "psi", "omega", "" }; -static char const *latex_brel[] = { +static char const * latex_brel[] = { "leq", "geq", "equiv", "models", "prec", "succ", "sim", "perp", "preceq", "succeq", "simeq", "mid", @@ -79,7 +77,7 @@ static char const *latex_brel[] = { "vdash", "dashv", "bowtie", "" }; -static char const* latex_arrow[] = { +static char const * latex_arrow[] = { "downarrow", "leftarrow", "Downarrow", "Leftarrow", "hookleftarrow", "rightarrow", "uparrow", "Rightarrow", "Uparrow", "hookrightarrow", "updownarrow", "Leftrightarrow", "leftharpoonup", @@ -90,7 +88,7 @@ static char const* latex_arrow[] = { "nwarrow", "nearrow", "swarrow", "searrow", "", }; -char const* latex_varsz[] = { +char const * latex_varsz[] = { "sum", "int", "oint", "prod", "coprod", "bigsqcup", "bigotimes", "bigodot", "bigoplus", @@ -98,7 +96,7 @@ char const* latex_varsz[] = { "bigvee", "bigwedge", "" }; -static char const* latex_bop[] = { +static char const * latex_bop[] = { "pm", "cap", "diamond", "oplus", "mp", "cup", "bigtriangleup", "ominus", "times", "uplus", "bigtriangledown", "otimes", @@ -109,7 +107,7 @@ static char const* latex_bop[] = { "bullet", "wr", "ddagger", "" }; -static char const* latex_misc[] = { +static char const * latex_misc[] = { "nabla", "partial", "infty", "prime", "ell", "emptyset", "exists", "forall", "imath", "jmath", "Re", "Im", "aleph", "wp", "hbar", @@ -118,7 +116,7 @@ static char const* latex_misc[] = { "diamondsuit", "heartsuit", "clubsuit", "spadesuit", "" }; -static char const* latex_dots[] = { +static char const * latex_dots[] = { "ldots", "cdots", "vdots", "ddots" }; @@ -132,19 +130,20 @@ static signed char Latin2Greek[] = { 5, 2, -1, 6, -1, 7, -1, 10, 4, 9, -1 }; -extern char** mathed_get_pixmap_from_icon(int d); +extern char const ** mathed_get_pixmap_from_icon(int d); extern "C" void math_cb(FL_OBJECT*, long); -static char** pixmapFromBitmapData(char const *, int, int); -void math_insert_symbol(char const* s); +static char const ** pixmapFromBitmapData(char const *, int, int); +void math_insert_symbol(char const * s); Bool math_insert_greek(char const c); -BitmapMenu *BitmapMenu::active = 0; +BitmapMenu * BitmapMenu::active = 0; -BitmapMenu::BitmapMenu(int n, FL_OBJECT* bt, BitmapMenu* prevx): nb(n) { +BitmapMenu::BitmapMenu(int n, FL_OBJECT * bt, BitmapMenu * prevx): nb(n) +{ w = h = 0; form = 0; i = 0; - ww = 2*FL_abs(FL_BOUND_WIDTH); + ww = 2 * FL_abs(FL_BOUND_WIDTH); x = y = ww; y += 8; bitmap = new FL_OBJECTP[nb]; @@ -156,20 +155,26 @@ BitmapMenu::BitmapMenu(int n, FL_OBJECT* bt, BitmapMenu* prevx): nb(n) { prev->next = this; } -BitmapMenu::~BitmapMenu() { + +BitmapMenu::~BitmapMenu() +{ if (next) delete next; if (form->visible) Hide(); fl_free_form(form); delete[] bitmap; } -void BitmapMenu::Hide() { + +void BitmapMenu::Hide() +{ fl_hide_form(form); fl_set_button(button, 0); active = 0; } -void BitmapMenu::Show() { + +void BitmapMenu::Show() +{ if (active) active->Hide(); active = this; @@ -179,15 +184,15 @@ void BitmapMenu::Show() { fl_show_form(form, FL_PLACE_MOUSE, FL_NOBORDER, ""); } -FL_OBJECT* -BitmapMenu::AddBitmap(int id, int nx, int ny, int bw, int bh, unsigned char* data, Bool vert) +FL_OBJECT * +BitmapMenu::AddBitmap(int id, int nx, int ny, int bw, int bh, unsigned char const * data, Bool vert) { - if (i>= nb) + if (i >= nb) return 0; - int wx= bw+ww/2, wy= bh+ww/2; + int wx = bw+ww/2, wy = bh+ww/2; wx += (wx % nx); wy += (wy % ny); - FL_OBJECT *obj = fl_create_bmtable(1, x, y, wx, wy, ""); + FL_OBJECT * obj = fl_create_bmtable(1, x, y, wx, wy, ""); fl_set_object_callback(obj, math_cb, id); fl_set_object_lcol(obj, FL_BLUE); fl_set_object_boxtype(obj, FL_UP_BOX); @@ -238,16 +243,16 @@ int peek_event(FL_FORM * /*form*/, void *xev) if (BitmapMenu::active == 0) return 0; - if(((XEvent *)xev)->type == ButtonPress) + if(static_cast(xev)->type == ButtonPress) { BitmapMenu::active->Hide(); return 1; } - if(((XEvent *)xev)->type == KeyPress) + if(static_cast(xev)->type == KeyPress) { char c[5]; KeySym keysym; - XLookupString(&((XEvent *)xev)->xkey, &c[0], 5, &keysym, 0); + XLookupString(&static_cast(xev)->xkey, &c[0], 5, &keysym, 0); if (keysym == XK_Left) BitmapMenu::active->Prev(); else if (keysym == XK_Right) @@ -300,7 +305,7 @@ extern "C" void math_cb(FL_OBJECT* ob, long data) if (s) { if (current_view->available() && lyxrc->display_shortcuts) { - minibuffer->Set("Inserting symbol ", s); + current_view->owner()->getMiniBuffer()->Set("Inserting symbol ", s); } current_view->owner()->getLyXFunc()->Dispatch(LFUN_INSERT_MATH, s); } @@ -308,10 +313,10 @@ extern "C" void math_cb(FL_OBJECT* ob, long data) menu->Hide(); } -char** get_pixmap_from_symbol(char const *arg, int wx, int hx) +char const ** get_pixmap_from_symbol(char const * arg, int wx, int hx) { - char** data= 0; - latexkeys *l = in_word_set (arg, strlen(arg)); + char const ** data = 0; + latexkeys * l = in_word_set (arg, strlen(arg)); if (!l) return 0; @@ -337,10 +342,10 @@ char** get_pixmap_from_symbol(char const *arg, int wx, int hx) Bool math_insert_greek(char const c) { int i; - char const *s= 0; + char const * s= 0; - if ('A'<= c && c<= 'Z') { - if ((i= Latin2Greek[c - 'A'])>= 0) + if ('A' <= c && c <= 'Z') { + if ((i = Latin2Greek[c - 'A']) >= 0) s = latex_greek[i]; } if ('a'<= c && c<= 'z') { @@ -362,7 +367,7 @@ void math_insert_symbol(char const* s) { if (current_view->available()) { if (!current_view->buffer()->the_locking_inset) { - InsetFormula* new_inset = new InsetFormula(); + InsetFormula * new_inset = new InsetFormula(); BeforeChange(); current_view->buffer()->insertInset(new_inset); // Update(1);//BUG @@ -430,15 +435,15 @@ void create_symbol_menues(FD_panel * symb_form) } static -char** pixmapFromBitmapData(char const *s, int wx, int hx) +char const ** pixmapFromBitmapData(char const * s, int wx, int hx) { - int i, id; - char** data= 0; + int i; + char const ** data = 0; - id= -1; + int id = -1; - for (i= 0; i<6; i++) { - char const **latex_str = 0; + for (i = 0; i < 6; ++i) { + char const ** latex_str = 0; switch (i) { case 0: latex_str = latex_greek; break; case 1: latex_str = latex_bop; break; @@ -454,10 +459,10 @@ char** pixmapFromBitmapData(char const *s, int wx, int hx) break; } } - if (id>= 0) break; + if (id >= 0) break; } - if (i<6 && id>= 0) { - unsigned char *bdata = 0; + if (i < 6 && id >= 0) { + unsigned char const * bdata = 0; int w = 0, h = 0, dw = 0, dh = 0; lyxerr[Debug::MATHED] << "Imando " << i << ", " << id << endl; @@ -523,21 +528,21 @@ char** pixmapFromBitmapData(char const *s, int wx, int hx) } int ww = w/dw, hh = h/dh, x, y; - XImage *xima = XCreateImage(fl_display, 0, 1, XYBitmap, 0, - reinterpret_cast(bdata), w, h, 8, 0); + XImage * xima = XCreateImage(fl_display, 0, 1, XYBitmap, 0, + const_cast(reinterpret_cast(bdata)), w, h, 8, 0); xima->byte_order = LSBFirst; xima->bitmap_bit_order = LSBFirst; x = (id % dw)*ww; y = (id/dw)*hh; - if (ww>wx) ww = wx; - if (hh>hx) hh = hx; - XImage *sbima = XSubImage(xima, x, y, ww, hh); - XpmCreateDataFromImage(fl_display, &data, sbima, sbima, 0); + if (ww > wx) ww = wx; + if (hh > hx) hh = hx; + XImage * sbima = XSubImage(xima, x, y, ww, hh); + XpmCreateDataFromImage(fl_display, const_cast(&data), sbima, sbima, 0); // Dirty hack to get blue symbols quickly - char *sx = strstr(data[2], "FFFFFFFF"); + char * sx = strstr(data[2], "FFFFFFFF"); if (sx) { - for (int k= 0; k<8; k++) sx[k] = '0'; + for (int k = 0; k < 8; ++k) sx[k] = '0'; } // XDestroyImage(xima);