~ubuntu-branches/ubuntu/gutsy/blender/gutsy-security

« back to all changes in this revision

Viewing changes to source/blender/src/header_text.c

  • Committer: Bazaar Package Importer
  • Author(s): Florian Ernst
  • Date: 2005-11-06 12:40:03 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20051106124003-3pgs7tcg5rox96xg
Tags: 2.37a-1.1
* Non-maintainer upload.
* Split out parts of 01_SConstruct_debian.dpatch again: root_build_dir
  really needs to get adjusted before the clean target runs - closes: #333958,
  see #288882 for reference

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
 * Functions to draw the "Text Editor" window header
5
5
 * and handle user events sent to it.
6
6
 * 
7
 
 * $Id: header_text.c,v 1.17 2004/03/26 01:12:45 stiv Exp $
 
7
 * $Id: header_text.c,v 1.26 2005/05/13 16:11:28 ton Exp $
8
8
 *
9
9
 * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
10
10
 *
43
43
#include <config.h>
44
44
#endif
45
45
 
46
 
#ifdef WIN32
47
 
#include "BLI_winstuff.h"
48
 
#endif
49
 
 
50
46
#include "BMF_Api.h"
51
47
#include "BIF_language.h"
52
 
#ifdef INTERNATIONAL
53
 
#include "FTF_Api.h"
54
 
#endif
55
48
 
56
49
#include "BSE_headerbuttons.h"
57
50
 
133
126
                                st->top= 0;
134
127
                                
135
128
                                pop_space_text(st);
136
 
                        
 
129
                                if (st->showsyntax) get_format_string();
137
130
                                allqueue(REDRAWTEXT, 0);
138
131
                                allqueue(REDRAWHEADERS, 0);
139
132
                        }
161
154
                break;
162
155
*/               
163
156
        case B_TEXTLINENUM:
164
 
                if(st->showlinenrs)
165
 
                        st->showlinenrs = 0;
166
 
                else
167
 
                        st->showlinenrs = 1;
168
 
 
169
157
                allqueue(REDRAWTEXT, 0);
170
158
                allqueue(REDRAWHEADERS, 0);
171
159
                break;
175
163
                case 0:
176
164
                        st->lheight= 12; break;
177
165
                case 1:
178
 
                        st->lheight= 15; break;
179
 
                }
180
 
 
181
 
                allqueue(REDRAWTEXT, 0);
182
 
                allqueue(REDRAWHEADERS, 0);
183
 
 
 
166
                        st->lheight= 15; 
 
167
                        break;
 
168
                }
 
169
                        
 
170
                allqueue(REDRAWTEXT, 0);
 
171
                allqueue(REDRAWHEADERS, 0);
 
172
 
 
173
                break;
 
174
        case B_TAB_NUMBERS:
 
175
                if (st->showsyntax) get_format_string();
 
176
                allqueue(REDRAWTEXT, 0);
 
177
                allqueue(REDRAWHEADERS, 0);
 
178
                break;
 
179
        case B_SYNTAX:
 
180
                if (st->showsyntax) {
 
181
                        get_format_string();
 
182
                }
 
183
                allqueue(REDRAWTEXT, 0);
 
184
                allqueue(REDRAWHEADERS, 0);
184
185
                break;
185
186
        }
186
187
}
210
211
                                if (!reopen_text(text)) {
211
212
                                        error("Could not reopen file");
212
213
                                }
 
214
                        if (st->showsyntax) get_format_string();
213
215
                        }
214
216
                break;
215
217
        case 5:
254
256
                break;
255
257
        case 5:
256
258
                txt_paste(text);
 
259
                if (st->showsyntax) get_format_string();
257
260
                break;
258
261
        case 6:
259
262
                txt_print_cutbuffer();
267
270
        case 9:
268
271
                txt_find_panel(st,0);
269
272
                break;
270
 
        case 10:
271
 
                txt_export_to_object(text);
272
 
                break;
273
273
        default:
274
274
                break;
275
275
        }
320
320
        switch(event) {
321
321
        case 1:
322
322
                txt_sel_all(text);
323
 
                break;
324
 
                        
 
323
                break;          
325
324
        case 2:
326
325
                txt_sel_line(text);
327
326
                break;
337
336
        }
338
337
}
339
338
 
 
339
/* action executed after clicking in Format menu */
 
340
static void do_text_formatmenu(void *arg, int event)
 
341
{
 
342
        SpaceText *st= curarea->spacedata.first;
 
343
        Text *text= st->text;
 
344
        ScrArea *sa;
 
345
        
 
346
        switch(event) {
 
347
        case 3:
 
348
                if (txt_has_sel(text)) {
 
349
                        txt_order_cursors(text);
 
350
                        indent(text);
 
351
                        break;
 
352
                }
 
353
                else {
 
354
                        txt_add_char(text, '\t');
 
355
                        break;
 
356
                }
 
357
        case 4:
 
358
                if ( txt_has_sel(text)) {
 
359
                        txt_order_cursors(text);
 
360
                        unindent(text);
 
361
                        break;
 
362
                }
 
363
                break;
 
364
        case 5:
 
365
                if ( txt_has_sel(text)) {
 
366
                        txt_order_cursors(text);
 
367
                        comment(text);
 
368
                        break;
 
369
                }
 
370
                break;
 
371
        case 6:
 
372
                if ( txt_has_sel(text)) {
 
373
                        txt_order_cursors(text);
 
374
                        uncomment(text);
 
375
                        break;
 
376
                }
 
377
                break;
 
378
        default:
 
379
                break;
 
380
        }
 
381
 
 
382
        for (sa= G.curscreen->areabase.first; sa; sa= sa->next) {
 
383
                SpaceText *st= sa->spacedata.first;
 
384
                if (st && st->spacetype==SPACE_TEXT) {
 
385
                        scrarea_queue_redraw(sa);
 
386
                }
 
387
        }
 
388
}
 
389
 
340
390
/* View menu */
341
391
static uiBlock *text_editmenu_viewmenu(void *arg_unused)
342
392
{
366
416
 
367
417
        uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Select All|Ctrl A", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 1, "");
368
418
        uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Select Line", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 2, "");
369
 
 
370
 
        uiBlockSetDirection(block, UI_RIGHT);
371
 
        uiTextBoundsBlock(block, 60);
372
 
        
373
 
        return block;
374
 
}
 
419
        
 
420
        uiBlockSetDirection(block, UI_RIGHT);
 
421
        uiTextBoundsBlock(block, 60);
 
422
        
 
423
        return block;
 
424
}
 
425
 
 
426
/* Format menu */
 
427
static uiBlock *text_formatmenu(void *arg_unused)
 
428
{
 
429
        uiBlock *block;
 
430
        short yco= 0, menuwidth=120;
 
431
 
 
432
        block= uiNewBlock(&curarea->uiblocks, "text_formatmenu", UI_EMBOSSP, UI_HELV, curarea->headwin);
 
433
        uiBlockSetButmFunc(block, do_text_formatmenu, NULL);
 
434
 
 
435
        uiDefBut(block, SEPR, 0, "",        0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
 
436
        uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Indent|Tab", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 3, "");
 
437
        uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Unindent|Shift Tab", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 4, "");
 
438
        uiDefBut(block, SEPR, 0, "",        0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
 
439
        uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Comment", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 5, "");
 
440
        uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Uncomment", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 6, "");
 
441
        
 
442
        if(curarea->headertype==HEADERTOP) {
 
443
                uiBlockSetDirection(block, UI_DOWN);
 
444
        }
 
445
        else {
 
446
                uiBlockSetDirection(block, UI_TOP);
 
447
                uiBlockFlipOrder(block);
 
448
        }
 
449
 
 
450
        uiTextBoundsBlock(block, 50);
 
451
        return block;
 
452
}
 
453
 
 
454
 
 
455
/* action executed after clicking in Object to 3d Sub Menu */
 
456
void do_text_editmenu_to3dmenu(void *arg, int event)
 
457
{
 
458
        SpaceText *st= curarea->spacedata.first;
 
459
        Text *text= st->text;
 
460
        
 
461
        switch(event) {
 
462
        case 1: txt_export_to_object(text); break;
 
463
        case 2: txt_export_to_objects(text); break;
 
464
        }
 
465
        allqueue(REDRAWVIEW3D, 0);
 
466
}
 
467
 
 
468
/* Object to 3d Sub Menu */
 
469
static uiBlock *text_editmenu_to3dmenu(void *arg_unused)
 
470
{
 
471
        uiBlock *block;
 
472
        short yco = 20, menuwidth = 120;
 
473
 
 
474
        block= uiNewBlock(&curarea->uiblocks, "do_text_editmenu_to3dmenu", UI_EMBOSSP, UI_HELV, G.curscreen->mainwin);
 
475
        uiBlockSetButmFunc(block, do_text_editmenu_to3dmenu, NULL);
 
476
 
 
477
        uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "One Object | Alt-M",             0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 1, "");
 
478
        uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "One Object Per Line",            0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 2, "");
 
479
        
 
480
        uiBlockSetDirection(block, UI_RIGHT);
 
481
        uiTextBoundsBlock(block, 60);
 
482
        return block;
 
483
}
 
484
 
375
485
 
376
486
/* Edit menu */
377
487
static uiBlock *text_editmenu(void *arg_unused)
382
492
        block= uiNewBlock(&curarea->uiblocks, "text_editmenu", UI_EMBOSSP, UI_HELV, curarea->headwin);
383
493
        uiBlockSetButmFunc(block, do_text_editmenu, NULL);
384
494
 
385
 
        uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Undo|Alt U", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 1, "");
386
 
        uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Redo|Alt Shift U", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 2, "");
 
495
        uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Undo|Ctrl Z", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 1, "");
 
496
        uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Redo|Ctrl Shift Z", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 2, "");
387
497
        uiDefBut(block, SEPR, 0, "",        0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
388
498
        uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Cut|Alt X", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 3, "");
389
499
        uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Copy|Alt C", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 4, "");
397
507
        uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Find...|Alt Ctrl F", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 8, "");
398
508
        uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Find Again|Alt F", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 9, "");
399
509
        uiDefBut(block, SEPR, 0, "",        0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
400
 
        uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Convert to 3D Text|Alt M", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 10, "");
 
510
        uiDefIconTextBlockBut(block, text_editmenu_to3dmenu, NULL, ICON_RIGHTARROW_THIN, "Text to 3d Object", 0, yco-=20, 120, 19, "");
401
511
        
402
512
        if(curarea->headertype==HEADERTOP) {
403
513
                uiBlockSetDirection(block, UI_DOWN);
486
596
                uiBlockSetEmboss(block, UI_EMBOSSP);
487
597
        
488
598
                xmax= GetButStringLength("File");
489
 
                uiDefBlockBut(block,text_filemenu, NULL, "File", xco, 0, xmax, 20, "");
 
599
                uiDefPulldownBut(block,text_filemenu, NULL, "File", xco, 0, xmax, 20, "");
490
600
                xco+=xmax;
491
601
        
492
602
                if(text) {
493
603
                        xmax= GetButStringLength("Edit");
494
 
                        uiDefBlockBut(block,text_editmenu, NULL, "Edit", xco, 0, xmax, 20, "");
 
604
                        uiDefPulldownBut(block,text_editmenu, NULL, "Edit", xco, 0, xmax, 20, "");
 
605
                        xco+=xmax;
 
606
                        
 
607
                        xmax= GetButStringLength("Format");
 
608
                        uiDefPulldownBut(block,text_formatmenu, NULL, "Format", xco, 0, xmax, 20, "");
495
609
                        xco+=xmax;
496
610
                }
497
611
        }
502
616
        if(curarea->full) uiDefIconBut(block, BUT,B_FULL, ICON_SPLITSCREEN,     xco,0,XIC,YIC, 0, 0, 0, 0, 0, "Returns to multiple views window (CTRL+Up arrow)");
503
617
        else uiDefIconBut(block, BUT,B_FULL, ICON_FULLSCREEN,   xco,0,XIC,YIC, 0, 0, 0, 0, 0, "Makes current window full screen (CTRL+Down arrow)");
504
618
                
505
 
        if(st->showlinenrs)
506
 
                uiDefIconBut(block, BUT, B_TEXTLINENUM, ICON_SHORTDISPLAY, xco+=XIC,0,XIC,YIC, 0, 0, 0, 0, 0, "Hides line numbers");
507
 
        else
508
 
                uiDefIconBut(block, BUT, B_TEXTLINENUM, ICON_LONGDISPLAY, xco+=XIC,0,XIC,YIC, 0, 0, 0, 0, 0, "Displays line numbers");
 
619
        uiDefIconButI(block, ICONTOG, B_TEXTLINENUM, ICON_LONGDISPLAY, xco+=XIC,0,XIC,YIC, &st->showlinenrs, 0, 0, 0, 0, "Displays line numbers");
509
620
 
 
621
        uiDefIconButI(block, ICONTOG, B_SYNTAX, ICON_SYNTAX, xco+=XIC,0,XIC,YIC, &st->showsyntax, 0, 0, 0, 0, "Enables Syntax Highlighting");
510
622
 
511
623
        /* STD TEXT BUTTONS */
512
624
        xco+= 2*XIC;
527
639
        xco+=XIC;
528
640
        if(st->font_id>1) st->font_id= 0;
529
641
        uiDefButI(block, MENU, B_TEXTFONT, "Screen 12 %x0|Screen 15%x1", xco,0,100,YIC, &st->font_id, 0, 0, 0, 0, "Displays available fonts");
530
 
        xco+=100;
531
 
 
 
642
        xco+=110;
 
643
        
 
644
        uiDefButI(block, NUM, B_TAB_NUMBERS, "Tab:",            xco, 0, XIC+50, YIC, &st->tabnumber, 2, 8, 0, 0, "Set spacing of Tab");
 
645
        xco+= XIC+50;
 
646
        
532
647
        /* always as last  */
533
648
        curarea->headbutlen= xco+2*XIC;
534
649