diff -urwN flwm-1.02/configure.in flwm-1.02.mod/configure.in --- flwm-1.02/configure.in 2000-01-05 13:14:02.000000000 +0300 +++ flwm-1.02.mod/configure.in 2007-12-10 15:48:34.000000000 +0300 @@ -13,6 +13,18 @@ MAKEDEPEND="\$(CXX) -M" +AC_PATH_PROG(FLTK,fltk-utf8-config) +if test "x$FLTK" == x; then + AC_PATH_PROG(FLTK,fltk-config) +fi + +if test "x$FLTK" != x; then + CXXFLAGS="`$FLTK --cxxflags` $CXXFLAGS" + LIBS="`$FLTK --ldflags` $LDFLAGS" +else + die "no fltk-config found" +fi + dnl# add warnings and optimization to compiler switches: dnl# do this last so messing with switches does not break tests if test -n "$GXX"; then diff -urwN flwm-1.02/Frame.C flwm-1.02.mod/Frame.C --- flwm-1.02/Frame.C 2007-12-11 14:54:47.000000000 +0300 +++ flwm-1.02.mod/Frame.C 2007-12-11 14:55:00.000000000 +0300 @@ -5,8 +5,9 @@ #include "Desktop.H" #include #include +#include #include -#include "Rotated.H" +#include "Rotated_xft.H" static Atom wm_state = 0; @@ -481,17 +482,38 @@ void Frame::getLabel(int del) { char* old = (char*)label(); - char* nu = del ? 0 : (char*)getProperty(XA_WM_NAME); + //char* nu = del ? 0 : (char*)getProperty(XA_WM_NAME); + char* nu=0;// = del ? 0 : (char*)getProperty(XA_WM_NAME); + if(!del){ + /*XGetIconName(fl_display,window_,&nu); + printf("icon %s\n",nu); + XFree(nu);nu=0;*/ + XTextProperty prop; + if(XGetWMName(fl_display,window_,&prop)){ + if(NULL!= prop.value && 0!=prop.nitems){ + //printf("icon %d\n",prop.nitems); + + char **strs;int count; + int ret = XmbTextPropertyToTextList(fl_display,&prop,&strs,&count); + if(ret>=0 && strs[0] && count >0)nu=strdup(strs[0]); + else nu=strdup((char*)prop.value); +// printf("%s\n",nu); + if(strs)XFreeStringList(strs); + XFree(prop.value); + } + } + //nu=(char*)prop.value; + } if (nu) { // since many window managers print a default label when none is // given, many programs send spaces to make a blank label. Detect // this and make it really be blank: char* c = nu; while (*c == ' ') c++; - if (!*c) {XFree(nu); nu = 0;} + if (!*c) {free(nu); nu = 0;} } if (old) { - if (nu && !strcmp(old,nu)) {XFree(nu); return;} - XFree(old); + if (nu && !strcmp(old,nu)) {free(nu); return;} + free(old); } else { if (!nu) return; } diff -urwN flwm-1.02/Makefile flwm-1.02.mod/Makefile --- flwm-1.02/Makefile 2006-07-01 02:11:39.000000000 +0400 +++ flwm-1.02.mod/Makefile 2007-12-10 15:48:49.000000000 +0300 @@ -3,9 +3,9 @@ PROGRAM = flwm VERSION = 1.02 -CXXFILES = main.C Frame.C Rotated.C Menu.C FrameWindow.C Desktop.C Hotkeys.C +CXXFILES = main.C Frame.C Rotated_xft.C Menu.C FrameWindow.C Desktop.C Hotkeys.C -LIBS = -lfltk +#LIBS = -lfltk MANPAGE = 1 @@ -80,5 +80,5 @@ $(PROGRAM_D) : $(OBJECTS_D) $(CXX) $(LDFLAGS) -o $(PROGRAM_D) $(OBJECTS_D) $(LIBS) $(LDLIBS) -rotated_test: Rotated.o rotated_test.C - $(CXX) $(CXXFLAGS) $(LDFLAGS) -o rotated_test rotated_test.C Rotated.o $(LIBS) $(LDLIBS) +rotated_test: Rotated_xft.o rotated_test.C + $(CXX) $(CXXFLAGS) $(LDFLAGS) -o rotated_test rotated_test.C Rotated_xft.o $(LIBS) -lfltk-utf8_forms $(LDLIBS) -lfltk-utf8_forms diff -urwN flwm-1.02/rotated_test.C flwm-1.02.mod/rotated_test.C --- flwm-1.02/rotated_test.C 2000-01-18 04:15:25.000000000 +0300 +++ flwm-1.02.mod/rotated_test.C 2007-12-10 16:19:03.000000000 +0300 @@ -11,20 +11,28 @@ //////////////////////////////////////////////////////////////// -#include "Rotated.H" +#include "Rotated_xft.H" class RotText : public Fl_Box { void draw(); public: + int angle; + int aligned; RotText(int X, int Y, int W, int H, const char* L = 0) : - Fl_Box(X,Y,W,H,L) {} + Fl_Box(X,Y,W,H,L),angle(90){} }; void RotText::draw() { draw_box(); fl_color(FL_BLACK); fl_font(labelfont(), labelsize()); - draw_rotated90(label(), x(), y(), w(), h(), align()); + if(aligned){ + if(angle%360==0)fl_draw(label(), x(), y(), w(), h(), align()); + else if(angle%360==90)draw_rotated90(label(), x(), y(), w(), h(), align()); + else if(angle%360==180)draw_rotated180(label(), x(), y(), w(), h(), align()); + else if(angle%360==270)draw_rotated270(label(), x(), y(), w(), h(), align()); + } + else draw_rotated(label(), x()+w()/2, y()+h()/2,angle); } //////////////////////////////////////////////////////////////// @@ -34,6 +42,7 @@ Fl_Input *input; Fl_Hor_Value_Slider *fonts; Fl_Hor_Value_Slider *sizes; +Fl_Hor_Value_Slider *angle; Fl_Double_Window *window; void button_cb(Fl_Widget *,void *) { @@ -59,48 +68,75 @@ window->redraw(); } +void cb_aligned(Fl_Button *o,void *) { + text->aligned=o->value(); + if(text->aligned){ + angle->value(text->angle-text->angle%90); + angle->step(90); + }else{ + angle->step(1); + } + window->redraw(); +} + +void angle_cb(Fl_Widget *,void *) { + text->angle=(int(angle->value())); + window->redraw(); +} + void input_cb(Fl_Widget *,void *) { text->label(input->value()); window->redraw(); } int main(int argc, char **argv) { - window = new Fl_Double_Window(400,400); + window = new Fl_Double_Window(450,425); - input = new Fl_Input(50,0,350,25); + input = new Fl_Input(50,0,375,25); input->static_value("The quick brown fox jumped over the lazy dog."); input->when(FL_WHEN_CHANGED); input->callback(input_cb); - sizes= new Fl_Hor_Value_Slider(50,25,350,25,"Size:"); + angle = new Fl_Hor_Value_Slider(50,25,400,25,"Angle:"); + angle->align(FL_ALIGN_LEFT); + angle->bounds(0,360); + angle->step(1); + angle->value(90); + angle->callback(angle_cb); + + sizes= new Fl_Hor_Value_Slider(50,50,400,25,"Size:"); sizes->align(FL_ALIGN_LEFT); sizes->bounds(1,64); sizes->step(1); sizes->value(14); sizes->callback(size_cb); - fonts=new Fl_Hor_Value_Slider(50,50,350,25,"Font:"); + fonts=new Fl_Hor_Value_Slider(50,75,400,25,"Font:"); fonts->align(FL_ALIGN_LEFT); fonts->bounds(0,15); fonts->step(1); fonts->value(0); fonts->callback(font_cb); + Fl_Group *g = new Fl_Group(0,0,0,0); - leftb = new Fl_Toggle_Button(50,75,50,25,"left"); + leftb = new Fl_Toggle_Button(50,100,50,25,"left"); leftb->callback(button_cb); - rightb = new Fl_Toggle_Button(100,75,50,25,"right"); + rightb = new Fl_Toggle_Button(100,100,50,25,"right"); rightb->callback(button_cb); - topb = new Fl_Toggle_Button(150,75,50,25,"top"); + topb = new Fl_Toggle_Button(150,100,50,25,"top"); topb->callback(button_cb); - bottomb = new Fl_Toggle_Button(200,75,50,25,"bottom"); + bottomb = new Fl_Toggle_Button(200,100,50,25,"bottom"); bottomb->callback(button_cb); - insideb = new Fl_Toggle_Button(250,75,50,25,"inside"); + insideb = new Fl_Toggle_Button(250,100,50,25,"inside"); insideb->callback(button_cb); - wrapb = new Fl_Toggle_Button(300,75,50,25,"wrap"); + wrapb = new Fl_Toggle_Button(300,100,50,25,"wrap"); wrapb->callback(button_cb); - clipb = new Fl_Toggle_Button(350,75,50,25,"clip"); + clipb = new Fl_Toggle_Button(350,100,50,25,"clip"); clipb->callback(button_cb); + Fl_Toggle_Button* bt_align=new Fl_Toggle_Button(400,100,50,25,"by 90"); + bt_align->callback((Fl_Callback*)cb_aligned); + bt_align->value(0); g->resizable(insideb); g->forms_end(); diff -urwN flwm-1.02/Rotated_xft.C flwm-1.02.mod/Rotated_xft.C --- flwm-1.02/Rotated_xft.C 1970-01-01 03:00:00.000000000 +0300 +++ flwm-1.02.mod/Rotated_xft.C 2007-12-10 16:36:37.000000000 +0300 @@ -0,0 +1,123 @@ +// Rotated text drawing with Xft. + +// Original code: +// for FL_ALIGNMENT +// Copyright (c) 1997 Bill Spitzak (spitzak@d2.com) +// +// Xft code: +// Yuri Fedorchenko 2007 +// (work with patchet fltk version) + + +#include +#include +#include "Rotated_xft.H" +#include +#include +#include + + +void draw_rotated(const char* text, int n, int x, int y, int angle) { + if (!text || !*text) return; + /* make angle positive ... */ + if (angle < 0) do angle += 360; while (angle < 0); + if (angle >=360)do angle -= 360; while (angle >=360); + /* get nearest vertical or horizontal direction ... */ + int dir = ((angle+45)/90)%4; +#ifndef WIN32 + int as=fl_angle(); + fl_font(fl_font(),fl_size(),angle); + fl_draw(text,n,x,y); + fl_font(fl_font(),fl_size(),as); +#else + f_name=built_in_table[fl_font()].name; + int weight = FW_NORMAL; + int italic = 0; + if(!f_name)f_name="Arial"; + switch (*f_name++) { + case 'I': italic = 1; break; + case 'P': italic = 1; + case 'B': weight = FW_BOLD; break; + case ' ': break; + default: f_name--; + } + //printf("angle %d\n",angle); + HFONT fid = CreateFont( + -fl_size(), // negative makes it use "char size" + 0, // logical average character width + angle*10., // angle of escapement + angle*10., // base-line orientation angle + weight, + italic, + FALSE, // underline attribute flag + FALSE, // strikeout attribute flag + DEFAULT_CHARSET, // character set identifier + OUT_DEFAULT_PRECIS, // output precision + CLIP_DEFAULT_PRECIS,// clipping precision + DEFAULT_QUALITY, // output quality + DEFAULT_PITCH, // pitch and family + f_name // pointer to typeface name string + ); + if (!fl_gc) fl_GetDC(0); + COLORREF oldColor = SetTextColor(fl_gc, fl_RGB()); + SelectObject(fl_gc, fid); + TextOut(fl_gc, x, y, text, n); + SetTextColor(fl_gc, oldColor); + DeleteObject(fid); +#endif +} + +void draw_rotated(const char* text, int x, int y, int angle) { + if (!text || !*text) return; + draw_rotated(text, strlen(text), x, y, angle); +} + +void draw_rot90(const char* str, int n, int x, int y) { + draw_rotated(str, n, y, -x, 90); +} +void draw_rotated90( + const char* str, // the (multi-line) string + int x, int y, int w, int h, // bounding box + Fl_Align align,Fl_Image* img) { + if (!str || !*str) return; + if (w && h && !fl_not_clipped(x, y, w, h)) return; + if (align & FL_ALIGN_CLIP) fl_clip(x, y, w, h); + int a1 = align&(-16); + if (align & FL_ALIGN_LEFT) a1 |= FL_ALIGN_TOP; + if (align & FL_ALIGN_RIGHT) a1 |= FL_ALIGN_BOTTOM; + if (align & FL_ALIGN_TOP) a1 |= FL_ALIGN_RIGHT; + if (align & FL_ALIGN_BOTTOM) a1 |= FL_ALIGN_LEFT; + fl_draw(str, -(y+h), x, h, w, (Fl_Align)a1, draw_rot90,img); + if (align & FL_ALIGN_CLIP) fl_pop_clip(); +} + +static void draw_rot180(const char* str, int n, int x, int y) { + draw_rotated(str, n, -x, -y, 180); +} +void draw_rotated180( + const char* str, // the (multi-line) string + int x, int y, int w, int h, // bounding box + Fl_Align align,Fl_Image* img) { + int a1 = align&(-16); + if (align & FL_ALIGN_LEFT) a1 |= FL_ALIGN_RIGHT; + if (align & FL_ALIGN_RIGHT) a1 |= FL_ALIGN_LEFT; + if (align & FL_ALIGN_TOP) a1 |= FL_ALIGN_BOTTOM; + if (align & FL_ALIGN_BOTTOM) a1 |= FL_ALIGN_TOP; + fl_draw(str, -(x+w), -(y+h), w, h, (Fl_Align)a1, draw_rot180,img); +} + +static void draw_rot270(const char* str, int n, int x, int y) { + draw_rotated(str, n, -y, x, 270); +} +void draw_rotated270( + const char* str, // the (multi-line) string + int x, int y, int w, int h, // bounding box + Fl_Align align,Fl_Image* img) { + int a1 = align&(-16); + if (align & FL_ALIGN_LEFT) a1 |= FL_ALIGN_BOTTOM; + if (align & FL_ALIGN_RIGHT) a1 |= FL_ALIGN_TOP; + if (align & FL_ALIGN_TOP) a1 |= FL_ALIGN_LEFT; + if (align & FL_ALIGN_BOTTOM) a1 |= FL_ALIGN_RIGHT; + fl_draw(str, y, -(x+w), h, w, (Fl_Align)a1, draw_rot270,img); +} + diff -urwN flwm-1.02/Rotated_xft.H flwm-1.02.mod/Rotated_xft.H --- flwm-1.02/Rotated_xft.H 1970-01-01 03:00:00.000000000 +0300 +++ flwm-1.02.mod/Rotated_xft.H 2007-12-11 14:57:06.000000000 +0300 @@ -0,0 +1,15 @@ +// Rotated text drawing with Xft. + +// Yury Fedorchenko 2007 + +#ifndef Rotated_H +#define Rotated_H + + +void draw_rotated(const char* text, int n, int x, int y, int angle); +void draw_rotated(const char* text, int x, int y, int angle); +void draw_rotated90(const char*, int x, int y, int w, int h, Fl_Align,Fl_Image* img=0); +void draw_rotated270(const char*, int x, int y, int w, int h, Fl_Align,Fl_Image* img=0); +void draw_rotated180(const char*, int x, int y, int w, int h, Fl_Align,Fl_Image* img=0); + +#endif