Example #1
0
static  void    AsmResize( a_window *wnd )
{
    asm_window          *asw = WndAsm( wnd );
    asm_addr            *new_ins;
    address             first;
    int         size;

    size = WndRows( wnd );
    if( size <= 0 ) size = 1;
    first = asw->ins[ 0 ].addr;
    new_ins = WndAlloc( size*sizeof( *new_ins ) );
    memset( new_ins, 0, size*sizeof( *new_ins ) );
    if( new_ins == NULL ) {
        WndClose( wnd );
        WndNoMemory();
    }
    WndFree( asw->ins );
    asw->ins = new_ins;
    asw->ins_size = size;
    AsmSetFirst( wnd, first, asw->ins[ 0 ].line != 0 );
    CalcAddrLen( wnd, first );
    if( asw->last_width != WndWidth( wnd ) ) {
        WndZapped( wnd );
    }
    asw->last_width = WndWidth( wnd );
    WndFixedThumb( wnd );
}
Example #2
0
void    *WndMustAlloc( size_t size )
{
    void        *chunk;

    chunk = WndAlloc( size );
    if( chunk == NULL )
        WndNoMemory();
    return( chunk );
}
Example #3
0
static void DoSet( int i, a_window *wnd,
                   int row, int piece, wnd_line_piece *line )
{
    CacheLine[i].line = *line;
    CacheLine[i].wnd = wnd;
    CacheLine[i].row = row;
    CacheLine[i].piece = piece;
    WndFree( CacheLine[i].text );
    CacheLine[i].text = WndAlloc( strlen( line->text ) + 1 );
    strcpy( CacheLine[i].text, line->text );
}
Example #4
0
void ProcPaint( void )
{
    wnd_class           wndcls;
    gui_colour          fore;
    gui_colour          back;
    gui_colour_set      *set;
    bool                dialog;
    int                 attr;

    dialog = FALSE;
    wndcls = WND_NO_CLASS;
    if( ScanStatus() ) {
        attr = 0;
    } else if( ScanCmd( "DIalog\0" ) == 0 ) {
        dialog = TRUE;
        attr = ScanAttr( DlgAttrMap, ArraySize( DlgAttrMap ) );
    } else {
        wndcls = ReqWndName();
        attr = ScanAttr( AttrMap, ArraySize( AttrMap ) );
    }
    fore = ScanColour();
    ScanCmd( "On\0" );
    back = ScanColour();
    ReqEOC();
    if( attr < 0 )
        return;
    if( wndcls == WND_NO_CLASS ) {
        if( dialog ) {
            GUIGetDialogColours( WndDlgColours );
            set_dlg_attr( (gui_dlg_attr)attr, fore, back );
            GUISetDialogColours( WndDlgColours );
        } else {
            WndStatusColour.fore = fore;
            WndStatusColour.back = back;
            if( WndHaveStatusWindow() ) {
                WndCloseStatusWindow();
                WndCreateStatusWindow( &WndStatusColour );
            }
        }
    } else {
        set = WndClassColour[wndcls];
        if( set == NULL ) {
            set = WndAlloc( sizeof( WndColours ) );
            memcpy( set, WndColours, sizeof( WndColours ) );
            WndClassColour[wndcls] = set;
        }
        set_wndcls_attr( (wnd_attr)attr, set, fore, back, ( wndcls == WND_ALL ) );
        _SwitchOn( SW_PENDING_REPAINT );
    }
}
Example #5
0
static void     ModInit( a_window *wnd )
{
    mod_window  *mod = WndMod( wnd );
    int         size;

    ModListFree( ModList( mod ) );
    ModListAddModules( ModList( mod ), mod->handle, mod->all_modules );
    WndFree( mod->info );
    mod->info = NULL;
    size = sizeof( modinfo ) * ModListNumRows( ModList( mod ) );
    if( size != 0 ) {
        mod->info = WndAlloc( size );
        memset( mod->info, 0, size );
    }
    ModCalcIndent( wnd );
}
Example #6
0
void WndShowAll( void )
{
    gui_window  *gui;
    gui_window  **list;
    gui_window  **pcurr;
    int         count;

    // this is a kludge since UI brings windows to the front on show
    count = 0;
    for( gui = GUIGetFront(); gui != NULL; gui = GUIGetNextWindow( gui ) ) {
        ++count;
    }
    list = WndAlloc( count * sizeof( gui ) );
    pcurr = list;
    for( gui = GUIGetFront(); gui != NULL; gui = GUIGetNextWindow( gui ) ) {
        if( WndMain != NULL && WndMain->gui == gui )
            continue;
        *pcurr++ = gui;
    }
    while( pcurr > list ) {
        GUIShowWindow( *--pcurr );
    }
    WndFree( list );
}
Example #7
0
static a_window *WndCreateWithStructBody( wnd_create_struct *info,
                                          gui_create_info *init )
{
    a_window    *wnd;
    gui_window  *gui;
    char        buff[256];
    int         size;

    if( info->title == NULL ) {
        buff[0] = '\0';
    } else {        // might be clobbered by create
        strcpy( buff, info->title );
    }
    if( info->title != NULL )
        strcpy( buff, info->title ); // might be clobbered by create
    size = sizeof( *wnd ) + ( WndMaxDirtyRects - 1 ) * sizeof( wnd->dirty ); //
    wnd = WndAlloc( size );
    if( wnd == NULL ) {
        WndFree( info->extra );
        WndNoMemory();
    }
    memset( wnd, 0, size );
    wnd->u.button_down.row = (char)-1;
    wnd->gui = NULL;
    wnd->info = info->info;
    wnd->wndclass = info->wndclass;
    wnd->extra = info->extra;
    wnd->title_size = info->title_size;
    wnd->rows = 1;      // just so it's not zero in init code
    WndNoSelect( wnd );
    WndNoCurrent( wnd );
    WndSetCurrCol( wnd );
    WndNullPopItem( wnd );
    wnd->dirtyrects= 0; // wndnoselect changes this!
    wnd->vscroll_pending = 0;
    wnd->hscroll_pending = -1;
    wnd->keypiece = WND_NO_PIECE;

    wnd->switches = WSW_SELECT_IN_TABSTOP | WSW_MUST_CLICK_ON_PIECE |
                    WSW_ALLOW_POPUP | WSW_SEARCH_WRAP | WSW_HIGHLIGHT_CURRENT |
                    WSW_ONLY_MODIFY_TABSTOP | WSW_MENU_ACCURATE_ROW;

    if( info->rect.width == 0 || info->rect.height == 0 ) {
        init->rect.x = 0;
        init->rect.y = 0;
        init->rect.width = WndMax.x;
        init->rect.height = WndMax.y;
    } else {
        init->rect.x = info->rect.x;
        init->rect.y = info->rect.y;
        init->rect.width = info->rect.width;
        init->rect.height = info->rect.height;
    }
    init->scroll = info->scroll;
    init->style = info->style;
    init->style |= GUI_VSCROLL_EVENTS;
    init->style &= ~GUI_HSCROLL_EVENTS;
    init->title = ( info->title == NULL ) ? NULL : "";
    if( WndMain != NULL ) {
        init->style |= GUI_VISIBLE;
        init->parent = WndMain->gui;
        init->num_menus = 0;
        init->menu = NULL;
    } else {
        init->style &= ~GUI_VISIBLE;
        init->scroll = GUI_NOSCROLL;
        init->num_menus = WndNumMenus;
        init->menu = WndMainMenu;
        init->parent = NULL;
    }
    if( init->style & GUI_POPUP ) {
        init->parent = NULL;
    }
    init->num_attrs = WndNumColours;
    init->colours = info->colour;
    init->call_back = WndMainEventProc;
    init->extra = wnd;

    _Set( wnd, WSW_ACTIVE );

    gui = GUICreateWindow( init );
    if( gui == NULL ) {
        WndFree( info->extra );
        WndFree( wnd );
        WndNoMemory();
        return( NULL );
    } else {
        if( buff[0] != '\0' ) {
            WndSetTitle( wnd, buff );
        }
    }
    ++NumWindows;
    return( wnd );
}