[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Antiright-devel] antiright/xshell button.c font.c layout.c layou...
From: |
Jeffrey Bedard |
Subject: |
[Antiright-devel] antiright/xshell button.c font.c layout.c layou... |
Date: |
Mon, 20 Aug 2007 19:55:25 +0000 |
CVSROOT: /sources/antiright
Module name: antiright
Changes by: Jeffrey Bedard <jefbed> 07/08/20 19:55:25
Modified files:
xshell : button.c font.c layout.c layout.h text.c
xshell.c xshell_struct.h
Log message:
Calculate geometries based on font properties. Store reference to
entire font structure. Only perform layout on initial mapping.
Began code to allow text widget to properly display text containing
nonprinting characters.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/antiright/xshell/button.c?cvsroot=antiright&r1=1.6&r2=1.7
http://cvs.savannah.gnu.org/viewcvs/antiright/xshell/font.c?cvsroot=antiright&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/antiright/xshell/layout.c?cvsroot=antiright&r1=1.6&r2=1.7
http://cvs.savannah.gnu.org/viewcvs/antiright/xshell/layout.h?cvsroot=antiright&r1=1.3&r2=1.4
http://cvs.savannah.gnu.org/viewcvs/antiright/xshell/text.c?cvsroot=antiright&r1=1.6&r2=1.7
http://cvs.savannah.gnu.org/viewcvs/antiright/xshell/xshell.c?cvsroot=antiright&r1=1.6&r2=1.7
http://cvs.savannah.gnu.org/viewcvs/antiright/xshell/xshell_struct.h?cvsroot=antiright&r1=1.2&r2=1.3
Patches:
Index: button.c
===================================================================
RCS file: /sources/antiright/antiright/xshell/button.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
Index: font.c
===================================================================
RCS file: /sources/antiright/antiright/xshell/font.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- font.c 20 Aug 2007 16:12:09 -0000 1.2
+++ font.c 20 Aug 2007 19:55:24 -0000 1.3
@@ -26,9 +26,11 @@
xsh_set_font(XShell * xsh, const char * name)
{
XGCValues values;
+ XFontStruct * font;
XShellGUI * gui = &(xsh->gui);
- values.font=XLoadFont(gui->display, name);
+ xsh->gui.font=font=XLoadQueryFont(gui->display, name);
+ values.font=font->fid;
XChangeGC(gui->display, gui->gc, GCFont, &values);
}
@@ -40,6 +42,6 @@
Display * dpy = xsh->gui.display;
XGetGCValues(dpy, xsh->gui.gc, GCFont, &values);
- XUnloadFont(dpy, values.font);
+ XFreeFont(dpy, xsh->gui.font);
}
Index: layout.c
===================================================================
RCS file: /sources/antiright/antiright/xshell/layout.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- layout.c 20 Aug 2007 16:18:58 -0000 1.6
+++ layout.c 20 Aug 2007 19:55:24 -0000 1.7
@@ -30,10 +30,12 @@
XShellGUILayout *layout=&(gui->layout);
unsigned int column_count = layout->column_count;
+ if(!(column_count & XSH_STOP_LAYOUT))
XResizeWindow(gui->display, gui->widgets->window,
layout->widget_width*(column_count+1),
XSH_WIDGET_HEIGHT*(column_count>0
- ? layout->max_row_count : layout->row_count+1 ));
+ ? layout->max_row_count : layout->row_count));
+ layout->column_count|=XSH_STOP_LAYOUT;
}
Index: layout.h
===================================================================
RCS file: /sources/antiright/antiright/xshell/layout.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- layout.h 22 Jul 2007 21:54:10 -0000 1.3
+++ layout.h 20 Aug 2007 19:55:25 -0000 1.4
@@ -24,8 +24,21 @@
#define XSH_LAYOUT_H
#define XSH_ROWS_PER_COLUMN 8
-#define XSH_WIDGET_WIDTH 84
+#define XSH_WIDGET_WIDTH 96
#define XSH_WIDGET_HEIGHT 16
+#define XSH_WIDGET_PADDING 2
+#define XSH_FONT_HEIGHT(xsh) (xsh->gui.font->max_bounds.ascent\
+ + xsh->gui.font->max_bounds.descent)
+#define XSH_FONT_WIDTH(xsh) (xsh->gui.font->max_bounds.rbearing\
+ - xsh->gui.font->min_bounds.lbearing)
+#define XSH_WIDGET_HEIGHT_FOR_FONT(xsh) \
+ (XSH_FONT_HEIGHT(xsh)+XSH_WIDGET_PADDING*2)
+#define XSH_WORD_WIDTH(xsh, word) \
+ (XSH_FONT_WIDTH(xsh)*strlen(word))
+#define XSH_WIDGET_WIDTH_FOR_WORD(xsh) \
+ (XSH_WORD_WIDTH(xsh)*XSH_WIDGET_PADDING)
+
+#define XSH_STOP_LAYOUT (1<<31)
void
xsh_layout_widgets(XShell * xsh);
Index: text.c
===================================================================
RCS file: /sources/antiright/antiright/xshell/text.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- text.c 20 Aug 2007 16:18:58 -0000 1.6
+++ text.c 20 Aug 2007 19:55:25 -0000 1.7
@@ -29,17 +29,17 @@
XSHTextData * data = (XSHTextData *)text_widget->data;
char * text=data->label;
unsigned int i, length=strlen(text), line=0, columns=80,
- font_height=18, font_width=8;
+ font_height=data->font_height, font_width=data->font_width;
XSH_SET_COLOR(gui->display, gui->gc, 0, 0, 0);
- xsh_set_font(xsh, "-*-fixed-medium-r-*-*-14-*-*-*-*-*-*-*");
for(i=0; i<length; i+=columns)
{
unsigned int line_length
=(length=strlen(text)) < columns ? length : columns;
XDrawString(gui->display, text_widget->window, gui->gc,
- font_width, (++line)*font_height, text, line_length);
+ 0, (++line)*font_height, text, line_length);
text+=line_length;
+ text=strchr(text, '\n');
}
}
@@ -89,6 +89,18 @@
text->events.button_release=&button_release;
}
+static void
+setup_font_data(XShell * xsh, unsigned int * font_width,
+ unsigned int * font_height)
+{
+ XFontStruct * font;
+
+ xsh_set_font(xsh, "-*-fixed-medium-r-*-*-14-*-*-*-*-*-*-*");
+ font=xsh->gui.font;
+ *font_width=font->max_bounds.rbearing-font->min_bounds.lbearing;
+ *font_height=font->max_bounds.ascent+font->max_bounds.descent;
+}
+
void
xshell_text_new(XShell * xsh, XWidget * parent, int x, int y,
unsigned int rows, const char * command)
@@ -96,15 +108,14 @@
XWidget * text;
XSHTextData * data;
char * label;
- unsigned int font_width=8;
+ const unsigned int columns = 80;
+ data=malloc(sizeof(XSHTextData));
+ setup_font_data(xsh, &(data->font_width), &(data->font_height));
xshell_XWidget_new(xsh, parent, x, y,
- xsh->gui.layout.widget_width=font_width*80,
+ xsh->gui.layout.widget_width=data->font_width*columns,
XSH_WIDGET_HEIGHT*rows);
text=xsh->gui.last_widget;
- data=malloc(sizeof(XSHTextData));
- data->font_height=16;
- data->font_width=font_width;
data->rows=rows;
data->command=(char *)command;
label=strchr(command, '#');
Index: xshell.c
===================================================================
RCS file: /sources/antiright/antiright/xshell/xshell.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- xshell.c 20 Aug 2007 16:12:09 -0000 1.6
+++ xshell.c 20 Aug 2007 19:55:25 -0000 1.7
@@ -86,7 +86,7 @@
/* Main window. */
xshell_XWidget_new(xsh, NULL, 0, 0, 100, 16);
gui->gc=XSH_SETUP_GC(gui->display, gui->widgets->window);
- XSH_SET_COLOR(gui->display, gui->gc, 0xff, 0xff, 0xff);
+ XSH_SET_COLOR(gui->display, gui->gc, 0xae, 0xb2, 0xc3);
xsh_set_font(xsh, "-misc-fixed-medium-r-*-*-14-*-*-*-*-*-*-*");
}
Index: xshell_struct.h
===================================================================
RCS file: /sources/antiright/antiright/xshell/xshell_struct.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- xshell_struct.h 20 Aug 2007 16:12:09 -0000 1.2
+++ xshell_struct.h 20 Aug 2007 19:55:25 -0000 1.3
@@ -70,6 +70,7 @@
XWidget * last_toplevel;
unsigned int widget_count;
GC gc;
+ XFontStruct * font;
#ifdef XSH_USE_GRADIENT
XShellGUIPixbufs pixbufs;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Antiright-devel] antiright/xshell button.c font.c layout.c layou...,
Jeffrey Bedard <=