Alternative FOX styling
Over time various people have com up with ways to modify FOX to alter its default appearance. This
is often acheived by hand editing the FOX sources, with the markup described below. Alternatively,
the aim of the foXdesktop is to provide a generic set of applications which can be used to
customise the look and behaviour of FOX applications.
FOX appearance/behaviour modifications:
FOX 'cool look'
The 'cool look' provides a 'flat' appearance for various FOX widgets, ###
1. Remove FRAME_THICK from all control options (buttons, ...). Most of the time, it's
the constructor default, so you need to explicitly enter the options parameter.
2. Alternatively, if this is too complicated, just remove FRAME_THICK from the FRAME_MASK
in FXFrame.cpp:52, and FXPacker.cpp:59. Also, remove line 89
(border=(options&FRAME_THICK)...) from FXFrame.cpp.
3. Unlike all other controls, FXCheckButton and FXRadioButton are always painted with
a thick border. It would be nice if this could be turned off.
Anyway, to do it by hand just comment the following code out:
3.1. Comment out FXRadioButton.cpp, lines 284 - 288:
// dc.setForeground(borderColor);
// dc.drawArc(ix+1,iy+1,11,11,45*64,180*64);
// dc.setForeground(backColor);
// dc.drawArc(ix+1,iy+1,11,11,225*64,180*64);
3.2. Comment out FXCheckButton.cpp, lines 325 - 327 and 333 - 335 :
// dc.setForeground(borderColor);
// dc.drawLine(ix+1,iy+1,ix+10,iy+1);
// dc.drawLine(ix+1,iy+1,ix+1,iy+10);
dc.setForeground(hiliteColor);
dc.drawLine(ix,iy+12,ix+12,iy+12);
dc.drawLine(ix+12,iy+12,ix+12,iy);
// dc.setForeground(backColor);
// dc.drawLine(ix+2,iy+11,ix+11,iy+11);
// dc.drawLine(ix+11,iy+2,ix+11,iy+11);
3.3 Change FXCheckButton.cpp:336 from
dc.fillRectangle(ix+2,iy+2,9,9);
to
dc.fillRectangle(ix+1,iy+1,11,11);
4. That's all for the flat style. Now for the hoovering: in your app's main
window (derived from FXMainWindow), add two new member declarations:
long onEnter(FXObject*, FXSelector, void*);
long onLeave(FXObject*, FXSelector, void*);
5. In the file's body, add the following entry in the message map:
FXDEFMAP(MyMainWindow) MyMainWindowMap[]={
FXMAPTYPE(SEL_ENTER, MyMainWindow::onEnter),
FXMAPTYPE(SEL_LEAVE, MyMainWindow::onLeave),
... (other mappings) ...
}
6. Add the implementation:
long MyMainWindow::onEnter(FXObject* obj, FXSelector sel, void* ptr) {
FXMainWindow::onEnter(obj, sel, ptr);
if (obj->isMemberOf(FXMETACLASS(FXPacker))) {
((FXPacker*)obj)->setShadowColor(FXApp::instance()->borderColor);
}
else if (obj->isMemberOf(FXMETACLASS(FXFrame))) {
((FXFrame*)obj)->setShadowColor(FXApp::instance()->borderColor);
}
return 1;
}
long MyMainWindow::onLeave(FXObject* obj, FXSelector sel, void* ptr) {
FXMainWindow::onLeave(obj, sel, ptr);
if (obj->isMemberOf(FXMETACLASS(FXPacker))) {
((FXPacker*)obj)->setShadowColor(FXApp::instance()->shadowColor);
}
else if (obj->isMemberOf(FXMETACLASS(FXFrame))) {
((FXFrame*)obj)->setShadowColor(FXApp::instance()->shadowColor);
}
return 1;
}
7. That's all. This assumes that the main window is the target of all the
controls it contains. If you have other windows, or other targets, you will
have to add this for every window. Alternatively, implement the hoovering
directly in FXFrame, and in the FXPacker derived controls.
ToolTip justification
// Overwrite base class method to force center justification of tip text
long AFXTooltip::onPaint(FXObject *, FXSelector, void *ptr)
{
FXEvent *ev=(FXEvent*)ptr;
FXDCWindow dc(this,ev);
FXint tw=0;
const FXchar *beg,*end;
register FXint tx,ty,xx;
dc.setForeground(backColor);
dc.fillRectangle(ev->rect.x,ev->rect.y,ev->rect.w,ev->rect.h);
dc.setForeground(textColor);
dc.setTextFont(font);
dc.drawRectangle(0,0,width-1,height-1);
if(!label.empty())
tw=labelWidth(label);
beg=label.text();
if(beg)
{
tx=1+HSPACE;
ty=1+VSPACE+font->getFontAscent();
do
{
end=beg;
while(*end!='\0' && *end!='\n') end++;
xx=tx+(tw-font->getTextWidth(beg,end-beg))/2;
dc.drawText(xx,ty,beg,end-beg);
ty+=font->getFontHeight();
beg=end+1;
} while(*end!='\0');
}
return 1;
}
// Get width of multi-line label (from FXLabel)
FXint AFXTooltip::labelWidth(const FXString& text) const {
register FXuint beg,end;
register FXint w,tw=0;
beg=0;
do
{
end=beg;
while(text[end] && text[end]!='\n') end++;
if((w=font->getTextWidth(&text[beg],end-beg))>tw) tw=w;
beg=end+1;
} while(text[end]);
return tw;
}