Changed Misc::

This commit is contained in:
fluxgen 2002-01-06 11:07:42 +00:00
parent ad3923a371
commit 68d83ecc98
10 changed files with 98 additions and 96 deletions

View file

@ -33,6 +33,7 @@
#include "fluxbox.hh"
#include "Basemenu.hh"
#include "Screen.hh"
#include "StringUtil.hh"
#ifdef HAVE_STDIO_H
# include <stdio.h>
@ -197,8 +198,8 @@ Basemenu::~Basemenu(void) {
int Basemenu::insert(const char *l, int function, const char *e, int pos) {
char *label = 0, *exec = 0;
if (l) label = Misc::strdup(l);
if (e) exec = Misc::strdup(e);
if (l) label = StringUtil::strdup(l);
if (e) exec = StringUtil::strdup(e);
BasemenuItem *item = new BasemenuItem(label, function, exec);
menuitems->insert(item, pos);
@ -210,7 +211,7 @@ int Basemenu::insert(const char *l, int function, const char *e, int pos) {
int Basemenu::insert(const char *l, Basemenu *submenu, int pos) {
char *label = 0;
if (l) label = Misc::strdup(l);
if (l) label = StringUtil::strdup(l);
BasemenuItem *item = new BasemenuItem(label, submenu);
menuitems->insert(item, pos);
@ -507,11 +508,11 @@ void Basemenu::redrawTitle(void) {
l += (menu.bevel_w * 2);
switch (screen->getMenuStyle()->titlefont.justify) {
case Misc::Font::RIGHT:
case DrawUtil::Font::RIGHT:
dx += menu.width - l;
break;
case Misc::Font::CENTER:
case DrawUtil::Font::CENTER:
dx += (menu.width - l) / 2;
break;
default:
@ -644,11 +645,11 @@ void Basemenu::drawItem(int index, Bool highlight, Bool clear,
}
switch(screen->getMenuStyle()->framefont.justify) {
case Misc::Font::LEFT:
case DrawUtil::Font::LEFT:
text_x = item_x + menu.bevel_w + menu.item_h + 1;
break;
case Misc::Font::RIGHT:
case DrawUtil::Font::RIGHT:
text_x = item_x + menu.item_w - (menu.item_h + menu.bevel_w + text_w);
break;
default: //center
@ -789,7 +790,7 @@ void Basemenu::setLabel(const char *l) {
if (menu.label)
delete [] menu.label;
if (l) menu.label = Misc::strdup(l);
if (l) menu.label = StringUtil::strdup(l);
else menu.label = 0;
}

View file

@ -273,10 +273,10 @@ void IconBar::draw(IconBarObj *obj, int width) {
}
switch (m_screen->getWindowStyle()->tab.font.justify) {
case Misc::Font::RIGHT:
case DrawUtil::Font::RIGHT:
dx += width - l;
break;
case Misc::Font::CENTER:
case DrawUtil::Font::CENTER:
dx += (width - l) / 2;
break;
default:

View file

@ -39,6 +39,7 @@
#include "Icon.hh"
#include "Image.hh"
#include "Screen.hh"
#include "StringUtil.hh"
#ifdef SLIT
#include "Slit.hh"
@ -831,13 +832,13 @@ void BScreen::saveStrftimeFormat(char *format) {
if (resource.strftime_format)
delete [] resource.strftime_format;
resource.strftime_format = Misc::strdup(format);
resource.strftime_format = StringUtil::strdup(format);
}
#endif // HAVE_STRFTIME
void BScreen::addWorkspaceName(char *name) {
workspaceNames->insert(Misc::strdup(name));
workspaceNames->insert(StringUtil::strdup(name));
}
@ -847,7 +848,7 @@ void BScreen::getNameOfWorkspace(int id, char **name) {
char *wkspc_name = workspaceNames->find(id);
if (wkspc_name)
*name = Misc::strdup(wkspc_name);
*name = StringUtil::strdup(wkspc_name);
} else
*name = 0;
}
@ -1460,7 +1461,7 @@ Bool BScreen::parseMenuFile(FILE *file, Rootmenu *menu) {
char **ls = new char* [entries];
int index = 0;
while ((p = readdir(d)))
ls[index++] = Misc::strdup(p->d_name);
ls[index++] = StringUtil::strdup(p->d_name);
qsort(ls, entries, sizeof(char *), dcmp);

View file

@ -20,14 +20,15 @@
// DEALINGS IN THE SOFTWARE.
#include "Tab.hh"
#include <iostream>
#ifdef HAVE_CONFIG_H
# include "../config.h"
#endif // HAVE_CONFIG_H
#include "i18n.hh"
#include "DrawUtil.hh"
#include "misc.hh"
#include <iostream>
using namespace std;
bool Tab::m_stoptabs = false;
@ -333,11 +334,11 @@ void Tab::draw(bool pressed) {
m_win->getScreen()->getTabPlacement() == PRIGHT) &&
(!m_win->isShaded() && m_win->getScreen()->isTabRotateVertical())) {
tabtext_w = Misc::XRotTextWidth(m_win->getScreen()->getWindowStyle()->tab.rot_font,
tabtext_w = DrawUtil::XRotTextWidth(m_win->getScreen()->getWindowStyle()->tab.rot_font,
m_win->client.title, m_win->client.title_len);
tabtext_w += (m_win->frame.bevel_w * 4);
Misc::DrawRotString(m_display, m_tabwin, gc,
DrawUtil::DrawRotString(m_display, m_tabwin, gc,
m_win->getScreen()->getWindowStyle()->tab.rot_font,
m_win->getScreen()->getWindowStyle()->tab.font.justify,
tabtext_w, m_size_w, m_size_h,
@ -357,7 +358,7 @@ void Tab::draw(bool pressed) {
}
tabtext_w += (m_win->frame.bevel_w * 4);
Misc::DrawString(m_display, m_tabwin, gc,
DrawUtil::DrawString(m_display, m_tabwin, gc,
&m_win->getScreen()->getWindowStyle()->tab.font,
tabtext_w, m_size_w,
m_win->frame.bevel_w, m_win->client.title);

View file

@ -270,7 +270,7 @@ void Theme::freeTabStyle() {
XFreeFont(m_display, m_windowstyle.tab.font.fontstruct);
if (m_windowstyle.tab.rot_font)
Misc::XRotUnloadFont(m_display, m_windowstyle.tab.rot_font);
DrawUtil::XRotUnloadFont(m_display, m_windowstyle.tab.rot_font);
XFreeGC(m_display, m_windowstyle.tab.l_text_focus_gc);
@ -345,27 +345,27 @@ void Theme::loadMenuStyle() {
"Menu.Title.Justify", &value_type, &value)) {
if (strstr(value.addr, "right") || strstr(value.addr, "Right"))
m_menustyle.titlefont.justify = Misc::Font::RIGHT;
m_menustyle.titlefont.justify = DrawUtil::Font::RIGHT;
else if (strstr(value.addr, "center") || strstr(value.addr, "Center"))
m_menustyle.titlefont.justify = Misc::Font::CENTER;
m_menustyle.titlefont.justify = DrawUtil::Font::CENTER;
else
m_menustyle.titlefont.justify = Misc::Font::LEFT;
m_menustyle.titlefont.justify = DrawUtil::Font::LEFT;
} else
m_menustyle.titlefont.justify = Misc::Font::LEFT;
m_menustyle.titlefont.justify = DrawUtil::Font::LEFT;
if (XrmGetResource(m_database, "menu.frame.justify",
"Menu.Frame.Justify", &value_type, &value)) {
if (strstr(value.addr, "right") || strstr(value.addr, "Right"))
m_menustyle.framefont.justify = Misc::Font::RIGHT;
m_menustyle.framefont.justify = DrawUtil::Font::RIGHT;
else if (strstr(value.addr, "center") || strstr(value.addr, "Center"))
m_menustyle.framefont.justify = Misc::Font::CENTER;
m_menustyle.framefont.justify = DrawUtil::Font::CENTER;
else
m_menustyle.framefont.justify = Misc::Font::LEFT;
m_menustyle.framefont.justify = DrawUtil::Font::LEFT;
} else
m_menustyle.framefont.justify = Misc::Font::LEFT;
m_menustyle.framefont.justify = DrawUtil::Font::LEFT;
if (XrmGetResource(m_database, "menu.bullet", "Menu.Bullet",
&value_type, &value)) {
@ -500,13 +500,13 @@ void Theme::loadWindowStyle() {
if (XrmGetResource(m_database, "window.justify", "Window.Justify",
&value_type, &value)) {
if (strstr(value.addr, "right") || strstr(value.addr, "Right"))
m_windowstyle.font.justify = Misc::Font::RIGHT;
m_windowstyle.font.justify = DrawUtil::Font::RIGHT;
else if (strstr(value.addr, "center") || strstr(value.addr, "Center"))
m_windowstyle.font.justify = Misc::Font::CENTER;
m_windowstyle.font.justify = DrawUtil::Font::CENTER;
else
m_windowstyle.font.justify = Misc::Font::LEFT;
m_windowstyle.font.justify = DrawUtil::Font::LEFT;
} else
m_windowstyle.font.justify = Misc::Font::LEFT;
m_windowstyle.font.justify = DrawUtil::Font::LEFT;
}
@ -578,21 +578,21 @@ void Theme::loadTabStyle() {
// TODO: add extra checking
if (XrmGetResource(m_database, "window.tab.font", "Window.Tab.Font",
&value_type, &value)) {
if (! (m_windowstyle.tab.rot_font = Misc::XRotLoadFont(m_display, value.addr, 90.0)) )
m_windowstyle.tab.rot_font = Misc::XRotLoadFont(m_display, "fixed", 90);
if (! (m_windowstyle.tab.rot_font = DrawUtil::XRotLoadFont(m_display, value.addr, 90.0)) )
m_windowstyle.tab.rot_font = DrawUtil::XRotLoadFont(m_display, "fixed", 90);
} else
m_windowstyle.tab.rot_font = Misc::XRotLoadFont(m_display, "fixed", 90);
m_windowstyle.tab.rot_font = DrawUtil::XRotLoadFont(m_display, "fixed", 90);
if (XrmGetResource(m_database, "window.tab.justify", "Window.Tab.Justify",
&value_type, &value)) {
if (strstr(value.addr, "right") || strstr(value.addr, "Right"))
m_windowstyle.tab.font.justify = Misc::Font::RIGHT;
m_windowstyle.tab.font.justify = DrawUtil::Font::RIGHT;
else if (strstr(value.addr, "center") || strstr(value.addr, "Center"))
m_windowstyle.tab.font.justify = Misc::Font::CENTER;
m_windowstyle.tab.font.justify = DrawUtil::Font::CENTER;
else
m_windowstyle.tab.font.justify = Misc::Font::LEFT;
m_windowstyle.tab.font.justify = DrawUtil::Font::LEFT;
} else
m_windowstyle.tab.font.justify = Misc::Font::LEFT;
m_windowstyle.tab.font.justify = DrawUtil::Font::LEFT;
}
@ -649,13 +649,13 @@ void Theme::loadToolbarStyle() {
if (XrmGetResource(m_database, "toolbar.justify",
"Toolbar.Justify", &value_type, &value)) {
if (strstr(value.addr, "right") || strstr(value.addr, "Right"))
m_toolbarstyle.font.justify = Misc::Font::RIGHT;
m_toolbarstyle.font.justify = DrawUtil::Font::RIGHT;
else if (strstr(value.addr, "center") || strstr(value.addr, "Center"))
m_toolbarstyle.font.justify = Misc::Font::CENTER;
m_toolbarstyle.font.justify = DrawUtil::Font::CENTER;
else
m_toolbarstyle.font.justify = Misc::Font::LEFT;
m_toolbarstyle.font.justify = DrawUtil::Font::LEFT;
} else
m_toolbarstyle.font.justify = Misc::Font::LEFT;
m_toolbarstyle.font.justify = DrawUtil::Font::LEFT;
}

View file

@ -50,8 +50,8 @@
#include "Image.hh"
#endif //_IMAGE_HH_
#ifndef _MISC_HH_
#include "misc.hh"
#ifndef _DRAWUTIL_HH_
#include "DrawUtil.hh"
#endif //_MISC_HH_
#include <X11/Xlib.h>
@ -70,7 +70,7 @@ public:
BColor t_text, f_text, h_text, d_text;
BTexture title, frame, hilite;
GC t_text_gc, f_text_gc, h_text_gc, d_text_gc, hilite_gc;
Misc::Font titlefont, framefont;
DrawUtil::Font titlefont, framefont;
int bullet, bullet_pos;
} MenuStyle;
@ -79,7 +79,7 @@ public:
BTexture l_focus, l_unfocus,
t_focus, t_unfocus;
GC l_text_focus_gc, l_text_unfocus_gc;
Misc::Font font;
DrawUtil::Font font;
BColor l_text_focus, l_text_unfocus;
} LabelStyle;
@ -95,7 +95,7 @@ public:
BColor border_color;
unsigned int border_width;
unsigned int border_width_2x;
Misc::XRotFontStruct *rot_font;
DrawUtil::XRotFontStruct *rot_font;
} tab;
} WindowStyle;
@ -105,7 +105,7 @@ public:
BColor l_text, w_text, c_text, b_pic;
BTexture toolbar, label, window, button, pressed, clock;
GC l_text_gc, w_text_gc, c_text_gc, b_pic_gc;
Misc::Font font;
DrawUtil::Font font;
} ToolbarStyle;

View file

@ -63,7 +63,6 @@
#endif // TIME_WITH_SYS_TIME
#include <iostream>
#include "misc.hh"
using namespace std;
@ -645,11 +644,11 @@ void Toolbar::checkClock(Bool redraw, Bool date) {
}
switch (screen->getToolbarStyle()->font.justify) {
case Misc::Font::RIGHT:
case DrawUtil::Font::RIGHT:
dx += frame.clock_w - l;
break;
case Misc::Font::CENTER:
case DrawUtil::Font::CENTER:
dx += (frame.clock_w - l) / 2;
break;
default: //LEFT
@ -711,11 +710,11 @@ void Toolbar::redrawWindowLabel(Bool redraw) {
}
}
switch (screen->getToolbarStyle()->font.justify) {
case Misc::Font::RIGHT:
case DrawUtil::Font::RIGHT:
dx += frame.window_label_w - l;
break;
case Misc::Font::CENTER:
case DrawUtil::Font::CENTER:
dx += (frame.window_label_w - l) / 2;
break;
default:
@ -789,11 +788,11 @@ void Toolbar::redrawWorkspaceLabel(Bool redraw) {
}
switch (screen->getToolbarStyle()->font.justify) {
case Misc::Font::RIGHT:
case DrawUtil::Font::RIGHT:
dx += frame.workspace_label_w - l;
break;
case Misc::Font::CENTER:
case DrawUtil::Font::CENTER:
dx += (frame.workspace_label_w - l) / 2;
break;
default:

View file

@ -41,6 +41,7 @@
#include "Windowmenu.hh"
#include "Workspace.hh"
#include "misc.hh"
#include "StringUtil.hh"
#ifdef SLIT
# include "Slit.hh"
@ -1201,17 +1202,17 @@ void FluxboxWindow::getWMName(void) {
if ((XmbTextPropertyToTextList(display, &text_prop,
&list, &num) == Success) &&
(num > 0) && *list) {
client.title = Misc::strdup(*list);
client.title = StringUtil::strdup(*list);
XFreeStringList(list);
} else
client.title = Misc::strdup((char *) text_prop.value);
client.title = StringUtil::strdup((char *) text_prop.value);
} else
client.title = Misc::strdup((char *) text_prop.value);
client.title = StringUtil::strdup((char *) text_prop.value);
XFree((char *) text_prop.value);
} else
client.title = Misc::strdup(i18n->getMessage(
client.title = StringUtil::strdup(i18n->getMessage(
#ifdef NLS
WindowSet, WindowUnnamed,
#else // !NLS
@ -1219,7 +1220,7 @@ void FluxboxWindow::getWMName(void) {
#endif //
"Unnamed"));
} else {
client.title = Misc::strdup(i18n->getMessage(
client.title = StringUtil::strdup(i18n->getMessage(
#ifdef NLS
WindowSet, WindowUnnamed,
#else // !NLS
@ -1263,18 +1264,18 @@ void FluxboxWindow::getWMIconName(void) {
if ((XmbTextPropertyToTextList(display, &text_prop,
&list, &num) == Success) &&
(num > 0) && *list) {
client.icon_title = Misc::strdup(*list);
client.icon_title = StringUtil::strdup(*list);
XFreeStringList(list);
} else
client.icon_title = Misc::strdup((char *) text_prop.value);
client.icon_title = StringUtil::strdup((char *) text_prop.value);
} else
client.icon_title = Misc::strdup((char *) text_prop.value);
client.icon_title = StringUtil::strdup((char *) text_prop.value);
XFree((char *) text_prop.value);
} else
client.icon_title = Misc::strdup(client.title);
client.icon_title = StringUtil::strdup(client.title);
} else
client.icon_title = Misc::strdup(client.title);
client.icon_title = StringUtil::strdup(client.title);
}
@ -2416,7 +2417,7 @@ void FluxboxWindow::redrawLabel(void) {
GC gc = ((focused) ? screen->getWindowStyle()->l_text_focus_gc :
screen->getWindowStyle()->l_text_unfocus_gc);
Misc::DrawString(display, frame.label, gc,
DrawUtil::DrawString(display, frame.label, gc,
&screen->getWindowStyle()->font,
client.title_text_w, frame.label_w,
frame.bevel_w, client.title);

View file

@ -40,6 +40,7 @@
#include "Window.hh"
#include "Workspace.hh"
#include "Windowmenu.hh"
#include "StringUtil.hh"
#ifdef HAVE_STDIO_H
# include <stdio.h>
@ -49,10 +50,6 @@
# include <string.h>
#endif // STDC_HEADERS
#define MIN(x,y) ((x < y) ? x : y)
#define MAX(x,y) ((x > y) ? x : y)
Workspace::Workspace(BScreen *scrn, int i) {
screen = scrn;
@ -309,7 +306,7 @@ void Workspace::setName(char *new_name) {
delete [] name;
if (new_name) {
name = Misc::strdup(new_name);
name = StringUtil::strdup(new_name);
} else {
name = new char[128];
sprintf(name, I18n::instance()->

View file

@ -32,16 +32,6 @@
# include "../config.h"
#endif // HAVE_CONFIG_H
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/Xresource.h>
#include <X11/Xatom.h>
#include <X11/keysym.h>
#ifdef SHAPE
#include <X11/extensions/shape.h>
#endif // SHAPE
#include "i18n.hh"
#include "fluxbox.hh"
#include "Basemenu.hh"
@ -57,6 +47,18 @@
#include "Window.hh"
#include "Workspace.hh"
#include "Workspacemenu.hh"
#include "StringUtil.hh"
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/Xresource.h>
#include <X11/Xatom.h>
#include <X11/keysym.h>
#ifdef SHAPE
#include <X11/extensions/shape.h>
#endif // SHAPE
#ifdef HAVE_STDIO_H
# include <stdio.h>
@ -1699,7 +1701,7 @@ char *Fluxbox::getRcFilename() {
snprintf(dbfile, dbfile_size, "%s/.%s/%s", homedir, RC_PATH, RC_INIT_FILE);
} else
dbfile = Misc::strdup(rc_file);
dbfile = StringUtil::strdup(rc_file);
return dbfile;
}
@ -1731,9 +1733,9 @@ void Fluxbox::load_rc(void) {
if (XrmGetResource(database, "session.menuFile", "Session.MenuFile",
&value_type, &value)) {
resource.menu_file = Misc::expandFilename(value.addr); // expand ~ to $HOME
resource.menu_file = StringUtil::expandFilename(value.addr); // expand ~ to $HOME
} else
resource.menu_file = Misc::strdup(DEFAULTMENU);
resource.menu_file = StringUtil::strdup(DEFAULTMENU);
if (resource.titlebar_file) {
delete resource.titlebar_file;
@ -1743,9 +1745,9 @@ void Fluxbox::load_rc(void) {
//get titlebar filename
if (XrmGetResource(database, "session.titlebarFile", "Session.TitlebarFile",
&value_type, &value)) {
resource.titlebar_file = Misc::expandFilename(value.addr); //expand ~ to home
resource.titlebar_file = StringUtil::expandFilename(value.addr); //expand ~ to home
} else
resource.titlebar_file = Misc::strdup(DEFAULTTITLEBAR);
resource.titlebar_file = StringUtil::strdup(DEFAULTTITLEBAR);
//if already allocated memory for keys_file destroy it
if (resource.keys_file) {
@ -1756,9 +1758,9 @@ void Fluxbox::load_rc(void) {
//get keys filename
if (XrmGetResource(database, "session.keyFile", "Session.keyFile",
&value_type, &value)) {
resource.keys_file = Misc::expandFilename(value.addr); //expand ~ to home
resource.keys_file = StringUtil::expandFilename(value.addr); //expand ~ to home
} else
resource.keys_file = Misc::strdup(DEFAULTKEYSFILE);
resource.keys_file = StringUtil::strdup(DEFAULTKEYSFILE);
if (XrmGetResource(database, "session.iconbar", "Session.Iconbar",
@ -1797,9 +1799,9 @@ void Fluxbox::load_rc(void) {
if (XrmGetResource(database, "session.styleFile", "Session.StyleFile",
&value_type, &value))
resource.style_file = Misc::expandFilename(value.addr);
resource.style_file = StringUtil::expandFilename(value.addr);
else
resource.style_file = Misc::strdup(DEFAULTSTYLE);
resource.style_file = StringUtil::strdup(DEFAULTSTYLE);
if (resource.root_cmd) {
delete [] resource.root_cmd;
@ -1807,7 +1809,7 @@ void Fluxbox::load_rc(void) {
}
if (XrmGetResource(database, "session.rootCommand", "Session.RootCommand", &value_type, &value))
resource.root_cmd = Misc::expandFilename(value.addr);
resource.root_cmd = StringUtil::expandFilename(value.addr);
else
resource.root_cmd = 0;
@ -2058,7 +2060,7 @@ void Fluxbox::load_rc(BScreen *screen) {
sprintf(class_lookup, "Session.Screen%d.WorkspaceNames", screen_number);
if (XrmGetResource(database, name_lookup, class_lookup, &value_type,
&value)) {
char *search = Misc::strdup(value.addr);
char *search = StringUtil::strdup(value.addr);
int i;
for (i = 0; i < screen->getNumberOfWorkspaces(); i++) {
@ -2504,7 +2506,7 @@ void Fluxbox::saveStyleFilename(const char *filename) {
if (resource.style_file)
delete [] resource.style_file;
resource.style_file = Misc::strdup(filename);
resource.style_file = StringUtil::strdup(filename);
}
@ -2521,7 +2523,7 @@ void Fluxbox::saveMenuFilename(const char *filename) {
if (! stat(filename, &buf)) {
MenuTimestamp *ts = new MenuTimestamp;
ts->filename = Misc::strdup(filename);
ts->filename = StringUtil::strdup(filename);
ts->timestamp = buf.st_ctime;
menuTimestamps->insert(ts);