1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220
|
#include <stdio.h>
#include <xview/xview.h>
#include <xview/panel.h>
#include "generic.h"
typedef struct {
ltgenericd g;
tdisplay dpy;
Panel p;
} ltpaneld, *ltpanel;
tdisplay tpanel_display(p)
ltpanel p;
{
/* check if it's a panel */
if(p==NULL)
return(0);
if(titem_type(p)!=lt_panel)
return(0);
/* return the display */
return(p->dpy);
}
Drawable tpanel_drawable(p)
ltpanel p;
{
/* check if it's a panel */
if(p==NULL)
return(0);
if(titem_type(p)!=lt_panel)
return(0);
/* return the X window for the panel */
return(xv_get(p->p, XV_XID));
}
int tpanel_right_side(p)
ltpanel p;
{
/* check if it's a panel */
if(p==NULL)
return(0);
if(titem_type(p)!=lt_panel)
return(0);
/* return the right side of the panel */
return(xv_get(p->p, XV_X)+xv_get(p->p, XV_WIDTH));
}
int tpanel_bottom_side(p)
ltpanel p;
{
/* check if it's a panel */
if(p==NULL)
return(0);
if(titem_type(p)!=lt_panel)
return(0);
/* return the bottom side of the panel */
return(xv_get(p->p, XV_Y)+xv_get(p->p, XV_HEIGHT));
}
Panel tpanel_xview(p)
ltpanel p;
{
/* check if it's a panel */
if(p==NULL)
return(0);
if(titem_type(p)!=lt_panel)
return(0);
/* return the xview Panel */
return(p->p);
}
tpanel tpanel_new(parent, x,y,w,h,right,below, args)
titem parent;
int x,y,w,h;
titem right,below;
targs args;
{
ltpanel p;
/* check parent type */
if(parent==NULL)
return(NULL);
else if(titem_type(parent)!=lt_frame)
return(NULL);
/* get memory */
p=(ltpanel)titem_new(parent, lt_panel, sizeof(ltpaneld));
if(p==NULL)
return(NULL);
/* create */
p->p=(Panel)xv_create(tframe_xview(parent), PANEL, NULL);
/* setup size */
if(w!=0)
xv_set(p->p, XV_WIDTH, w, NULL);
if(h!=0)
xv_set(p->p, XV_HEIGHT, h, NULL);
/* setup position */
if(right!=NULL)
xv_set(p->p, XV_X, tright_side(right), NULL);
else
xv_set(p->p, XV_X, x, NULL);
if(below!=NULL)
xv_set(p->p, XV_Y, tbottom_side(below), NULL);
else
xv_set(p->p, XV_Y, y, NULL);
p->dpy=(tdisplay)titem_display(parent);
return((tpanel)p);
}
tpanel tpanel_new_from_dialog(f)
tframe f;
{
ltpanel p;
/* get memory */
p=(ltpanel)titem_new(f, lt_panel, sizeof(ltpaneld));
if(p==NULL)
return(NULL);
/* create */
p->p=(Panel)xv_get(tframe_xview(f), FRAME_CMD_PANEL);
return((tpanel)p);
}
int tpanel_free(p)
ltpanel p;
{
/* check if it's a panel */
if(p==NULL)
return(0);
if(titem_type(p)!=lt_panel)
return(0);
xv_destroy_safe(p->p);
return(titem_free(p));
}
int tpanel_fit(p)
ltpanel p;
{
/* check if it's a panel */
if(p==NULL)
return(0);
if(titem_type(p)!=lt_panel)
return(0);
/* fit the panel */
window_fit(p->p);
return(1);
}
int tpanel_set_width_to_frame(p, f)
ltpanel p;
tframe f;
{
/* check if it's a panel and frame */
if(p==NULL)
return(0);
if(titem_type(p)!=lt_panel)
return(0);
if(f==NULL)
return(0);
if(titem_type(f)!=lt_frame)
return(0);
xv_set(p->p, XV_WIDTH, xv_get(tframe_xview(f), XV_WIDTH), NULL);
return(1);
}
int tpanel_height(p)
ltpanel p;
{
/* check if it's a panel */
if(p==NULL)
return(0);
if(titem_type(p)!=lt_panel)
return(0);
/* return the height */
return(xv_get(p->p, XV_HEIGHT));
}
int tpanel_width(p)
ltpanel p;
{
/* check if it's a panel */
if(p==NULL)
return(0);
if(titem_type(p)!=lt_panel)
return(0);
/* return the width */
return(xv_get(p->p, XV_WIDTH));
}
int tpanel_xview_window(p)
ltpanel p;
{
/* check if it's a panel */
if(p==NULL)
return(0);
if(titem_type(p)!=lt_panel)
return(0);
/* return the window */
return(xv_get(p->p, XV_XID));
}
|