compiler tweaks for ub10, titler popup fixes
authorGood Guy <good1.2guy@gmail.com>
Sat, 25 Feb 2017 16:08:00 +0000 (09:08 -0700)
committerGood Guy <good1.2guy@gmail.com>
Sat, 25 Feb 2017 16:08:00 +0000 (09:08 -0700)
cinelerra-5.1/guicast/bclistbox.C
cinelerra-5.1/guicast/bclistbox.h
cinelerra-5.1/guicast/bctextbox.C
cinelerra-5.1/guicast/bctextbox.h
cinelerra-5.1/plugins/titler/titler.C
cinelerra-5.1/plugins/titler/titler.h
cinelerra-5.1/plugins/titler/titlerwindow.C
cinelerra-5.1/plugins/titler/titlerwindow.h

index 76f8fde1eee13f042d592db2f3f2793977d4bda1..89df76ae038fd356fac85e826c6127e38c9d1cfd 100644 (file)
@@ -3922,8 +3922,6 @@ int BC_ListBox::reposition_window(int x, int y, int w, int h, int flush)
 
                if(!is_popup)
                {
-                       if(w != -1) popup_w = w;
-                       if(h != -1) popup_h = h;
                        if(xscrollbar)
                                xscrollbar->reposition_window(get_xscroll_x(),
                                        get_xscroll_y(),
@@ -3979,69 +3977,43 @@ int BC_ListBox::deactivate()
 
 int BC_ListBox::activate(int take_focus)
 {
-//printf("BC_ListBox::activate %d %p\n", __LINE__, this);
-       if(!active)
-       {
-               if(take_focus)
-               {
-                       top_level->active_subwindow = this;
-                       active = 1;
-               }
-
-               button_releases = 0;
-
-// Test for existence of GUI in case this was previously called without
-// take_focus & again with take_focus
-               if(is_popup && !gui)
-               {
-                       Window tempwin;
-                       int x, y;
-                       int new_x, new_y;
-                       y = get_y() + get_h();
-                       if(justify == LISTBOX_RIGHT)
-                       {
-                               x = get_x() - popup_w + get_w();
-                       }
-                       else
-                       {
-                               x = get_x();
-                       }
-
-
-                       XTranslateCoordinates(top_level->display,
-                               parent_window->win,
-                               top_level->rootwin,
-                               x,
-                               y,
-                               &new_x,
-                               &new_y,
-                               &tempwin);
-
-                       if(new_x < 0) new_x = 0;
-                       if(new_y + popup_h > top_level->get_root_h(0))
-                               new_y -= get_h() + popup_h;
-
-                       add_subwindow(gui = new BC_Popup(this,
-                               new_x,
-                               new_y,
-                               popup_w,
-                               popup_h,
-                               -1,
-                               0,
-                               0));
-// Avoid top going out of screen
-                       if(new_y < 0 )
-                               new_y = 2;
-//printf("BC_ListBox::activate %d this=%p %p\n", __LINE__, this, gui->win);
-                       draw_items(1);
-                       gui->show_window(1);
-               }
-//printf("BC_ListBox::activate %d %p\n", __LINE__, this);
-//sleep(1);
-       }
+       if( active ) return 0;
+       if( take_focus )
+               set_active_subwindow(this);
+       button_releases = 0;
+       if( !is_popup || gui ) return 0;
+       int wx = get_x(), wy = get_y() + get_h();
+       if( justify == LISTBOX_RIGHT ) wx += get_w() - popup_w;
+       Window xwin;
+       int abs_x, abs_y;
+       XTranslateCoordinates(top_level->display,
+               parent_window->win, top_level->rootwin,
+               wx, wy, &abs_x, &abs_y, &xwin);
+       if( x <= 0 ) x = 2;
+       if( y <= 0 ) y = 2;
+       return activate(abs_x, abs_y);
+}
+
+int BC_ListBox::activate(int x, int y, int w, int h)
+{
+       if( active || !is_popup || gui ) return 0;
+       if(w != -1) popup_w = w;
+       if(h != -1) popup_h = h;
+       active = 1;
+       if( y + popup_h > top_level->get_root_h(0) )
+               y -= get_h() + popup_h;
+       add_subwindow(gui = new BC_Popup(this,
+               x, y, popup_w, popup_h, -1, 0, 0));
+       draw_items(1);
+       gui->show_window(1);
        return 0;
 }
 
+int BC_ListBox::is_active()
+{
+       return active;
+}
+
 int BC_ListBox::keypress_event()
 {
        if(!active) return 0;
index 7a61af7120ff551de5fc6fd724421339f66b365d..e815a7f7edd1935616c4f4d5efb5096116f480b0 100644 (file)
@@ -189,13 +189,15 @@ public:
        virtual int drag_motion_event();
        virtual int drag_stop_event();
 
-       int deactivate();
 // After popping up a menu call this to interrupt the selection process
        void deactivate_selection();
 
 // take_focus - used by the suggestion box to keep it from taking focus from the
 // textbox
        int activate(int take_focus = 1);
+       int activate(int x, int y, int w=-1, int h=-1);
+       int deactivate();
+       int is_active();
 
        int translation_event();
        int repeat_event(int64_t duration);
index e8cb09ced1fc35afb853cea90382e99766229cd8..cbd74e0623c45760221fe5dec44075d23d81ce04 100644 (file)
@@ -777,7 +777,7 @@ int BC_TextBox::cursor_leave_event()
                draw_border();
                flash(1);
        }
-       if( !suggestions_popup &&
+       if( !suggestions_popup && !get_buttonpress() &&
            !(top_level->get_resources()->textbox_focus_policy & CLICK_DEACTIVATE) )
                deactivate();
        return 0;
@@ -2166,19 +2166,6 @@ void BC_ScrollTextBox::create_objects()
        set_text_row(0);
 }
 
-int BC_ScrollTextBox::handle_event() { return 1; }
-int BC_ScrollTextBox::button_press_event() { return text->BC_TextBox::button_press_event(); }
-int BC_ScrollTextBox::button_release_event() { return text->BC_TextBox::button_release_event(); }
-int BC_ScrollTextBox::get_buttonpress() { return text->BC_TextBox::get_buttonpress(); };
-int BC_ScrollTextBox::get_x() { return x; }
-int BC_ScrollTextBox::get_y() { return y; }
-int BC_ScrollTextBox::get_w() { return w; }
-int BC_ScrollTextBox::get_h() { return text->get_h(); }
-int BC_ScrollTextBox::get_rows() { return rows; }
-
-const char* BC_ScrollTextBox::get_text() { return text->get_text(); }
-const wchar_t* BC_ScrollTextBox::get_wtext() { return text->get_wtext(); }
-
 void BC_ScrollTextBox::set_text(char *text, int isz)
 {
        this->text->set_text(text, isz);
@@ -2234,27 +2221,36 @@ void BC_ScrollTextBox::reposition_window(int x, int y, int w, int rows)
                0);
 }
 
-void BC_ScrollTextBox::set_selection(int char1, int char2, int ibeam)
+int BC_ScrollTextBox::button_press_event()
 {
-       this->text->set_selection(char1, char2, ibeam);
+       return text->BC_TextBox::button_press_event();
 }
+int BC_ScrollTextBox::button_release_event()
+{
+       return text->BC_TextBox::button_release_event();
+}
+
+int BC_ScrollTextBox::get_h() { return text->get_h(); }
+const char *BC_ScrollTextBox::get_text() { return text->get_text(); }
+const wchar_t *BC_ScrollTextBox::get_wtext() { return text->get_wtext(); }
 
+int BC_ScrollTextBox::get_buttonpress()
+{
+       return text->BC_TextBox::get_buttonpress();
+}
 void BC_ScrollTextBox::wset_selection(int char1, int char2, int ibeam)
 {
-       this->text->wset_selection(char1, char2, ibeam);
+       text->wset_selection(char1, char2, ibeam);
+}
+void BC_ScrollTextBox::set_selection(int char1, int char2, int ibeam)
+{
+       text->set_selection(char1, char2, ibeam);
 }
-
 int BC_ScrollTextBox::get_ibeam_letter()
 {
-       return this->text->get_ibeam_letter();
+       return text->get_ibeam_letter();
 }
 
-
-
-
-
-
-
 BC_ScrollTextBoxText::BC_ScrollTextBoxText(BC_ScrollTextBox *gui, const char *text)
  : BC_TextBox(gui->x, gui->y,
        gui->w - get_resources()->vscroll_data[SCROLL_HANDLE_UP]->get_w(),
@@ -2325,13 +2321,6 @@ int BC_ScrollTextBoxYScroll::handle_event()
 
 
 
-
-
-
-
-
-
-
 BC_PopupTextBoxText::BC_PopupTextBoxText(BC_PopupTextBox *popup, int x, int y, const char *text)
  : BC_TextBox(x, y, popup->text_w, 1, text, BCTEXTLEN)
 {
index bb79e6899eef69910efa6e9e452e7bf1d6b3fd50..a4d94e68958a32814b7c9300712e1ebdf0e9ef14 100644 (file)
@@ -250,27 +250,30 @@ public:
                 const wchar_t *default_wtext, int default_size=BCTEXTLEN);
        virtual ~BC_ScrollTextBox();
        void create_objects();
-       virtual int handle_event();
+
+       virtual int handle_event() { return 1; }
        virtual int button_press_event();
        virtual int button_release_event();
-       int get_buttonpress();
 
-       const char* get_text();
-       const wchar_t* get_wtext();
        void set_text(char *text, int isz);
        int set_text_row(int n);
        void update(const char *text);
        void update(const wchar_t *wtext);
-       void set_selection(int char1, int char2, int ibeam);
-       void wset_selection(int char1, int char2, int ibeam);
        void reposition_window(int x, int y, int w, int rows);
+// accessors
+       int get_x() { return x; }
+       int get_y() { return y; }
+       int get_w() { return w; }
+// Visible rows for resizing
+       int get_rows() { return rows; }
 
-       int get_x();
-       int get_y();
-       int get_w();
+// forward functions
        int get_h();
-// Visible rows for resizing
-       int get_rows();
+       const char *get_text();
+       const wchar_t *get_wtext();
+       int get_buttonpress();
+       void wset_selection(int char1, int char2, int ibeam);
+       void set_selection(int char1, int char2, int ibeam);
        int get_ibeam_letter();
 };
 
index bdde6b47cd32a651dac4c75eac90ac48d7436358..2a11a98e90374ddbdbdf2c814afb5e42c9c30da6 100644 (file)
@@ -1001,51 +1001,51 @@ LoadPackage* TitleTranslate::new_package()
 }
 
 TitleCurNudge::TitleCurNudge(TitleParser *parser, TitleMain *plugin)
- : TitleStack(parser, 0)
+ : TitleStack<int>(parser, 0)
 {
 }
 TitleCurColor::TitleCurColor(TitleParser *parser, TitleMain *plugin)
- : TitleStack(parser, plugin->config.color)
+ : TitleStack<int>(parser, plugin->config.color)
 {
 }
 TitleCurAlpha::TitleCurAlpha(TitleParser *parser, TitleMain *plugin)
- : TitleStack(parser, plugin->config.alpha)
+ : TitleStack<int>(parser, plugin->config.alpha)
 {
 }
 TitleCurSize::TitleCurSize(TitleParser *parser, TitleMain *plugin)
- : TitleStack(parser, plugin->config.size)
+ : TitleStack<float>(parser, plugin->config.size)
 {
 }
 TitleCurBold::TitleCurBold(TitleParser *parser, TitleMain *plugin)
- : TitleStack(parser, (plugin->config.style & BC_FONT_BOLD) ? 1 : 0)
+ : TitleStack<int>(parser, (plugin->config.style & BC_FONT_BOLD) ? 1 : 0)
 {
 }
 TitleCurItalic::TitleCurItalic(TitleParser *parser, TitleMain *plugin)
- : TitleStack(parser, (plugin->config.style & BC_FONT_ITALIC) ? 1 : 0)
+ : TitleStack<int>(parser, (plugin->config.style & BC_FONT_ITALIC) ? 1 : 0)
 {
 }
 TitleCurFont::TitleCurFont(TitleParser *parser, TitleMain *plugin)
- : TitleStack(parser, plugin->config_font())
+ : TitleStack<BC_FontEntry*>(parser, plugin->config_font())
 {
 }
 TitleCurCaps::TitleCurCaps(TitleParser *parser, TitleMain *plugin)
- : TitleStack(parser, 0)
+ : TitleStack<int>(parser, 0)
 {
 }
 TitleCurUnder::TitleCurUnder(TitleParser *parser, TitleMain *plugin)
- : TitleStack(parser, 0)
+ : TitleStack<int>(parser, 0)
 {
 }
 TitleCurBlink::TitleCurBlink(TitleParser *parser, TitleMain *plugin)
- : TitleStack(parser, 0)
+ : TitleStack<float>(parser, 0)
 {
 }
 TitleCurFixed::TitleCurFixed(TitleParser *parser, TitleMain *plugin)
- : TitleStack(parser, 0)
+ : TitleStack<int>(parser, 0)
 {
 }
 TitleCurSuper::TitleCurSuper(TitleParser *parser, TitleMain *plugin)
- : TitleStack(parser, 0)
+ : TitleStack<int>(parser, 0)
 {
 }
 
@@ -1633,7 +1633,7 @@ int TitleCurSize::set(const char *txt)
        }
        if( *txt || size <= 0 || size > 2048 ) return 1;
        int style = parser->cur_font.style();
-       if( parser->cur_font.set(0,style) ) return 1;
+       if( !parser->cur_font.set(0,style) ) return 1;
        push(size);
        return 0;
 }
@@ -1654,7 +1654,7 @@ int TitleCurBold::set(const char *txt)
        int style = parser->cur_font.style();
        if( bold ) style |= BC_FONT_BOLD;
        else style &= ~BC_FONT_BOLD;
-       if( parser->cur_font.set(0,style) ) return 1;
+       if( !parser->cur_font.set(0,style) ) return 1;
        push(bold);
        return 0;
 }
@@ -1674,7 +1674,7 @@ int TitleCurItalic::set(const char *txt)
        int style = parser->cur_font.style();
        if( italic ) style |= BC_FONT_ITALIC;
        else style &= ~BC_FONT_ITALIC;
-       if( parser->cur_font.set(0,style) ) return 1;
+       if( !parser->cur_font.set(0,style) ) return 1;
        push(italic);
        return 0;
 }
@@ -1700,16 +1700,16 @@ BC_FontEntry* TitleCurFont::get(const char *txt, int style)
        else if( !*txt ) txt = parser->plugin->config.font;
        return parser->plugin->get_font(txt, style);
 }
-int TitleCurFont::set(const char *txt, int style)
+BC_FontEntry *TitleCurFont::set(const char *txt, int style)
 {
        BC_FontEntry *font = get(txt, style);
-       if( !font || parser->plugin->load_font(font) ) return 1;
+       if( !font || parser->plugin->load_font(font) ) return 0;
        if( !txt ) (BC_FontEntry*&)*this = font;
-       return 0;
+       return font;
 }
 int TitleCurFont::set(const char *txt)
 {
-       BC_FontEntry *font = get(txt, style());
+       BC_FontEntry *font = set(txt, style());
        if( !font ) return 1;
        push(font);
        return 0;
@@ -1788,6 +1788,7 @@ int TitleParser::set_attributes(int ret)
        return 1;
 }
 
+
 void TitleMain::load_glyphs()
 {
 // Build table of all glyphs needed
@@ -2302,11 +2303,11 @@ void TitleMain::draw_overlay()
 const char* TitleMain::motion_to_text(int motion)
 {
        switch( motion ) {
-       case NO_MOTION: return _("No motion"); break;
-       case BOTTOM_TO_TOP: return _("Bottom to top"); break;
-       case TOP_TO_BOTTOM: return _("Top to bottom"); break;
-       case RIGHT_TO_LEFT: return _("Right to left"); break;
-       case LEFT_TO_RIGHT: return _("Left to right"); break;
+       case NO_MOTION:     return _("No motion");
+       case BOTTOM_TO_TOP: return _("Bottom to top");
+       case TOP_TO_BOTTOM: return _("Top to bottom");
+       case RIGHT_TO_LEFT: return _("Right to left");
+       case LEFT_TO_RIGHT: return _("Left to right");
        }
        return _("Unknown");
 }
@@ -2634,3 +2635,26 @@ void TitleMain::read_data(KeyFrame *keyframe)
        }
 }
 
+void TitleMain::insert_text(const char *txt, int pos)
+{
+       int ilen = strlen(txt);
+       wchar_t *wtext = config.wtext;
+       int wsize = sizeof(config.wtext)-1;
+       int wlen = config.wlen;
+       if( pos < 0 ) pos = 0;
+       if( pos > wlen ) pos = wlen;
+
+       for( int i=wlen-1, j=wlen+ilen-1; i>=pos; --i,--j ) {
+               if( j >= wsize ) continue;
+               wtext[j] = wtext[i];
+       }
+       for( int i=pos, j=0; j<ilen; ++i,++j ) {
+               if( i >= wsize ) break;
+               wtext[i] = txt[j];
+       }
+
+       if( (wlen+=ilen) > wsize ) wlen = wsize;
+       wtext[wlen] = 0;
+       config.wlen = wlen;
+}
+
index d24dbbbdfd8c11f4082fd968b46780017513646b..2b957a2c511358ac53f2e236f3428595c71cde73 100644 (file)
@@ -482,8 +482,8 @@ public:
 class TitleCurFont : public TitleStack<BC_FontEntry*>
 {
 public:
-       BC_FontEntryget(const char *txt, int style);
-       int set(const char *txt, int style);
+       BC_FontEntry *get(const char *txt, int style);
+       BC_FontEntry *set(const char *txt, int style);
        int style();
        virtual int set(const char *txt=0);
        virtual int unset(const char *txt);
@@ -566,6 +566,7 @@ public:
        void update_gui();
        void save_data(KeyFrame *keyframe);
        void read_data(KeyFrame *keyframe);
+       void insert_text(const char *txt, int pos);
 
        void build_previews(TitleWindow *gui);
        void reset_render();
index ef89eb8ddd28a93a1d2ff23af2270109bfaa1c70..bdf11eda3852bb9653106db0437bf0d24c96ab0a 100644 (file)
@@ -56,49 +56,68 @@ TitleWindow::TitleWindow(TitleMain *client)
 {
 //printf("TitleWindow::TitleWindow %d %d %d\n", __LINE__, client->config.window_w, client->config.window_h);
        this->client = client;
+
+       font_title = 0;
+       font = 0;
        font_tumbler = 0;
-       justify_title = 0;
+       x_title = 0; title_x = 0;
+       y_title = 0; title_y = 0;
+       w_title = 0; title_w = 0;
+       h_title = 0; title_h = 0;
+       dropshadow_title = 0; dropshadow = 0;
+       outline_title = 0;    outline = 0;
+       stroker_title = 0;    stroker = 0;
        style_title = 0;
+       italic = 0;
+       bold = 0;
+       drag = 0;
+       cur_popup = 0;
+       fonts_popup = 0;
+
+       color_x = color_y = 0;
+       outline_color_x = outline_color_y = 0;
+       drag_dx = drag_dy = dragging = 0;
+       cur_ibeam = -1;
+
        size_title = 0;
+       size = 0;
+       size_tumbler = 0;
+       pitch_title = 0;
+       pitch = 0;
+       encoding_title = 0;
+       encoding = 0;
+       color_button = 0;
+       color_thread = 0;
+       outline_color_button = 0;
+       outline_color_thread = 0;
        motion_title = 0;
-       speed_title = 0;
-       font_title = 0;
-       fadeout_title = 0;
+       motion = 0;
+       line_pitch = 0;
+       loop = 0;
        fadein_title = 0;
-       dropshadow_title = 0;
+       fade_in = 0;
+       fadeout_title = 0;
+       fade_out = 0;
        text_title = 0;
-
-       font = 0;  size = 0;
-       title_x = 0; title_y = 0;
-       x_title = 0; y_title = 0;
-       title_w = 0; title_h = 0;
-       w_title = 0; h_title = 0;
-       top = 0;  mid = 0;    bottom = 0;
-       left = 0; center = 0; right = 0;
-       loop = 0; motion = 0; speed = 0;
-       dropshadow = 0;
        text = 0;
+       justify_title = 0;
+       left = 0;  center = 0;  right = 0;
+       top = 0;   mid = 0;     bottom = 0;
+       speed_title = 0;
+       speed = 0;
        timecode = 0;
-       bold = 0;
-       italic = 0;
-       dragging = 0;
-       fade_in = 0;
-       fade_out = 0;
-       color_button = 0;
-       color_x = color_y = 0;
-       color_thread = 0;
+       timecode_format = 0;
        background = 0;
        background_path = 0;
-       cur_ibeam = -1;
+       loop_playback = 0;
 }
 
 TitleWindow::~TitleWindow()
 {
        ungrab(client->server->mwindow->cwindow->gui);
-       for( int j=0; j<fonts.size(); ++j ) {
-// delete the pixmaps but not the vframes since they're static
-               delete fonts.get(j)->get_icon();
-       }
+       delete fonts_popup;
+       for( int i=0; i<fonts.size(); ++i )
+               delete fonts[i]->get_icon();
 
        sizes.remove_all_objects();
        delete timecode_format;
@@ -357,9 +376,10 @@ void TitleWindow::create_objects()
 
        add_tool(cur_popup = new TitleCurPopup(client, this));
        cur_popup->create_objects();
+       add_tool(fonts_popup = new TitleFontsPopup(client, this));
 
-       update();
        show_window(1);
+       update();
 }
 
 int TitleWindow::resize_event(int w, int h)
@@ -590,7 +610,17 @@ void  TitleWindow::next_font()
        client->send_configure_change();
 }
 
-
+int TitleWindow::insert_ibeam(const char *txt, int adv)
+{
+       int ibeam = cur_ibeam;
+       client->insert_text(txt, ibeam);
+       if( (ibeam += adv) >= client->config.wlen)
+               ibeam = client->config.wlen;
+       text->wset_selection(-1, -1, ibeam);
+       text->update(client->config.wtext);
+       client->send_configure_change();
+       return 1;
+}
 
 void TitleWindow::update_color()
 {
@@ -965,6 +995,7 @@ int TitleText::button_press_event()
 
 int TitleText::handle_event()
 {
+       window->fonts_popup->deactivate();
        int len =  sizeof(client->config.wtext) / sizeof(wchar_t);
        wcsncpy(client->config.wtext, get_wtext(), len);
        client->config.wtext[len-1] = 0;
@@ -1280,61 +1311,63 @@ TitleCurPopup::TitleCurPopup(TitleMain *client, TitleWindow *window)
 }
 int TitleCurPopup::handle_event()
 {
-printf("cur popup\n");
        return 1;
 }
 void TitleCurPopup::create_objects()
 {
        TitleCurItem *cur_item;
        TitleCurSubMenu *sub_menu;
-       add_item(cur_item = new TitleCurItem(this, "nudge"));
+       add_item(cur_item = new TitleCurItem(this, _("nudge")));
+       cur_item->add_submenu(sub_menu = new TitleCurSubMenu(cur_item));
+       sub_menu->add_submenuitem(new TitleCurSubMenuItem(sub_menu,_("nudge")));
+       sub_menu->add_submenuitem(new TitleCurSubMenuItem(sub_menu,_("/nudge")));
+       add_item(cur_item = new TitleCurItem(this, _("color")));
        cur_item->add_submenu(sub_menu = new TitleCurSubMenu(cur_item));
-       sub_menu->add_submenuitem(new TitleCurSubMenuItem(sub_menu,"nudge"));
-       sub_menu->add_submenuitem(new TitleCurSubMenuItem(sub_menu,"/nudge"));
-       add_item(cur_item = new TitleCurItem(this, "color"));
+       sub_menu->add_submenuitem(new TitleCurSubMenuItem(sub_menu,_("color")));
+       sub_menu->add_submenuitem(new TitleCurSubMenuItem(sub_menu,_("/color")));
+       add_item(cur_item = new TitleCurItem(this, _("alpha")));
        cur_item->add_submenu(sub_menu = new TitleCurSubMenu(cur_item));
-       sub_menu->add_submenuitem(new TitleCurSubMenuItem(sub_menu,"color"));
-       sub_menu->add_submenuitem(new TitleCurSubMenuItem(sub_menu,"/color"));
-       add_item(cur_item = new TitleCurItem(this, "alpha"));
+       sub_menu->add_submenuitem(new TitleCurSubMenuItem(sub_menu,_("alpha")));
+       sub_menu->add_submenuitem(new TitleCurSubMenuItem(sub_menu,_("/alpha")));
+       add_item(cur_item = new TitleCurItem(this, _("font")));
        cur_item->add_submenu(sub_menu = new TitleCurSubMenu(cur_item));
-       sub_menu->add_submenuitem(new TitleCurSubMenuItem(sub_menu,"alpha"));
-       sub_menu->add_submenuitem(new TitleCurSubMenuItem(sub_menu,"/alpha"));
-       add_item(cur_item = new TitleCurItem(this, "font"));
+       sub_menu->add_submenuitem(new TitleCurSubMenuItem(sub_menu,_("font")));
+       sub_menu->add_submenuitem(new TitleCurSubMenuItem(sub_menu,_("/font")));
+       add_item(cur_item = new TitleCurItem(this, _("size")));
        cur_item->add_submenu(sub_menu = new TitleCurSubMenu(cur_item));
-       sub_menu->add_submenuitem(new TitleCurSubMenuItem(sub_menu,"font"));
-       sub_menu->add_submenuitem(new TitleCurSubMenuItem(sub_menu,"/font"));
-       add_item(cur_item = new TitleCurItem(this, "size"));
+       sub_menu->add_submenuitem(new TitleCurSubMenuItem(sub_menu,_("size")));
+       sub_menu->add_submenuitem(new TitleCurSubMenuItem(sub_menu,_("/size")));
+       add_item(cur_item = new TitleCurItem(this, _("bold")));
        cur_item->add_submenu(sub_menu = new TitleCurSubMenu(cur_item));
-       sub_menu->add_submenuitem(new TitleCurSubMenuItem(sub_menu,"size"));
-       sub_menu->add_submenuitem(new TitleCurSubMenuItem(sub_menu,"/size"));
-       add_item(cur_item = new TitleCurItem(this, "bold"));
+       sub_menu->add_submenuitem(new TitleCurSubMenuItem(sub_menu,_("bold")));
+       sub_menu->add_submenuitem(new TitleCurSubMenuItem(sub_menu,_("/bold")));
+       add_item(cur_item = new TitleCurItem(this, _("italic")));
        cur_item->add_submenu(sub_menu = new TitleCurSubMenu(cur_item));
-       sub_menu->add_submenuitem(new TitleCurSubMenuItem(sub_menu,"bold"));
-       sub_menu->add_submenuitem(new TitleCurSubMenuItem(sub_menu,"/bold"));
-       add_item(cur_item = new TitleCurItem(this, "italic"));
+       sub_menu->add_submenuitem(new TitleCurSubMenuItem(sub_menu,_("italic")));
+       sub_menu->add_submenuitem(new TitleCurSubMenuItem(sub_menu,_("/italic")));
+       add_item(cur_item = new TitleCurItem(this, _("caps")));
        cur_item->add_submenu(sub_menu = new TitleCurSubMenu(cur_item));
-       sub_menu->add_submenuitem(new TitleCurSubMenuItem(sub_menu,"italic"));
-       sub_menu->add_submenuitem(new TitleCurSubMenuItem(sub_menu,"/italic"));
-       add_item(cur_item = new TitleCurItem(this, "caps"));
+       sub_menu->add_submenuitem(new TitleCurSubMenuItem(sub_menu,_("caps")));
+       sub_menu->add_submenuitem(new TitleCurSubMenuItem(sub_menu,_("/caps")));
+       add_item(cur_item = new TitleCurItem(this, _("ul")));
        cur_item->add_submenu(sub_menu = new TitleCurSubMenu(cur_item));
-       sub_menu->add_submenuitem(new TitleCurSubMenuItem(sub_menu,"caps"));
-       sub_menu->add_submenuitem(new TitleCurSubMenuItem(sub_menu,"/caps"));
-       add_item(cur_item = new TitleCurItem(this, "ul"));
+       sub_menu->add_submenuitem(new TitleCurSubMenuItem(sub_menu,_("ul")));
+       sub_menu->add_submenuitem(new TitleCurSubMenuItem(sub_menu,_("/ul")));
+       add_item(cur_item = new TitleCurItem(this, _("blink")));
        cur_item->add_submenu(sub_menu = new TitleCurSubMenu(cur_item));
-       sub_menu->add_submenuitem(new TitleCurSubMenuItem(sub_menu,"ul"));
-       sub_menu->add_submenuitem(new TitleCurSubMenuItem(sub_menu,"/ul"));
-       add_item(cur_item = new TitleCurItem(this, "blink"));
+       sub_menu->add_submenuitem(new TitleCurSubMenuItem(sub_menu,_("blink")));
+       sub_menu->add_submenuitem(new TitleCurSubMenuItem(sub_menu,_("/blink")));
+       add_item(cur_item = new TitleCurItem(this, _("fixed")));
        cur_item->add_submenu(sub_menu = new TitleCurSubMenu(cur_item));
-       sub_menu->add_submenuitem(new TitleCurSubMenuItem(sub_menu,"blink"));
-       sub_menu->add_submenuitem(new TitleCurSubMenuItem(sub_menu,"/blink"));
-       add_item(cur_item = new TitleCurItem(this, "fixed"));
+       sub_menu->add_submenuitem(new TitleCurSubMenuItem(sub_menu,_("fixed")));
+       sub_menu->add_submenuitem(new TitleCurSubMenuItem(sub_menu,_("/fixed")));
+       add_item(cur_item = new TitleCurItem(this, _("sup")));
        cur_item->add_submenu(sub_menu = new TitleCurSubMenu(cur_item));
-       sub_menu->add_submenuitem(new TitleCurSubMenuItem(sub_menu,"fixed"));
-       sub_menu->add_submenuitem(new TitleCurSubMenuItem(sub_menu,"/fixed"));
-       add_item(cur_item = new TitleCurItem(this, "sup"));
+       sub_menu->add_submenuitem(new TitleCurSubMenuItem(sub_menu,_("sup")));
+       sub_menu->add_submenuitem(new TitleCurSubMenuItem(sub_menu,_("/sup")));
+       add_item(cur_item = new TitleCurItem(this, _("png")));
        cur_item->add_submenu(sub_menu = new TitleCurSubMenu(cur_item));
-       sub_menu->add_submenuitem(new TitleCurSubMenuItem(sub_menu,"sup"));
-       sub_menu->add_submenuitem(new TitleCurSubMenuItem(sub_menu,"/sup"));
+       sub_menu->add_submenuitem(new TitleCurSubMenuItem(sub_menu,_("png")));
 }
 
 TitleCurItem::TitleCurItem(TitleCurPopup *popup, const char *text)
@@ -1365,34 +1398,47 @@ TitleCurSubMenuItem::~TitleCurSubMenuItem()
 }
 int TitleCurSubMenuItem::handle_event()
 {
-       char id[BCSTRLEN];
-       sprintf(id, "<%s>",get_text());
-       int ilen = strlen(id);
-       TitleMain *client = submenu->cur_item->popup->client;
-       TitleWindow *window = submenu->cur_item->popup->window;
-
-       wchar_t *wtext = client->config.wtext;
-       int wsize = sizeof(client->config.wtext)-1;
-       int wlen = client->config.wlen;
-       int ibeam_letter = window->cur_ibeam;
-       if( ibeam_letter < 0 ) ibeam_letter = 0;
-       if( ibeam_letter > wlen ) ibeam_letter = wlen;
-
-       for( int i=wlen-1, j=wlen+ilen-1; i>=ibeam_letter; --i,--j ) {
-               if( j >= wsize ) continue;
-               wtext[j] = wtext[i];
-       }
-       for( int i=ibeam_letter, j=0; j<ilen; ++i,++j ) {
-               if( i >= wsize ) break;
-               wtext[i] = id[j];
+       TitleCurPopup *popup = submenu->cur_item->popup;
+       TitleWindow *window = popup->window;
+       const char *item_text = get_text();
+       if( !strcmp(item_text, _("font")) ) {
+               int w = 300, h = 200;
+               int x = window->get_abs_cursor_x(0) - w + 10;
+               int y = window->get_abs_cursor_y(0) - 20;
+               if( x < 2 ) x = 2;
+               if( y < 2 ) y = 2;
+               window->fonts_popup->activate(x, y, w,h);
+               return 1;
        }
+       char txt[BCSTRLEN];
+       sprintf(txt, "<%s>", item_text);
+       int adv = strlen(txt);
+       if( adv > 1 && (txt[1] != '/' && strcmp(txt,_("font"))) ) --adv;
+       return window->insert_ibeam(txt,adv);
+}
 
-       if( (wlen+=ilen) > wsize ) wlen = wsize;
-       wtext[wlen] = 0;
-       window->text->update(wtext);
-       client->config.wlen = wlen;
-       client->send_configure_change();
-       return 1;
+TitleFontsPopup::TitleFontsPopup(TitleMain *client, TitleWindow *window)
+ : BC_ListBox(-1, -1, 1, 1, LISTBOX_ICON_LIST,
+       &window->fonts, 0, 0, 1, 0, 1)
+{
+       this->client = client;
+       this->window = window;
+       set_use_button(0);
+}
+TitleFontsPopup::~TitleFontsPopup()
+{
 }
 
+int TitleFontsPopup::handle_event()
+{
+       deactivate();
+       BC_ListBoxItem *item = get_selection(0, 0);
+       if( !item ) return 1;
+       const char *item_text = item->get_text();
+       char txt[BCTEXTLEN];
+       sprintf(txt, "<font %s>",item_text);
+       int adv = strlen(txt);
+       int ret = window->insert_ibeam(txt, adv);
+       return ret;
+}
 
index cc3734b4caf54df4b91b577bb9a543a483a87a30..dd9e9c51ac863c23743d22da2a010b99d0553529 100644 (file)
@@ -76,6 +76,7 @@ class TitleCurPopup;
 class TitleCurItem;
 class TitleCurSubMenu;
 class TitleCurSubMenuItem;
+class TitleFontsPopup;
 
 class TitleWindow : public PluginClientWindow
 {
@@ -91,6 +92,7 @@ public:
        void update();
        void previous_font();
        void next_font();
+       int insert_ibeam(const char *txt, int adv);
 
        TitleMain *client;
 
@@ -116,10 +118,12 @@ public:
        TitleBold *bold;
        TitleDrag *drag;
        TitleCurPopup *cur_popup;
+       TitleFontsPopup *fonts_popup;
 
        int color_x, color_y;
        int outline_color_x, outline_color_y;
        int drag_dx, drag_dy, dragging;
+       int cur_ibeam;
 
        BC_Title *size_title;
        TitleSize *size;
@@ -162,7 +166,6 @@ public:
        ArrayList<BC_ListBoxItem*> encodings;
        ArrayList<BC_ListBoxItem*> paths;
        ArrayList<BC_ListBoxItem*> fonts;
-       int cur_ibeam;
 };
 
 
@@ -530,9 +533,20 @@ class TitleCurSubMenuItem : public BC_MenuItem
 public:
         TitleCurSubMenuItem(TitleCurSubMenu *submenu, const char *text);
         ~TitleCurSubMenuItem();
-
         int handle_event();
+
         TitleCurSubMenu *submenu;
 };
 
+class TitleFontsPopup : public BC_ListBox
+{
+public:
+       TitleFontsPopup(TitleMain *client, TitleWindow *window);
+       ~TitleFontsPopup();
+       int handle_event();
+
+       TitleMain *client;
+       TitleWindow *window;
+};
+
 #endif