ui/motif/pathbar.h

Sun, 23 Nov 2025 08:44:41 +0100

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Sun, 23 Nov 2025 08:44:41 +0100
changeset 926
32b16cbca280
parent 925
df27741d02b5
permissions
-rw-r--r--

implement ui_savefiledialog (Motif)

/*
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
 *
 * Copyright 2025 Olaf Wintermann. All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 *   1. Redistributions of source code must retain the above copyright
 *      notice, this list of conditions and the following disclaimer.
 *
 *   2. Redistributions in binary form must reproduce the above copyright
 *      notice, this list of conditions and the following disclaimer in the
 *      documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 */

#ifndef PATHBAR_H
#define PATHBAR_H

#include <Xm/XmAll.h>

#include "../ui/text.h"

#ifdef __cplusplus
extern "C" {
#endif

#define XNECreateText(parent,name,args,count)   XmCreateTextField(parent,name,args,count)
#define XNETextSetString(widget,value)          XmTextFieldSetString(widget,value)
#define XNETextGetString(widget)                XmTextFieldGetString(widget)
#define XNETextGetLastPosition(widget)          XmTextFieldGetLastPosition(widget)  
#define XNETextSetInsertionPosition(widget, i)  XmTextFieldSetInsertionPosition(widget, i)  
#define XNETextSetSelection(w, f, l, t)         XmTextFieldSetSelection(w, f, l, t)

typedef void(*updatedir_callback)(void*,char*,int);

typedef struct PathBar {  
    Widget widget;
    Widget textfield;
    
    Widget focus_widget;
    
    Widget left;
    Widget right;
    Dimension lw;
    Dimension rw;
    
    int shift;
    
    UiPathElm *current_pathelms;
    Widget *pathSegments;
    size_t numSegments;
    size_t segmentAlloc;
    
    char *path;
    int selection;
    Boolean input;
    
    int focus;
    
    Boolean disableResize;
    
    updatedir_callback updateDir;
    void *updateDirData;
    
    ui_pathelm_func getpathelm;
    void *getpathelmdata;
} PathBar;

PathBar* CreatePathBar(Widget parent, ArgList args, int n);
void PathBarSetPath(PathBar *bar, const char *path);
void PathBarDestroy(PathBar *bar);

void pathbar_resize(Widget w, PathBar *p, XtPointer d);

char* pathbar_concat_path(const char *path1, const char *path2);

#ifdef __cplusplus
}
#endif

#endif /* PATHBAR_H */

mercurial