~ubuntu-branches/ubuntu/quantal/vice/quantal

« back to all changes in this revision

Viewing changes to src/arch/unix/x11/xaw/x11ui.c

  • Committer: Bazaar Package Importer
  • Author(s): Zed Pobre
  • Date: 2006-07-30 19:15:59 UTC
  • mto: (9.1.1 lenny) (1.1.6 upstream)
  • mto: This revision was merged to the branch mainline in revision 9.
  • Revision ID: james.westby@ubuntu.com-20060730191559-g31ymd2mk102kzff
Tags: upstream-1.19
ImportĀ upstreamĀ versionĀ 1.19

Show diffs side-by-side

added added

removed removed

Lines of Context:
87
87
#include "widgets/TextField.h"
88
88
#include "video.h"
89
89
#include "videoarch.h"
90
 
 
 
90
#include "screenshot.h"
 
91
#include "event.h"
91
92
 
92
93
/* FIXME: We want these to be static.  */
93
94
Visual *visual;
219
220
/* Toplevel widget. */
220
221
Widget _ui_top_level = NULL;
221
222
Widget status_bar = NULL;
 
223
Widget rec_button = NULL;
 
224
static Widget event_recording_button = NULL;
 
225
static int statustext_display_time = 0;
222
226
 
223
227
/* Our colormap. */
224
228
/*static*/ Colormap colormap;
241
245
    Widget shell;
242
246
    Widget canvas;
243
247
    Widget speed_label;
 
248
    Widget statustext_label;
244
249
    struct {
245
250
        Widget track_label;
246
251
        Widget driveled;
285
290
UI_CALLBACK(enter_window_callback);
286
291
UI_CALLBACK(exposure_callback_shell);
287
292
UI_CALLBACK(exposure_callback_canvas);
 
293
static UI_CALLBACK(rec_button_callback)
 
294
{
 
295
    screenshot_stop_recording();
 
296
    XtUnrealizeWidget(rec_button);
 
297
}
 
298
 
 
299
static UI_CALLBACK(event_recording_button_callback)
 
300
{
 
301
    event_record_stop();
 
302
    XtUnrealizeWidget(event_recording_button);
 
303
}
288
304
 
289
305
/* ------------------------------------------------------------------------- */
290
306
 
361
377
    "*driveCurrentImage3.font:                   -*-helvetica-medium-r-*-*-12-*",
362
378
    "*driveCurrentImage4.font:                   -*-helvetica-medium-r-*-*-12-*",
363
379
    "*speedStatus.font:                         -*-helvetica-medium-r-*-*-12-*",
 
380
    "*statustext.font:                         -*-helvetica-medium-r-*-*-8-*",
364
381
 
365
382
    NULL
366
383
};
582
599
                             int width, int height, int no_autorepeat)
583
600
{
584
601
    /* Note: this is correct because we never destroy CanvasWindows.  */
585
 
    Widget shell, speed_label;
 
602
    Widget shell, speed_label, statustext_label;
586
603
    Widget drive_track_label[NUM_DRIVES], drive_led[NUM_DRIVES];
587
604
    Widget drive_current_image[NUM_DRIVES];
588
605
    Widget drive_led1[NUM_DRIVES], drive_led2[NUM_DRIVES];
660
677
    {
661
678
        Dimension height;
662
679
        Dimension led_width = 14, led_height = 5;
663
 
        Dimension w1 = width - 2 - led_width * NUM_DRIVES;
664
 
 
665
 
        speed_label = XtVaCreateManagedWidget
 
680
        
 
681
        speed_label = XtVaCreateManagedWidget
666
682
            ("speedStatus",
667
683
             labelWidgetClass, pane,
668
684
             XtNlabel, "",
669
 
             XtNwidth, (w1 - NUM_DRIVES * (w1 / 4)) / 2,
 
685
             XtNwidth, width / 3,
670
686
             XtNfromVert, canvas,
671
687
             XtNtop, XawChainBottom,
672
688
             XtNbottom, XawChainBottom,
686
702
                (name,
687
703
                 labelWidgetClass, pane,
688
704
                 XtNlabel, "",
689
 
                 XtNwidth, (w1 / 2) + 13,
 
705
                 XtNwidth, (width / 3)  - led_width - 2,
690
706
                 XtNfromVert, i == 0 ? canvas : drive_current_image[i-1],
691
707
                 XtNfromHoriz, speed_label,
692
708
                 XtNhorizDistance, 0,
704
720
                (name,
705
721
                 labelWidgetClass, pane,
706
722
                 XtNlabel, "",
707
 
                 XtNwidth, w1 / 4 + 4,
 
723
                 XtNwidth, (width / 3) - led_width - 2,
708
724
                 XtNfromVert, canvas,
709
725
                 XtNfromVert, i == 0 ? canvas : drive_track_label[i-1],
710
726
                 XtNfromHoriz, drive_current_image[i],
777
793
                 NULL);
778
794
            lib_free(name);
779
795
        }
 
796
        statustext_label = XtVaCreateManagedWidget 
 
797
            ("statustext",
 
798
             labelWidgetClass, pane,
 
799
             XtNwidth, width / 3 - 2,
 
800
             XtNfromVert, speed_label,
 
801
             XtNjustify, XtJustifyLeft,
 
802
             XtNlabel, "",
 
803
             XtNborderWidth, 0,
 
804
             NULL);
 
805
        rec_button = XtVaCreateManagedWidget 
 
806
            ("recButton",
 
807
             commandWidgetClass, pane,
 
808
             XtNwidth, width / 3 - 2,
 
809
             XtNfromVert, statustext_label,
 
810
             XtNjustify, XtJustifyLeft,
 
811
             XtNlabel, _("recording..."),
 
812
             NULL);
 
813
        XtAddCallback(rec_button, XtNcallback, rec_button_callback, NULL);
 
814
        event_recording_button = XtVaCreateManagedWidget 
 
815
            ("eventRecButton",
 
816
             commandWidgetClass, pane,
 
817
             XtNwidth, width / 3 - 2,
 
818
             XtNfromVert, rec_button,
 
819
             XtNjustify, XtJustifyLeft,
 
820
             XtNlabel, _("event recording..."),
 
821
             NULL);
 
822
        XtAddCallback(event_recording_button, XtNcallback, 
 
823
                      event_recording_button_callback, NULL);
780
824
    }
781
825
 
782
826
    /* Assign proper translations to open the menus, if already
823
867
    app_shells[num_app_shells - 1].canvas = canvas;
824
868
    app_shells[num_app_shells - 1].title = lib_stralloc(title);
825
869
    app_shells[num_app_shells - 1].speed_label = speed_label;
 
870
    app_shells[num_app_shells - 1].statustext_label = statustext_label;
826
871
    status_bar = speed_label;
827
872
    
828
873
    for (i = 0; i < NUM_DRIVES; i++) {
847
892
                      drive_widgets[i].current_image);
848
893
 
849
894
    }
850
 
 
 
895
    XtUnrealizeWidget(rec_button);
 
896
    XtUnrealizeWidget(event_recording_button);
 
897
    
851
898
    XSetWMProtocols(display, XtWindow(shell), &wm_delete_window, 1);
852
899
    XtOverrideTranslations(shell,
853
900
                           XtParseTranslationTable
1085
1132
    return 0;
1086
1133
}
1087
1134
 
 
1135
static void statusbar_setstatustext(const char *t)
 
1136
{
 
1137
    int i;
 
1138
    for (i = 0; i < num_app_shells; i++)
 
1139
        XtVaSetValues(app_shells[i].statustext_label, XtNlabel, t, NULL);
 
1140
}
 
1141
 
1088
1142
/* ------------------------------------------------------------------------- */
1089
1143
 
1090
1144
/* Show the speed index to the user.  */
1101
1155
                          NULL);
1102
1156
        } else {
1103
1157
            char *str;
1104
 
 
1105
 
            str = lib_msprintf("%d%%, %d fps %s", percent_int, framerate_int,
 
1158
            str = lib_msprintf("%d%%, %dfps %s", percent_int, framerate_int,
1106
1159
                               warp_flag ? _("(warp)") : "");
1107
1160
            XtVaSetValues(app_shells[i].speed_label, XtNlabel, str, NULL);
1108
1161
            lib_free(str);
1109
1162
        }
1110
1163
    }
 
1164
    if (statustext_display_time > 0) {
 
1165
        statustext_display_time--;
 
1166
        if (statustext_display_time == 0)
 
1167
            statusbar_setstatustext("");
 
1168
    }
 
1169
 
 
1170
    if (!screenshot_is_recording())
 
1171
        XtUnrealizeWidget(rec_button);
1111
1172
}
1112
1173
void ui_enable_drive_status(ui_drive_enable_t enable, int *drive_led_color)
1113
1174
{
1308
1369
 
1309
1370
void ui_display_recording(int recording_status)
1310
1371
{
 
1372
    if (recording_status)
 
1373
    {
 
1374
        XtRealizeWidget(event_recording_button);
 
1375
        XtManageChild(event_recording_button);
 
1376
    }
 
1377
    else
 
1378
        XtUnrealizeWidget(event_recording_button);
1311
1379
}
1312
1380
 
1313
1381
void ui_display_playback(int playback_status, char *version)
2101
2169
    ui_exit();
2102
2170
}
2103
2171
 
 
2172
void ui_display_statustext(const char *text, int fade_out)
 
2173
{
 
2174
    log_message(LOG_DEFAULT, text);
 
2175
    statusbar_setstatustext(text);
 
2176
    if (fade_out)
 
2177
        statustext_display_time = 5;
 
2178
    else
 
2179
        statustext_display_time = 0;
 
2180
}