#endif
#include <algorithm>
+using std::max;
#include "lyx_main.h"
#include "buffer.h"
static char const* latex_arrow[] = {
"downarrow", "leftarrow", "Downarrow", "Leftarrow",
"hookleftarrow", "rightarrow", "uparrow", "Rightarrow", "Uparrow",
- "hookrightarrow","updownarrow", "Leftrightarrow", "leftharpoonup",
+ "hookrightarrow", "updownarrow", "Leftrightarrow", "leftharpoonup",
"rightharpoonup", "rightleftharpoons", "leftrightarrow", "Updownarrow",
"leftharpoondown", "rightharpoondown", "mapsto",
"Longleftarrow", "Longrightarrow", "Longleftrightarrow",
};
extern char** mathed_get_pixmap_from_icon(int d);
-static void math_cb(FL_OBJECT*, long);
+extern "C" void math_cb(FL_OBJECT*, long);
static char** pixmapFromBitmapData(char const *, int, int);
void math_insert_symbol(char const* s);
Bool math_insert_greek(char const c);
}
FL_OBJECT*
-BitmapMenu::AddBitmap(int id, int nx, int ny, int bw, int bh, char* data, Bool vert)
+BitmapMenu::AddBitmap(int id, int nx, int ny, int bw, int bh, unsigned char* 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, "");
return;
}
form = fl_bgn_form(FL_UP_BOX, w, h);
- for (i=0; i<nb; i++) {
+ for (i= 0; i<nb; i++) {
fl_add_object(form, bitmap[i]);
bitmap[i]->u_vdata = this;
}
fl_end_form();
- fl_register_raw_callback(form, KeyPressMask, peek_event);
+ fl_register_raw_callback(form, KeyPressMask, C_peek_event);
}
int BitmapMenu::GetIndex(FL_OBJECT* ob)
{
- if (active==this) {
+ if (active == this) {
int k = 0;
- for (i=0; i<nb; i++) {
- if (bitmap[i]==ob)
+ for (i= 0; i<nb; i++) {
+ if (bitmap[i] == ob)
return k+fl_get_bmtable(ob);
k += fl_get_bmtable_maxitems(bitmap[i]);
}
return -1;
}
-extern "C" {
int peek_event(FL_FORM * /*form*/, void *xev)
{
- if (BitmapMenu::active==0)
+ if (BitmapMenu::active == 0)
return 0;
if(((XEvent *)xev)->type == ButtonPress)
char c[5];
KeySym keysym;
XLookupString(&((XEvent *)xev)->xkey, &c[0], 5, &keysym, 0);
- if (keysym==XK_Left)
+ if (keysym == XK_Left)
BitmapMenu::active->Prev(); else
- if (keysym==XK_Right)
+ if (keysym == XK_Right)
BitmapMenu::active->Next();
else
BitmapMenu::active->Hide();
}
return 0;
}
+
+// This is just a wrapper.
+extern "C" int C_peek_event(FL_FORM *form, void *ptr) {
+ return peek_event(form, ptr);
}
-static void math_cb(FL_OBJECT* ob, long data)
+
+extern "C" void math_cb(FL_OBJECT* ob, long data)
{
BitmapMenu* menu = (BitmapMenu*)ob->u_vdata;
int i = menu->GetIndex(ob);
if (current_view->available() && lyxrc->display_shortcuts) {
minibuffer->Set("Inserting symbol ", s);
}
- current_view->getOwner()->getLyXFunc()->Dispatch(LFUN_INSERT_MATH, s);
+ current_view->owner()->getLyXFunc()->Dispatch(LFUN_INSERT_MATH, s);
}
if (menu)
menu->Hide();
char** get_pixmap_from_symbol(char const *arg, int wx, int hx)
{
- char** data=0;
+ char** data= 0;
latexkeys *l = in_word_set (arg, strlen(arg));
if (!l)
return 0;
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') {
- if ((i=latin2greek[c - 'a'])>=0)
+ if ('a'<= c && c<= 'z') {
+ if ((i= latin2greek[c - 'a'])>= 0)
s = latex_greek[i+11];
}
if (s) {
math_insert_symbol(s);
if (greek_kb_flag<2) {
greek_kb_flag = 0;
- UnlockInset(current_view->currentBuffer()->the_locking_inset);
+ UnlockInset(current_view->buffer()->the_locking_inset);
}
return True;
} else
void math_insert_symbol(char const* s)
{
if (current_view->available()) {
- if (!current_view->currentBuffer()->the_locking_inset) {
+ if (!current_view->buffer()->the_locking_inset) {
InsetFormula* new_inset = new InsetFormula();
BeforeChange();
- current_view->currentBuffer()->insertInset(new_inset);
+ current_view->buffer()->insertInset(new_inset);
// Update(1);//BUG
- new_inset->Edit(0,0);
+ new_inset->Edit(0, 0);
new_inset->InsertSymbol(s);
} else
- if (current_view->currentBuffer()->the_locking_inset->LyxCode()==Inset::MATH_CODE)
- ((InsetFormula*)current_view->currentBuffer()->the_locking_inset)->InsertSymbol(s);
+ if (current_view->buffer()->the_locking_inset->LyxCode() == Inset::MATH_CODE)
+ static_cast<InsetFormula*>(current_view->buffer()->the_locking_inset)->InsertSymbol(s);
else
lyxerr << "Math error: attempt to write on a wrong "
"class of inset." << endl;
}
}
-BitmapMenu* sym_menu=0;
+BitmapMenu * sym_menu= 0;
-void create_symbol_menues(FD_panel *symb_form)
+void create_symbol_menues(FD_panel * symb_form)
{
- FL_OBJECT* obj;
- BitmapMenu* menu;
+ FL_OBJECT * obj;
+ BitmapMenu * menu;
sym_menu = menu = new BitmapMenu(2, symb_form->greek);
obj = menu->AddBitmap(MM_GREEK, 6, 2, Greek_width, Greek_height,
char** pixmapFromBitmapData(char const *s, int wx, int hx)
{
int i, id;
- char** data=0;
+ char** data= 0;
- id=-1;
+ id= -1;
- for (i=0; i<6; i++) {
+ for (i= 0; i<6; i++) {
char const **latex_str = 0;
switch (i) {
case 0: latex_str = latex_greek; break;
}
for (int k = 0; latex_str[k][0]>' '; k++) {
- if (strcmp(latex_str[k], s)==0) {
+ if (strcmp(latex_str[k], s) == 0) {
id = k;
break;
}
}
- if (id>=0) break;
+ if (id>= 0) break;
}
- if (i<6 && id>=0) {
- char *bdata = 0;
+ if (i<6 && id>= 0) {
+ unsigned char *bdata = 0;
int w = 0, h = 0, dw = 0, dh = 0;
lyxerr[Debug::MATHED] << "Imando " << i << ", " << id << endl;
switch (i) {
case 0:
- if (id<=10) {
+ if (id<= 10) {
w = Greek_width;
h = Greek_height;
bdata = Greek_bits;
int ww = w/dw, hh = h/dh, x, y;
XImage *xima = XCreateImage(fl_display, 0, 1, XYBitmap, 0,
- bdata, w, h, 8, 0);
+ reinterpret_cast<char*>(bdata), w, h, 8, 0);
xima->byte_order = LSBFirst;
xima->bitmap_bit_order = LSBFirst;
x = (id % dw)*ww;
// Dirty hack to get blue symbols quickly
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);