Cleanup the XfeBm library. Remove circular dependancy on XfeBm from

XfeWidgets.
This commit is contained in:
ramiro 1998-06-01 07:49:21 +00:00
parent 1f2bdadab7
commit 4597448a01
13 changed files with 927 additions and 749 deletions

View File

@ -27,8 +27,6 @@
#include <Xfe/XfeP.h>
#include <Xfe/ManagerP.h>
#include <Xfe/CascadeP.h>
#include <Xfe/BmCascadeP.h>
#include <Xfe/BmButtonP.h>
#include <Xm/RowColumnP.h>
@ -361,385 +359,9 @@ XfeMenuItemPreviousItem(Widget item)
/*----------------------------------------------------------------------*/
/* */
/* Private accent functions. */
/* Menu type */
/* */
/*----------------------------------------------------------------------*/
#define ACCENT_DRAW 1
#define ACCENT_ERASE 2
static void AccentBottom (Widget,GC,GC,Dimension,Dimension,
Dimension,Dimension,int);
static void AccentAll (Widget,GC,GC,Dimension,Dimension,
Dimension,Dimension,int);
static void AccentTop (Widget,GC,GC,Dimension,Dimension,
Dimension,Dimension,int);
/*----------------------------------------------------------------------*/
/* */
/* Public accent drawing functions. */
/* */
/*----------------------------------------------------------------------*/
/* extern */ void
XfeMenuItemDrawAccent(Widget item,
unsigned char accent_type,
Dimension offset_left,
Dimension offset_right,
Dimension shadow_thickness,
Dimension accent_thickness)
{
Widget pw;
GC top_gc;
GC bottom_gc;
XGCValues values;
int top_subwindow_mode;
int bottom_subwindow_mode;
/* duh */
if (accent_type == XmACCENT_NONE)
{
return;
}
assert( _XfeIsAlive(item) );
assert( XmIsPushButton(item) || XmIsCascadeButton(item) );
pw = _XfeParent(item);
assert( XmIsRowColumn(pw) );
top_gc = _XfemTopShadowGC(pw);
bottom_gc = _XfemBottomShadowGC(pw);
/* Remember the old wubwindow mode values */
XGetGCValues(XtDisplay(item),top_gc,GCSubwindowMode,&values);
top_subwindow_mode = values.subwindow_mode;
XGetGCValues(XtDisplay(item),bottom_gc,GCSubwindowMode,&values);
bottom_subwindow_mode = values.subwindow_mode;
/* Force the subwindow mode to IncludeInferiors */
XSetSubwindowMode(XtDisplay(item),top_gc,IncludeInferiors);
XSetSubwindowMode(XtDisplay(item),bottom_gc,IncludeInferiors);
switch(accent_type)
{
case XmACCENT_BOTTOM:
AccentBottom(item,top_gc,bottom_gc,offset_left,offset_right,
shadow_thickness,accent_thickness,ACCENT_DRAW);
break;
case XmACCENT_ALL:
AccentAll(item,top_gc,bottom_gc,offset_left,offset_right,
shadow_thickness,accent_thickness,ACCENT_DRAW);
break;
case XmACCENT_TOP:
AccentTop(item,top_gc,bottom_gc,offset_left,offset_right,
shadow_thickness,accent_thickness,ACCENT_DRAW);
break;
default:
break;
}
/* Restore the old subwindow mode */
XSetSubwindowMode(XtDisplay(item),top_gc,top_subwindow_mode);
XSetSubwindowMode(XtDisplay(item),bottom_gc,bottom_subwindow_mode);
}
/*----------------------------------------------------------------------*/
/* extern */ void
XfeMenuItemEraseAccent(Widget item,
unsigned char accent_type,
Dimension offset_left,
Dimension offset_right,
Dimension shadow_thickness,
Dimension accent_thickness)
{
Widget pw;
GC gc;
XGCValues values;
int subwindow_mode;
/* duh */
if (accent_type == XmACCENT_NONE)
{
return;
}
assert( _XfeIsAlive(item) );
assert( XmIsPushButton(item) || XmIsCascadeButton(item) );
pw = _XfeParent(item);
assert( XmIsRowColumn(pw) );
gc = _XfemBackgroundGC(pw);
/* Remember the old wubwindow mode values */
XGetGCValues(XtDisplay(item),gc,GCSubwindowMode,&values);
subwindow_mode = values.subwindow_mode;
/* Force the subwindow mode to IncludeInferiors */
XSetSubwindowMode(XtDisplay(item),gc,IncludeInferiors);
switch(accent_type)
{
case XmACCENT_BOTTOM:
AccentBottom(item,gc,None,offset_left,offset_right,
shadow_thickness,accent_thickness,ACCENT_ERASE);
break;
case XmACCENT_ALL:
AccentAll(item,gc,None,offset_left,offset_right,
shadow_thickness,accent_thickness,ACCENT_ERASE);
break;
case XmACCENT_TOP:
AccentTop(item,gc,None,offset_left,offset_right,
shadow_thickness,accent_thickness,ACCENT_ERASE);
break;
default:
break;
}
/* Restore the old subwindow mode */
XSetSubwindowMode(XtDisplay(item),gc,subwindow_mode);
}
/*----------------------------------------------------------------------*/
/*----------------------------------------------------------------------*/
/* */
/* Private accent functions. */
/* */
/*----------------------------------------------------------------------*/
static void
AccentBottom(Widget w,
GC top_gc,
GC bottom_gc,
Dimension offset_left,
Dimension offset_right,
Dimension shadow_thickness,
Dimension accent_thickness,
int code)
{
Widget pw = _XfeParent(w);
int position_index = XfeMenuItemPositionIndex(w);
Cardinal num_children = _XfemNumChildren(pw);
Position x;
Position y;
Dimension width;
Dimension height = 2 * shadow_thickness + accent_thickness;
assert( code == ACCENT_DRAW || code == ACCENT_ERASE );
/* Last item */
if (position_index == (num_children - 1))
{
x = _XfeX(w) + offset_left;
y = _XfeY(w) + _XfeHeight(w) - height;
width = _XfeWidth(w) - offset_left - offset_right;
}
/* Any other item */
else
{
x = _XfeX(w) + offset_left;
y = _XfeY(w) + _XfeHeight(w) - height / 2;
width = _XfeWidth(w) - offset_left - offset_right;
}
if (code == ACCENT_DRAW)
{
/* Draw accent */
_XmDrawShadows(XtDisplay(pw),_XfeWindow(pw),top_gc,bottom_gc,
x,y,width,height,shadow_thickness,XmSHADOW_IN);
}
else
{
/* Erase accent */
XfeDrawRectangle(XtDisplay(pw),_XfeWindow(pw),top_gc,
x,y,width,height,shadow_thickness);
}
}
/*----------------------------------------------------------------------*/
static void
AccentTop(Widget w,
GC top_gc,
GC bottom_gc,
Dimension offset_left,
Dimension offset_right,
Dimension shadow_thickness,
Dimension accent_thickness,
int code)
{
Widget pw = _XfeParent(w);
int position_index = XfeMenuItemPositionIndex(w);
Position x;
Position y;
Dimension width;
Dimension height = 2 * shadow_thickness + accent_thickness;
assert( code == ACCENT_DRAW || code == ACCENT_ERASE );
/* First item */
if (position_index == 0)
{
x = _XfeX(w) + offset_left;
y = _XfeY(w);
width = _XfeWidth(w) - offset_left - offset_right;
}
/* Any other item */
else
{
x = _XfeX(w) + offset_left;
y = _XfeY(w) - height / 2;
width = _XfeWidth(w) - offset_left - offset_right;
}
if (code == ACCENT_DRAW)
{
/* Draw accent */
_XmDrawShadows(XtDisplay(pw),_XfeWindow(pw),top_gc,bottom_gc,
x,y,width,height,shadow_thickness,XmSHADOW_IN);
}
else
{
/* Erase accent */
XfeDrawRectangle(XtDisplay(pw),_XfeWindow(pw),top_gc,
x,y,width,height,shadow_thickness);
}
}
/*----------------------------------------------------------------------*/
static void
AccentAll(Widget w,
GC top_gc,
GC bottom_gc,
Dimension offset_left,
Dimension offset_right,
Dimension shadow_thickness,
Dimension accent_thickness,
int code)
{
#if 1
if (code == ACCENT_DRAW)
{
/* Draw accent */
_XmDrawShadows(XtDisplay(w),_XfeWindow(w),
top_gc,bottom_gc,
_XfeHighlightThickness(w),
_XfeHighlightThickness(w),
_XfeWidth(w) - 2 * _XfeHighlightThickness(w),
_XfeHeight(w) - 2 * _XfeHighlightThickness(w),
_XfeShadowThickness(w),
XmSHADOW_OUT);
}
else
{
/* Erase accent */
XfeDrawRectangle(XtDisplay(w),_XfeWindow(w),top_gc,
_XfeHighlightThickness(w),
_XfeHighlightThickness(w),
_XfeWidth(w) - 2 * _XfeHighlightThickness(w),
_XfeHeight(w) - 2 * _XfeHighlightThickness(w),
_XfeShadowThickness(w));
}
#else
Widget pw = _XfeParent(w);
int position_index = XfeMenuItemPositionIndex(w);
Cardinal num_children = _XfemNumChildren(pw);
Position x;
Position y;
Dimension width;
Dimension height;
Dimension total_thickness = shadow_thickness + accent_thickness;
assert( code == ACCENT_DRAW || code == ACCENT_ERASE );
/* One and only */
if (num_children == 1)
{
x = _XfeX(w) + offset_left;
y = _XfeY(w);
width = _XfeWidth(w) - offset_left - offset_right;
height = _XfeHeight(w);
}
else
{
Dimension overlap = (2 * shadow_thickness + accent_thickness) / 2;
/* First item */
if (position_index == 0)
{
x = _XfeX(w) + offset_left;
y = _XfeY(w);
width = _XfeWidth(w) - offset_left - offset_right;
height = _XfeHeight(w) + overlap;
}
/* Last item */
else if (position_index == (num_children - 1))
{
x = _XfeX(w) + offset_left;
y = _XfeY(w) - overlap;
width = _XfeWidth(w) - offset_left - offset_right;
height = _XfeHeight(w) + overlap;
}
/* In between two others */
else
{
x = _XfeX(w) + offset_left;
y = _XfeY(w) - overlap;
width = _XfeWidth(w) - offset_left - offset_right;
height = _XfeHeight(w) + 2 * total_thickness;
}
}
if (code == ACCENT_DRAW)
{
/* Draw accent */
_XmDrawShadows(XtDisplay(pw),_XfeWindow(pw),top_gc,bottom_gc,
x,y,width,height,shadow_thickness,XmSHADOW_IN);
x += total_thickness;
y += total_thickness;
width -= (2 * total_thickness);
height -= (2 * total_thickness);
_XmDrawShadows(XtDisplay(pw),_XfeWindow(pw),top_gc,bottom_gc,
x,y,width,height,shadow_thickness,XmSHADOW_OUT);
}
else
{
/* Erase accent */
XfeDrawRectangle(XtDisplay(pw),_XfeWindow(pw),top_gc,
x,y,width,height,shadow_thickness);
x += total_thickness;
y += total_thickness;
width -= (2 * total_thickness);
height -= (2 * total_thickness);
XfeDrawRectangle(XtDisplay(pw),_XfeWindow(pw),top_gc,
x,y,width,height,shadow_thickness);
}
#endif
}
/*----------------------------------------------------------------------*/
/* extern */ unsigned char
XfeMenuType(Widget menu)
{

View File

@ -93,28 +93,6 @@ XfeMenuItemNextItem (Widget item);
extern Widget
XfeMenuItemPreviousItem (Widget item);
/*----------------------------------------------------------------------*/
/* */
/* Public accent drawing functions. */
/* */
/*----------------------------------------------------------------------*/
extern void
XfeMenuItemDrawAccent (Widget item,
unsigned char accent_type,
Dimension offset_left,
Dimension offset_right,
Dimension shadow_thickness,
Dimension accent_thickness);
/*----------------------------------------------------------------------*/
extern void
XfeMenuItemEraseAccent (Widget item,
unsigned char accent_type,
Dimension offset_left,
Dimension offset_right,
Dimension shadow_thickness,
Dimension accent_thickness);
/*----------------------------------------------------------------------*/
/*----------------------------------------------------------------------*/
/* */
/* Display grabbed access. */

View File

@ -17,7 +17,7 @@
*/
/*-----------------------------------------*/
/* */
/* Name: <Xfe/RepType.h> */
/* Name: <Xfe/RepType.c> */
/* Description: Xfe widgets representation types source. */
/* Author: Ramiro Estrugo <ramiro@netscape.com> */
/* */
@ -49,8 +49,8 @@ XfeRepTypeCheck(Widget w,
return result;
}
/*----------------------------------------------------------------------*/
/* extern */ void
XfeRegisterBoxType()
static void
RegisterBoxType(void)
{
static String BoxNames[] =
{
@ -62,8 +62,8 @@ XfeRegisterBoxType()
XmRepTypeRegister(XmRBoxType,BoxNames,NULL,XtNumber(BoxNames));
}
/*----------------------------------------------------------------------*/
/* extern */ void
XfeRegisterButtonLayout()
static void
RegisterButtonLayout(void)
{
static String names[] =
{
@ -78,8 +78,8 @@ XfeRegisterButtonLayout()
XmRepTypeRegister(XmRButtonLayout,names,NULL,XtNumber(names));
}
/*----------------------------------------------------------------------*/
/* extern */ void
XfeRegisterButtonTrigger()
static void
RegisterButtonTrigger(void)
{
static String names[] =
{
@ -94,8 +94,8 @@ XfeRegisterButtonTrigger()
}
/*----------------------------------------------------------------------*/
#ifdef notused
/* extern */ void
XfeRegisterArrowType()
static void
RegisterArrowType(void)
{
static String ArrowNames[] =
{
@ -109,8 +109,8 @@ XfeRegisterArrowType()
}
/*----------------------------------------------------------------------*/
#endif
/* extern */ void
XfeRegisterBufferType()
static void
RegisterBufferType(void)
{
static String BufferNames[] =
{
@ -122,8 +122,8 @@ XfeRegisterBufferType()
XmRepTypeRegister(XmRBufferType,BufferNames,NULL,XtNumber(BufferNames));
}
/*----------------------------------------------------------------------*/
/* extern */ void
XfeRegisterButtonType()
static void
RegisterButtonType(void)
{
static String ButtonNames[] =
{
@ -135,21 +135,8 @@ XfeRegisterButtonType()
XmRepTypeRegister(XmRButtonType,ButtonNames,NULL,XtNumber(ButtonNames));
}
/*----------------------------------------------------------------------*/
/* extern */ void
XfeRegisterAccentType()
{
static String AccentNames[] =
{
"accent_box",
"accent_none",
"accent_underline",
};
XmRepTypeRegister(XmRAccentType,AccentNames,NULL,XtNumber(AccentNames));
}
/*----------------------------------------------------------------------*/
/* extern */ void
XfeRegisterRulesType()
static void
RegisterRulesType(void)
{
static String RulesNames[] =
{
@ -161,8 +148,8 @@ XfeRegisterRulesType()
XmRepTypeRegister(XmRRulesType,RulesNames,NULL,XtNumber(RulesNames));
}
/*----------------------------------------------------------------------*/
/* extern */ void
XfeRegisterLocationType()
static void
RegisterLocationType(void)
{
static String names[] =
{
@ -179,8 +166,8 @@ XfeRegisterLocationType()
XmRepTypeRegister(XmRLocationType,names,NULL,XtNumber(names));
}
/*----------------------------------------------------------------------*/
/* extern */ void
XfeRegisterComboBoxType()
static void
RegisterComboBoxType(void)
{
static String names[] =
{
@ -191,8 +178,8 @@ XfeRegisterComboBoxType()
XmRepTypeRegister(XmRComboBoxType,names,NULL,XtNumber(names));
}
/*----------------------------------------------------------------------*/
/* extern */ void
XfeRegisterToolScrollArrowPlacement()
static void
RegisterToolScrollArrowPlacement(void)
{
static String names[] =
{
@ -204,8 +191,8 @@ XfeRegisterToolScrollArrowPlacement()
XmRepTypeRegister(XmRToolScrollArrowPlacement,names,NULL,XtNumber(names));
}
/*----------------------------------------------------------------------*/
/* extern */ void
XfeRegisterPaneChildType()
static void
RegisterPaneChildType(void)
{
static String names[] =
{
@ -219,8 +206,8 @@ XfeRegisterPaneChildType()
XmRepTypeRegister(XmRPaneChildType,names,NULL,XtNumber(names));
}
/*----------------------------------------------------------------------*/
/* extern */ void
XfeRegisterPaneDragModeType()
static void
RegisterPaneDragModeType(void)
{
static String names[] =
{
@ -232,8 +219,8 @@ XfeRegisterPaneDragModeType()
XmRepTypeRegister(XmRPaneDragMode,names,NULL,XtNumber(names));
}
/*----------------------------------------------------------------------*/
/* extern */ void
XfeRegisterPaneChildAttachment()
static void
RegisterPaneChildAttachment(void)
{
static String names[] =
{
@ -247,8 +234,8 @@ XfeRegisterPaneChildAttachment()
XmRepTypeRegister(XmRPaneChildAttachment,names,NULL,XtNumber(names));
}
/*----------------------------------------------------------------------*/
/* extern */ void
XfeRegisterPaneSashType()
static void
RegisterPaneSashType(void)
{
static String names[] =
{
@ -262,8 +249,8 @@ XfeRegisterPaneSashType()
XmRepTypeRegister(XmRPaneSashType,names,NULL,XtNumber(names));
}
/*----------------------------------------------------------------------*/
/* extern */ void
XfeRegisterToolBarSelectionPolicy()
static void
RegisterToolBarSelectionPolicy(void)
{
static String names[] =
{
@ -275,8 +262,8 @@ XfeRegisterToolBarSelectionPolicy()
XmRepTypeRegister(XmRToolBarSelectionPolicy,names,NULL,XtNumber(names));
}
/*----------------------------------------------------------------------*/
/* extern */ void
XfeRegisterToolBarIndicatorLocation()
static void
RegisterToolBarIndicatorLocation(void)
{
static String names[] =
{
@ -289,8 +276,8 @@ XfeRegisterToolBarIndicatorLocation()
XmRepTypeRegister(XmRToolBarIndicatorLocation,names,NULL,XtNumber(names));
}
/*----------------------------------------------------------------------*/
/* extern */ void
XfeRegisterChromeChildType()
static void
RegisterChromeChildType(void)
{
static String names[] =
{
@ -309,25 +296,24 @@ XfeRegisterChromeChildType()
}
/*----------------------------------------------------------------------*/
/* extern */ void
XfeRegisterRepresentationTypes()
XfeRegisterRepresentationTypes(void)
{
XfeRegisterAccentType();
XfeRegisterBoxType();
XfeRegisterBufferType();
XfeRegisterButtonLayout();
XfeRegisterButtonTrigger();
XfeRegisterButtonType();
XfeRegisterChromeChildType();
XfeRegisterComboBoxType();
XfeRegisterLocationType();
XfeRegisterPaneChildAttachment();
XfeRegisterPaneChildType();
XfeRegisterPaneDragModeType();
XfeRegisterPaneSashType();
XfeRegisterRulesType();
XfeRegisterToolBarIndicatorLocation();
XfeRegisterToolBarSelectionPolicy();
XfeRegisterToolScrollArrowPlacement();
RegisterBoxType();
RegisterBufferType();
RegisterButtonLayout();
RegisterButtonTrigger();
RegisterButtonType();
RegisterChromeChildType();
RegisterComboBoxType();
RegisterLocationType();
RegisterPaneChildAttachment();
RegisterPaneChildType();
RegisterPaneDragModeType();
RegisterPaneSashType();
RegisterRulesType();
RegisterToolBarIndicatorLocation();
RegisterToolBarSelectionPolicy();
RegisterToolScrollArrowPlacement();
/* XfeRegisterArrowType(); */
}

View File

@ -39,33 +39,13 @@ extern "C" {
/* */
/*----------------------------------------------------------------------*/
extern Boolean
XfeRepTypeCheck (Widget w,
String rep_type,
unsigned char * address,
unsigned char fallback);
XfeRepTypeCheck (Widget w,
String rep_type,
unsigned char * address,
unsigned char fallback);
/*----------------------------------------------------------------------*/
extern void XfeRegisterAccentType (void);
extern void XfeRegisterArrowType (void);
extern void XfeRegisterBmSelectionType (void);
extern void XfeRegisterBoxType (void);
extern void XfeRegisterBufferType (void);
extern void XfeRegisterButtonLayout (void);
extern void XfeRegisterButtonTrigger (void);
extern void XfeRegisterButtonType (void);
extern void XfeRegisterChromeChildType (void);
extern void XfeRegisterComboBoxType (void);
extern void XfeRegisterLocationType (void);
extern void XfeRegisterPaneChildAttachment (void);
extern void XfeRegisterPaneChildType (void);
extern void XfeRegisterPaneDragModeType (void);
extern void XfeRegisterPaneSashType (void);
extern void XfeRegisterRulesType (void);
extern void XfeRegisterToolBarIndicatorLocation (void);
extern void XfeRegisterToolBarSelectionPolicy (void);
extern void XfeRegisterToolScrollArrowPlacement (void);
/*----------------------------------------------------------------------*/
extern void XfeRegisterRepresentationTypes (void);
extern void
XfeRegisterRepresentationTypes (void);
/*----------------------------------------------------------------------*/
#ifdef __cplusplus /* end C++ */

View File

@ -77,7 +77,6 @@
/* Resource Names */
/* */
/*----------------------------------------------------------------------*/
#define XmNaccentType "accentType"
#define XmNactionButton "actionButton"
#define XmNactionCursor "actionCursor"
#define XmNactionPixmap "actionPixmap"
@ -93,7 +92,6 @@
#define XmNanimationRunning "animationRunning"
#define XmNarmBackground "armBackground"
#define XmNarmOffset "armOffset"
#define XmNarmPixmapMask "armPixmapMask"
#define XmNarmed "armed"
#define XmNarmedPixmap "armedPixmap"
#define XmNarmedPixmapMask "armedPixmapMask"
@ -197,7 +195,6 @@
#define XmNitemList "itemList"
#define XmNlabelAlignment "labelAlignment"
#define XmNlabelDirection "labelDirection"
#define XmNlabelPixmapMask "labelPixmapMask"
#define XmNlayableChildren "layableChildren"
#define XmNleftPixmap "leftPixmap"
#define XmNleftRaisedPixmap "leftRaisedPixmap"
@ -308,7 +305,6 @@
/* Class Names */
/* */
/*----------------------------------------------------------------------*/
#define XmCAccentType "AccentType"
#define XmCActionPixmap "ActionPixmap"
#define XmCActive "Active"
#define XmCActiveButton "ActiveButton"
@ -317,7 +313,6 @@
#define XmCAnimationPixmaps "AnimationPixmaps"
#define XmCArmBackground "ArmBackground"
#define XmCArmOffset "ArmOffset"
#define XmCArmPixmapMask "ArmPixmapMask"
#define XmCArmed "Armed"
#define XmCArmedPixmap "ArmedPixmap"
#define XmCArmedPixmapMask "ArmedPixmapMask"
@ -401,7 +396,6 @@
#define XmCItemForeground "ItemForeground"
#define XmCLabelAlignment "LabelAlignment"
#define XmCLabelDirection "LabelDirection"
#define XmCLabelPixmapMask "LabelPixmapMask"
#define XmCLayableChildren "LayableChildren"
#define XmCLeftPixmap "LeftPixmap"
#define XmCLeftRaisedPixmap "LeftRaisedPixmap"
@ -483,7 +477,6 @@
/* Representation Types */
/* */
/*----------------------------------------------------------------------*/
#define XmRAccentType "AccentType"
#define XmRArrowDisplayPolicy XmRScrollBarDisplayPolicy
#define XmRBoxType "BoxType"
#define XmRBufferType "BufferType"

View File

@ -0,0 +1,418 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
/*----------------------------------------------------------------------*/
/* */
/* Name: <XfeBm/BmAccent.c> */
/* */
/* Description: Functions for drawing accents on push and cascade */
/* buttons. Button accents are used to give feedback by */
/* the bookmark filing mechanism in mozilla. */
/* */
/* Author: Ramiro Estrugo <ramiro@netscape.com> */
/* */
/*----------------------------------------------------------------------*/
#include <Xfe/XfeP.h>
#include <Xfe/BmCascadeP.h>
#include <Xfe/BmButtonP.h>
#include <Xfe/ManagerP.h>
/*----------------------------------------------------------------------*/
/* */
/* Private accent functions. */
/* */
/*----------------------------------------------------------------------*/
#define ACCENT_DRAW 1
#define ACCENT_ERASE 2
static void AccentBottom (Widget,GC,GC,Dimension,Dimension,
Dimension,Dimension,int);
static void AccentAll (Widget,GC,GC,Dimension,Dimension,
Dimension,Dimension,int);
static void AccentTop (Widget,GC,GC,Dimension,Dimension,
Dimension,Dimension,int);
/*----------------------------------------------------------------------*/
/* */
/* Public accent drawing functions. */
/* */
/*----------------------------------------------------------------------*/
/* extern */ void
XfeMenuItemDrawAccent(Widget item,
unsigned char accent_type,
Dimension offset_left,
Dimension offset_right,
Dimension shadow_thickness,
Dimension accent_thickness)
{
Widget pw;
GC top_gc;
GC bottom_gc;
XGCValues values;
int top_subwindow_mode;
int bottom_subwindow_mode;
/* duh */
if (accent_type == XmACCENT_NONE)
{
return;
}
assert( _XfeIsAlive(item) );
assert( XmIsPushButton(item) || XmIsCascadeButton(item) );
pw = _XfeParent(item);
assert( XmIsRowColumn(pw) );
top_gc = _XfemTopShadowGC(pw);
bottom_gc = _XfemBottomShadowGC(pw);
/* Remember the old wubwindow mode values */
XGetGCValues(XtDisplay(item),top_gc,GCSubwindowMode,&values);
top_subwindow_mode = values.subwindow_mode;
XGetGCValues(XtDisplay(item),bottom_gc,GCSubwindowMode,&values);
bottom_subwindow_mode = values.subwindow_mode;
/* Force the subwindow mode to IncludeInferiors */
XSetSubwindowMode(XtDisplay(item),top_gc,IncludeInferiors);
XSetSubwindowMode(XtDisplay(item),bottom_gc,IncludeInferiors);
switch(accent_type)
{
case XmACCENT_BOTTOM:
AccentBottom(item,top_gc,bottom_gc,offset_left,offset_right,
shadow_thickness,accent_thickness,ACCENT_DRAW);
break;
case XmACCENT_ALL:
AccentAll(item,top_gc,bottom_gc,offset_left,offset_right,
shadow_thickness,accent_thickness,ACCENT_DRAW);
break;
case XmACCENT_TOP:
AccentTop(item,top_gc,bottom_gc,offset_left,offset_right,
shadow_thickness,accent_thickness,ACCENT_DRAW);
break;
default:
break;
}
/* Restore the old subwindow mode */
XSetSubwindowMode(XtDisplay(item),top_gc,top_subwindow_mode);
XSetSubwindowMode(XtDisplay(item),bottom_gc,bottom_subwindow_mode);
}
/*----------------------------------------------------------------------*/
/* extern */ void
XfeMenuItemEraseAccent(Widget item,
unsigned char accent_type,
Dimension offset_left,
Dimension offset_right,
Dimension shadow_thickness,
Dimension accent_thickness)
{
Widget pw;
GC gc;
XGCValues values;
int subwindow_mode;
/* duh */
if (accent_type == XmACCENT_NONE)
{
return;
}
assert( _XfeIsAlive(item) );
assert( XmIsPushButton(item) || XmIsCascadeButton(item) );
pw = _XfeParent(item);
assert( XmIsRowColumn(pw) );
gc = _XfemBackgroundGC(pw);
/* Remember the old wubwindow mode values */
XGetGCValues(XtDisplay(item),gc,GCSubwindowMode,&values);
subwindow_mode = values.subwindow_mode;
/* Force the subwindow mode to IncludeInferiors */
XSetSubwindowMode(XtDisplay(item),gc,IncludeInferiors);
switch(accent_type)
{
case XmACCENT_BOTTOM:
AccentBottom(item,gc,None,offset_left,offset_right,
shadow_thickness,accent_thickness,ACCENT_ERASE);
break;
case XmACCENT_ALL:
AccentAll(item,gc,None,offset_left,offset_right,
shadow_thickness,accent_thickness,ACCENT_ERASE);
break;
case XmACCENT_TOP:
AccentTop(item,gc,None,offset_left,offset_right,
shadow_thickness,accent_thickness,ACCENT_ERASE);
break;
default:
break;
}
/* Restore the old subwindow mode */
XSetSubwindowMode(XtDisplay(item),gc,subwindow_mode);
}
/*----------------------------------------------------------------------*/
/*----------------------------------------------------------------------*/
/* */
/* Private accent functions. */
/* */
/*----------------------------------------------------------------------*/
static void
AccentBottom(Widget w,
GC top_gc,
GC bottom_gc,
Dimension offset_left,
Dimension offset_right,
Dimension shadow_thickness,
Dimension accent_thickness,
int code)
{
Widget pw = _XfeParent(w);
int position_index = XfeMenuItemPositionIndex(w);
Cardinal num_children = _XfemNumChildren(pw);
Position x;
Position y;
Dimension width;
Dimension height = 2 * shadow_thickness + accent_thickness;
assert( code == ACCENT_DRAW || code == ACCENT_ERASE );
/* Last item */
if (position_index == (num_children - 1))
{
x = _XfeX(w) + offset_left;
y = _XfeY(w) + _XfeHeight(w) - height;
width = _XfeWidth(w) - offset_left - offset_right;
}
/* Any other item */
else
{
x = _XfeX(w) + offset_left;
y = _XfeY(w) + _XfeHeight(w) - height / 2;
width = _XfeWidth(w) - offset_left - offset_right;
}
if (code == ACCENT_DRAW)
{
/* Draw accent */
_XmDrawShadows(XtDisplay(pw),_XfeWindow(pw),top_gc,bottom_gc,
x,y,width,height,shadow_thickness,XmSHADOW_IN);
}
else
{
/* Erase accent */
XfeDrawRectangle(XtDisplay(pw),_XfeWindow(pw),top_gc,
x,y,width,height,shadow_thickness);
}
}
/*----------------------------------------------------------------------*/
static void
AccentTop(Widget w,
GC top_gc,
GC bottom_gc,
Dimension offset_left,
Dimension offset_right,
Dimension shadow_thickness,
Dimension accent_thickness,
int code)
{
Widget pw = _XfeParent(w);
int position_index = XfeMenuItemPositionIndex(w);
Position x;
Position y;
Dimension width;
Dimension height = 2 * shadow_thickness + accent_thickness;
assert( code == ACCENT_DRAW || code == ACCENT_ERASE );
/* First item */
if (position_index == 0)
{
x = _XfeX(w) + offset_left;
y = _XfeY(w);
width = _XfeWidth(w) - offset_left - offset_right;
}
/* Any other item */
else
{
x = _XfeX(w) + offset_left;
y = _XfeY(w) - height / 2;
width = _XfeWidth(w) - offset_left - offset_right;
}
if (code == ACCENT_DRAW)
{
/* Draw accent */
_XmDrawShadows(XtDisplay(pw),_XfeWindow(pw),top_gc,bottom_gc,
x,y,width,height,shadow_thickness,XmSHADOW_IN);
}
else
{
/* Erase accent */
XfeDrawRectangle(XtDisplay(pw),_XfeWindow(pw),top_gc,
x,y,width,height,shadow_thickness);
}
}
/*----------------------------------------------------------------------*/
static void
AccentAll(Widget w,
GC top_gc,
GC bottom_gc,
Dimension offset_left,
Dimension offset_right,
Dimension shadow_thickness,
Dimension accent_thickness,
int code)
{
#if 1
if (code == ACCENT_DRAW)
{
/* Draw accent */
_XmDrawShadows(XtDisplay(w),_XfeWindow(w),
top_gc,bottom_gc,
_XfeHighlightThickness(w),
_XfeHighlightThickness(w),
_XfeWidth(w) - 2 * _XfeHighlightThickness(w),
_XfeHeight(w) - 2 * _XfeHighlightThickness(w),
_XfeShadowThickness(w),
XmSHADOW_OUT);
}
else
{
/* Erase accent */
XfeDrawRectangle(XtDisplay(w),_XfeWindow(w),top_gc,
_XfeHighlightThickness(w),
_XfeHighlightThickness(w),
_XfeWidth(w) - 2 * _XfeHighlightThickness(w),
_XfeHeight(w) - 2 * _XfeHighlightThickness(w),
_XfeShadowThickness(w));
}
#else
Widget pw = _XfeParent(w);
int position_index = XfeMenuItemPositionIndex(w);
Cardinal num_children = _XfemNumChildren(pw);
Position x;
Position y;
Dimension width;
Dimension height;
Dimension total_thickness = shadow_thickness + accent_thickness;
assert( code == ACCENT_DRAW || code == ACCENT_ERASE );
/* One and only */
if (num_children == 1)
{
x = _XfeX(w) + offset_left;
y = _XfeY(w);
width = _XfeWidth(w) - offset_left - offset_right;
height = _XfeHeight(w);
}
else
{
Dimension overlap = (2 * shadow_thickness + accent_thickness) / 2;
/* First item */
if (position_index == 0)
{
x = _XfeX(w) + offset_left;
y = _XfeY(w);
width = _XfeWidth(w) - offset_left - offset_right;
height = _XfeHeight(w) + overlap;
}
/* Last item */
else if (position_index == (num_children - 1))
{
x = _XfeX(w) + offset_left;
y = _XfeY(w) - overlap;
width = _XfeWidth(w) - offset_left - offset_right;
height = _XfeHeight(w) + overlap;
}
/* In between two others */
else
{
x = _XfeX(w) + offset_left;
y = _XfeY(w) - overlap;
width = _XfeWidth(w) - offset_left - offset_right;
height = _XfeHeight(w) + 2 * total_thickness;
}
}
if (code == ACCENT_DRAW)
{
/* Draw accent */
_XmDrawShadows(XtDisplay(pw),_XfeWindow(pw),top_gc,bottom_gc,
x,y,width,height,shadow_thickness,XmSHADOW_IN);
x += total_thickness;
y += total_thickness;
width -= (2 * total_thickness);
height -= (2 * total_thickness);
_XmDrawShadows(XtDisplay(pw),_XfeWindow(pw),top_gc,bottom_gc,
x,y,width,height,shadow_thickness,XmSHADOW_OUT);
}
else
{
/* Erase accent */
XfeDrawRectangle(XtDisplay(pw),_XfeWindow(pw),top_gc,
x,y,width,height,shadow_thickness);
x += total_thickness;
y += total_thickness;
width -= (2 * total_thickness);
height -= (2 * total_thickness);
XfeDrawRectangle(XtDisplay(pw),_XfeWindow(pw),top_gc,
x,y,width,height,shadow_thickness);
}
#endif
}
/*----------------------------------------------------------------------*/

View File

@ -15,15 +15,15 @@
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
/*-----------------------------------------*/
/*----------------------------------------------------------------------*/
/* */
/* Name: <Xfe/BmButton.c> */
/* Name: <XfeBm/BmButton.c> */
/* Description: XfeBmButton widget source. */
/* Author: Ramiro Estrugo <ramiro@netscape.com> */
/* */
/*----------------------------------------------------------------------*/
#include <Xfe/BmButtonP.h>
#include <Xfe/ManagerP.h>
#include <Xfe/BmCascade.h>
@ -43,6 +43,7 @@
/* Core Class methods */
/* */
/*----------------------------------------------------------------------*/
static void ClassInitialize ();
static void Initialize (Widget,Widget,ArgList,Cardinal *);
static void Destroy (Widget);
static void Resize (Widget);
@ -194,7 +195,7 @@ _XFE_WIDGET_CLASS_RECORD(bmbutton,BmButton) =
(WidgetClass) &xmPushButtonClassRec, /* superclass */
"XfeBmButton", /* class_name */
sizeof(XfeBmButtonRec), /* widget_size */
NULL, /* class_initialize */
ClassInitialize, /* class_initialize */
NULL, /* class_part_initialize*/
FALSE, /* class_inited */
Initialize, /* initialize */
@ -268,6 +269,13 @@ _XFE_WIDGET_CLASS(bmbutton,BmButton);
/* */
/*----------------------------------------------------------------------*/
static void
ClassInitialize()
{
/* Register Bm Representation Types */
XfeBmRegisterRepresentationTypes();
}
/*----------------------------------------------------------------------*/
static void
Initialize(Widget rw,Widget nw,ArgList args,Cardinal *nargs)
{
XfeBmButtonPart * bmp = _XfeBmButtonPart(nw);
@ -446,7 +454,7 @@ SetValues(Widget ow,Widget rw,Widget nw,ArgList args,Cardinal *nargs)
static void
BorderHighlight(Widget w)
{
XfeBmButtonPart * bmp = _XfeBmButtonPart(w);
/* XfeBmButtonPart * bmp = _XfeBmButtonPart(w); */
XmPushButtonWidgetClass pwc =
(XmPushButtonWidgetClass) xmPushButtonWidgetClass;
@ -465,7 +473,7 @@ BorderHighlight(Widget w)
static void
BorderUnhighlight(Widget w)
{
XfeBmButtonPart * bmp = _XfeBmButtonPart(w);
/* XfeBmButtonPart * bmp = _XfeBmButtonPart(w); */
XmPushButtonWidgetClass pwc =
(XmPushButtonWidgetClass) xmPushButtonWidgetClass;
@ -492,7 +500,7 @@ static void
Enter(Widget w,XEvent * event,char ** params,Cardinal * nparams)
{
static XtActionProc enter_action = NULL;
XfeBmButtonPart * bmp = _XfeBmButtonPart(w);
/* XfeBmButtonPart * bmp = _XfeBmButtonPart(w); */
if (!enter_action)
{
@ -523,7 +531,7 @@ Enter(Widget w,XEvent * event,char ** params,Cardinal * nparams)
static void
Leave(Widget w,XEvent * event,char ** params,Cardinal * nparams)
{
XfeBmButtonPart * bmp = _XfeBmButtonPart(w);
/* XfeBmButtonPart * bmp = _XfeBmButtonPart(w); */
static XtActionProc leave_action = NULL;
if (!leave_action)
@ -555,7 +563,7 @@ Leave(Widget w,XEvent * event,char ** params,Cardinal * nparams)
static void
Motion(Widget w,XEvent * event,char ** params,Cardinal * nparams)
{
XfeBmButtonPart * bmp = _XfeBmButtonPart(w);
/* XfeBmButtonPart * bmp = _XfeBmButtonPart(w); */
if (!XfeBmAccentIsEnabled())
{
@ -569,7 +577,7 @@ static void
BtnDown(Widget w,XEvent * event,char ** params,Cardinal * nparams)
{
static XtActionProc btn_down_action = NULL;
XfeBmButtonPart * bmp = _XfeBmButtonPart(w);
/* XfeBmButtonPart * bmp = _XfeBmButtonPart(w); */
if (!btn_down_action)
{
@ -592,7 +600,7 @@ static void
BtnUp(Widget w,XEvent * event,char ** params,Cardinal * nparams)
{
static XtActionProc btn_up_action = NULL;
XfeBmButtonPart * bmp = _XfeBmButtonPart(w);
/* XfeBmButtonPart * bmp = _XfeBmButtonPart(w); */
if (!btn_up_action)
{
@ -816,128 +824,3 @@ XfeCreateBmButton(Widget pw,char * name,Arg * av,Cardinal ac)
return XtCreateWidget(name,xfeBmButtonWidgetClass,pw,av,ac);
}
/*----------------------------------------------------------------------*/
/*----------------------------------------------------------------------*/
/* */
/* Accent enabled/disabled functions */
/* */
/*----------------------------------------------------------------------*/
static Boolean _accent_is_enabled = False;
/* extern */ Boolean
XfeBmAccentIsEnabled(void)
{
return _accent_is_enabled;
}
/*----------------------------------------------------------------------*/
/* extern */ void
XfeBmAccentDisable(void)
{
_accent_is_enabled = False;
}
/*----------------------------------------------------------------------*/
/* extern */ void
XfeBmAccentEnable(void)
{
_accent_is_enabled = True;
}
/*----------------------------------------------------------------------*/
/*----------------------------------------------------------------------*/
/* */
/* Global BmButton/BmCascade accent offset values set/get functions */
/* */
/*----------------------------------------------------------------------*/
static Dimension _accent_offset_left = 4;
static Dimension _accent_offset_right = 8;
static Dimension _accent_shadow_thickness = 1;
static Dimension _accent_thickness = 1;
/* extern */ void
XfeBmAccentSetOffsetLeft(Dimension offset_left)
{
_accent_offset_left = offset_left;
}
/*----------------------------------------------------------------------*/
/* extern */ void
XfeBmAccentSetOffsetRight(Dimension offset_right)
{
_accent_offset_right = offset_right;
}
/*----------------------------------------------------------------------*/
/* extern */ void
XfeBmAccentSetShadowThickness(Dimension shadow_thickness)
{
_accent_shadow_thickness = shadow_thickness;
}
/*----------------------------------------------------------------------*/
/* extern */ void
XfeBmAccentSetThickness(Dimension thickness)
{
_accent_thickness = thickness;
}
/*----------------------------------------------------------------------*/
/* extern */ Dimension
XfeBmAccentGetOffsetLeft(void)
{
return _accent_offset_left;
}
/*----------------------------------------------------------------------*/
/* extern */ Dimension
XfeBmAccentGetOffsetRight(void)
{
return _accent_offset_right;
}
/*----------------------------------------------------------------------*/
/* extern */ Dimension
XfeBmAccentGetShadowThickness(void)
{
return _accent_shadow_thickness;
}
/*----------------------------------------------------------------------*/
/* extern */ Dimension
XfeBmAccentGetThickness(void)
{
return _accent_thickness;
}
/*----------------------------------------------------------------------*/
/*----------------------------------------------------------------------*/
/* */
/* Global BmButton/BmCascade accent filing mode. */
/* */
/*----------------------------------------------------------------------*/
static XfeAccentFileMode _accent_file_mode = XmACCENT_FILE_ANYWHERE;
/* extern */ void
XfeBmAccentSetFileMode(XfeAccentFileMode file_mode)
{
_accent_file_mode = file_mode;
}
/*----------------------------------------------------------------------*/
/* extern */ XfeAccentFileMode
XfeBmAccentGetFileMode(void)
{
return _accent_file_mode;
}
/*----------------------------------------------------------------------*/
/*----------------------------------------------------------------------*/
/* */
/* Global BmButton/BmCascade pixmap offset values set/get functions */
/* */
/*----------------------------------------------------------------------*/
static Dimension _pixmap_offset = 4;
/* extern */ void
XfeBmPixmapSetOffset(Dimension offset)
{
_pixmap_offset = offset;
}
/*----------------------------------------------------------------------*/
/* extern */ Dimension
XfeBmPixmapGetOffset(void)
{
return _pixmap_offset;
}
/*----------------------------------------------------------------------*/

View File

@ -27,38 +27,12 @@
#ifndef _XfeBmButton_h_ /* start BmButton.h */
#define _XfeBmButton_h_
#include <Xfe/Xfe.h>
#include <Xfe/XfeBm.h>
#ifdef __cplusplus /* start C++ */
extern "C" {
#endif
/*----------------------------------------------------------------------*/
/* */
/* XmRAccentType */
/* */
/*----------------------------------------------------------------------*/
enum
{
XmACCENT_NONE,
XmACCENT_BOTTOM,
XmACCENT_TOP,
XmACCENT_ALL
};
/*----------------------------------------------------------------------*/
/*----------------------------------------------------------------------*/
/* */
/* Accent filing mode */
/* */
/*----------------------------------------------------------------------*/
typedef enum
{
XmACCENT_FILE_ANYWHERE,
XmACCENT_FILE_SELF
} XfeAccentFileMode;
/*----------------------------------------------------------------------*/
/*----------------------------------------------------------------------*/
/* */
/* XfeBmButton class names */
@ -88,82 +62,8 @@ XfeCreateBmButton (Widget parent,
Cardinal count);
/*----------------------------------------------------------------------*/
/*----------------------------------------------------------------------*/
/* */
/* Accent enabled/disabled functions */
/* */
/*----------------------------------------------------------------------*/
extern void
XfeBmAccentDisable (void);
/*----------------------------------------------------------------------*/
extern void
XfeBmAccentEnable (void);
/*----------------------------------------------------------------------*/
extern Boolean
XfeBmAccentIsEnabled (void);
/*----------------------------------------------------------------------*/
/*----------------------------------------------------------------------*/
/* */
/* Global BmButton/BmCascade accent offset values set/get functions */
/* */
/*----------------------------------------------------------------------*/
extern void
XfeBmAccentSetOffsetLeft (Dimension offset_left);
/*----------------------------------------------------------------------*/
extern void
XfeBmAccentSetOffsetRight (Dimension offset_right);
/*----------------------------------------------------------------------*/
extern void
XfeBmAccentSetShadowThickness (Dimension shadow_thickness);
/*----------------------------------------------------------------------*/
extern void
XfeBmAccentSetThickness (Dimension thickness);
/*----------------------------------------------------------------------*/
extern Dimension
XfeBmAccentGetOffsetLeft (void);
/*----------------------------------------------------------------------*/
extern Dimension
XfeBmAccentGetOffsetRight (void);
/*----------------------------------------------------------------------*/
extern Dimension
XfeBmAccentGetShadowThickness (void);
/*----------------------------------------------------------------------*/
extern Dimension
XfeBmAccentGetThickness (void);
/*----------------------------------------------------------------------*/
/*----------------------------------------------------------------------*/
/* */
/* Global BmButton/BmCascade accent filing mode. */
/* */
/*----------------------------------------------------------------------*/
extern void
XfeBmAccentSetFileMode (XfeAccentFileMode file_mode);
/*----------------------------------------------------------------------*/
extern XfeAccentFileMode
XfeBmAccentGetFileMode (void);
/*----------------------------------------------------------------------*/
/*----------------------------------------------------------------------*/
/* */
/* Global BmButton/BmCascade pixmap offset values set/get functions */
/* */
/*----------------------------------------------------------------------*/
extern void
XfeBmPixmapSetOffset (Dimension offset_lefft);
/*----------------------------------------------------------------------*/
extern Dimension
XfeBmPixmapGetOffset (void);
/*----------------------------------------------------------------------*/
#ifdef __cplusplus /* end C++ */
}
#endif
#endif /* end BmPushB.h */
#endif /* end BmButton.h */

View File

@ -15,15 +15,15 @@
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
/*-----------------------------------------*/
/*----------------------------------------------------------------------*/
/* */
/* Name: <Xfe/BmCascade.c> */
/* Name: <XfeBm/BmCascade.c> */
/* Description: XfeBmCascade widget source. */
/* Author: Ramiro Estrugo <ramiro@netscape.com> */
/* */
/*----------------------------------------------------------------------*/
#include <Xfe/BmCascadeP.h>
#include <Xfe/BmButtonP.h>
#include <Xfe/Cascade.h>
@ -47,6 +47,7 @@
/* Core Class methods */
/* */
/*----------------------------------------------------------------------*/
static void ClassInitialize ();
static void Initialize (Widget,Widget,ArgList,Cardinal *);
static void Destroy (Widget);
static void Resize (Widget);
@ -81,7 +82,10 @@ static void Motion (Widget,XEvent *,char **,Cardinal *);
/* */
/*----------------------------------------------------------------------*/
static void DrawPixmap (Widget,XEvent *,Region);
#ifdef notused
static Position GetPointerY (Widget);
#endif
static void AccentUpdate (Widget,Position);
static void AccentDraw (Widget);
@ -206,7 +210,7 @@ _XFE_WIDGET_CLASS_RECORD(bmcascade,BmCascade) =
(WidgetClass) &xmCascadeButtonClassRec, /* superclass */
"XfeBmCascade", /* class_name */
sizeof(XfeBmCascadeRec), /* widget_size */
NULL, /* class_initialize */
ClassInitialize, /* class_initialize */
NULL, /* class_part_initialize*/
FALSE, /* class_inited */
Initialize, /* initialize */
@ -280,6 +284,13 @@ _XFE_WIDGET_CLASS(bmcascade,BmCascade);
/* */
/*----------------------------------------------------------------------*/
static void
ClassInitialize()
{
/* Register Bm Representation Types */
XfeBmRegisterRepresentationTypes();
}
/*----------------------------------------------------------------------*/
static void
Initialize(Widget rw,Widget nw,ArgList args,Cardinal *nargs)
{
XfeBmCascadePart * bmc = _XfeBmCascadePart(nw);
@ -394,8 +405,8 @@ SetValues(Widget ow,Widget rw,Widget nw,ArgList args,Cardinal *nargs)
{
Boolean redisplay = False;
Boolean resize = False;
XmCascadeButtonPart * old_cp = _XfeXmCascadeButtonPart(ow);
XmCascadeButtonPart * new_cp = _XfeXmCascadeButtonPart(nw);
/* XmCascadeButtonPart * old_cp = _XfeXmCascadeButtonPart(ow); */
/* XmCascadeButtonPart * new_cp = _XfeXmCascadeButtonPart(nw); */
XmLabelPart * old_lp = _XfeXmLabelPart(ow);
XmLabelPart * new_lp = _XfeXmLabelPart(nw);
XfeBmCascadePart * new_bmc = _XfeBmCascadePart(nw);
@ -458,7 +469,7 @@ SetValues(Widget ow,Widget rw,Widget nw,ArgList args,Cardinal *nargs)
static void
BorderHighlight(Widget w)
{
XfeBmCascadePart * bmc = _XfeBmCascadePart(w);
/* XfeBmCascadePart * bmc = _XfeBmCascadePart(w); */
XmCascadeButtonWidgetClass cwc =
(XmCascadeButtonWidgetClass) xmCascadeButtonWidgetClass;
@ -477,7 +488,7 @@ BorderHighlight(Widget w)
static void
BorderUnhighlight(Widget w)
{
XfeBmCascadePart * bmc = _XfeBmCascadePart(w);
/* XfeBmCascadePart * bmc = _XfeBmCascadePart(w); */
XmCascadeButtonWidgetClass cwc =
(XmCascadeButtonWidgetClass) xmCascadeButtonWidgetClass;
@ -503,7 +514,7 @@ static void
CheckDisarm(Widget w,XEvent * event,char ** params,Cardinal * nparams)
{
static XtActionProc check_disarm_action = NULL;
XfeBmCascadePart * bmc = _XfeBmCascadePart(w);
/* XfeBmCascadePart * bmc = _XfeBmCascadePart(w); */
if (!check_disarm_action)
{
@ -536,7 +547,7 @@ static void
DelayedArm(Widget w,XEvent * event,char ** params,Cardinal * nparams)
{
static XtActionProc delayed_arm_action = NULL;
XfeBmCascadePart * bmc = _XfeBmCascadePart(w);
/* XfeBmCascadePart * bmc = _XfeBmCascadePart(w); */
if (!delayed_arm_action)
{
@ -608,7 +619,7 @@ DoSelect(Widget w,XEvent * event,char ** params,Cardinal * nparams)
static void
Motion(Widget w,XEvent * event,char ** params,Cardinal * nparams)
{
XfeBmCascadePart * bmc = _XfeBmCascadePart(w);
/* XfeBmCascadePart * bmc = _XfeBmCascadePart(w); */
if (!XfeBmAccentIsEnabled())
{
@ -681,6 +692,7 @@ DrawPixmap(Widget w,XEvent *event,Region region)
}
/*----------------------------------------------------------------------*/
#ifdef notused
static Position
GetPointerY(Widget w)
{
@ -713,6 +725,7 @@ GetPointerY(Widget w)
return 0;
}
/*----------------------------------------------------------------------*/
#endif
static void
AccentUpdate(Widget w,Position y)
{

View File

@ -0,0 +1,155 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
/*----------------------------------------------------------------------*/
/* */
/* Name: <XfeBm/BmGlobal.c> */
/* */
/* Description: Global functions to set/get accent drawing and filing */
/* properties. */
/* */
/* Author: Ramiro Estrugo <ramiro@netscape.com> */
/* */
/*----------------------------------------------------------------------*/
#include <Xfe/XfeBm.h>
/*----------------------------------------------------------------------*/
/* */
/* Accent enabled/disabled functions */
/* */
/*----------------------------------------------------------------------*/
static Boolean _accent_is_enabled = False;
/* extern */ Boolean
XfeBmAccentIsEnabled(void)
{
return _accent_is_enabled;
}
/*----------------------------------------------------------------------*/
/* extern */ void
XfeBmAccentDisable(void)
{
_accent_is_enabled = False;
}
/*----------------------------------------------------------------------*/
/* extern */ void
XfeBmAccentEnable(void)
{
_accent_is_enabled = True;
}
/*----------------------------------------------------------------------*/
/*----------------------------------------------------------------------*/
/* */
/* Global BmButton/BmCascade accent offset values set/get functions */
/* */
/*----------------------------------------------------------------------*/
static Dimension _accent_offset_left = 4;
static Dimension _accent_offset_right = 8;
static Dimension _accent_shadow_thickness = 1;
static Dimension _accent_thickness = 1;
/* extern */ void
XfeBmAccentSetOffsetLeft(Dimension offset_left)
{
_accent_offset_left = offset_left;
}
/*----------------------------------------------------------------------*/
/* extern */ void
XfeBmAccentSetOffsetRight(Dimension offset_right)
{
_accent_offset_right = offset_right;
}
/*----------------------------------------------------------------------*/
/* extern */ void
XfeBmAccentSetShadowThickness(Dimension shadow_thickness)
{
_accent_shadow_thickness = shadow_thickness;
}
/*----------------------------------------------------------------------*/
/* extern */ void
XfeBmAccentSetThickness(Dimension thickness)
{
_accent_thickness = thickness;
}
/*----------------------------------------------------------------------*/
/* extern */ Dimension
XfeBmAccentGetOffsetLeft(void)
{
return _accent_offset_left;
}
/*----------------------------------------------------------------------*/
/* extern */ Dimension
XfeBmAccentGetOffsetRight(void)
{
return _accent_offset_right;
}
/*----------------------------------------------------------------------*/
/* extern */ Dimension
XfeBmAccentGetShadowThickness(void)
{
return _accent_shadow_thickness;
}
/*----------------------------------------------------------------------*/
/* extern */ Dimension
XfeBmAccentGetThickness(void)
{
return _accent_thickness;
}
/*----------------------------------------------------------------------*/
/*----------------------------------------------------------------------*/
/* */
/* Global BmButton/BmCascade accent filing mode. */
/* */
/*----------------------------------------------------------------------*/
static XfeAccentFileMode _accent_file_mode = XmACCENT_FILE_ANYWHERE;
/* extern */ void
XfeBmAccentSetFileMode(XfeAccentFileMode file_mode)
{
_accent_file_mode = file_mode;
}
/*----------------------------------------------------------------------*/
/* extern */ XfeAccentFileMode
XfeBmAccentGetFileMode(void)
{
return _accent_file_mode;
}
/*----------------------------------------------------------------------*/
/*----------------------------------------------------------------------*/
/* */
/* Global BmButton/BmCascade pixmap offset values set/get functions */
/* */
/*----------------------------------------------------------------------*/
static Dimension _pixmap_offset = 4;
/* extern */ void
XfeBmPixmapSetOffset(Dimension offset)
{
_pixmap_offset = offset;
}
/*----------------------------------------------------------------------*/
/* extern */ Dimension
XfeBmPixmapGetOffset(void)
{
return _pixmap_offset;
}
/*----------------------------------------------------------------------*/

View File

@ -0,0 +1,49 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
/*----------------------------------------------------------------------*/
/* */
/* Name: <XfeBm/BmRepTyep.c> */
/* Description: Representation type(s) used by BmCascade and BmButton. */
/* Author: Ramiro Estrugo <ramiro@netscape.com> */
/* */
/*----------------------------------------------------------------------*/
#include <Xm/RepType.h>
#include <Xfe/XfeBm.h>
/*----------------------------------------------------------------------*/
static void
RegisterAccentType(void)
{
static String AccentNames[] =
{
"accent_box",
"accent_none",
"accent_underline",
};
XmRepTypeRegister(XmRAccentType,AccentNames,NULL,XtNumber(AccentNames));
}
/*----------------------------------------------------------------------*/
/* extern */ void
XfeBmRegisterRepresentationTypes(void)
{
RegisterAccentType();
}
/*----------------------------------------------------------------------*/

View File

@ -32,8 +32,11 @@ MODULE = XfeWidgets/Xfe
LIBRARY_NAME = XfeBm
CSRCS = \
BmAccent.c \
BmButton.c \
BmCascade.c \
BmGlobal.c \
BmRepType.c \
$(NULL)
REQUIRES =\
@ -45,6 +48,7 @@ EXPORTS = \
BmButtonP.h \
BmCascade.h \
BmCascadeP.h \
XfeBm.h \
$(NULL)
include $(DEPTH)/config/rules.mk

View File

@ -0,0 +1,197 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
/*----------------------------------------------------------------------*/
/* */
/* Name: <Xfe/XfeBm.h> */
/* */
/* Description: Header for BmButton and BmCascade. Widgets subclassed */
/* from XmPushButton and XmCascadeButton. Used in the */
/* Mozilla bookmark filing mechanism. */
/* */
/* Author: Ramiro Estrugo <ramiro@netscape.com> */
/* */
/*----------------------------------------------------------------------*/
#ifndef _XfeXfeBm_h_ /* start XfeBm.h */
#define _XfeXfeBm_h_
#include <Xfe/Xfe.h>
#ifdef __cplusplus /* start C++ */
extern "C" {
#endif
/*----------------------------------------------------------------------*/
/* */
/* Bm Resource Names */
/* */
/*----------------------------------------------------------------------*/
#define XmNaccentType "accentType"
#define XmNarmPixmapMask "armPixmapMask"
#define XmNlabelPixmapMask "labelPixmapMask"
/*----------------------------------------------------------------------*/
/* */
/* Bm Class Names */
/* */
/*----------------------------------------------------------------------*/
#define XmCAccentType "AccentType"
#define XmCArmPixmapMask "ArmPixmapMask"
#define XmCLabelPixmapMask "LabelPixmapMask"
/*----------------------------------------------------------------------*/
/* */
/* Bm Representation Types */
/* */
/*----------------------------------------------------------------------*/
#define XmRAccentType "AccentType"
/*----------------------------------------------------------------------*/
/* */
/* XmRAccentType */
/* */
/*----------------------------------------------------------------------*/
enum
{
XmACCENT_NONE,
XmACCENT_BOTTOM,
XmACCENT_TOP,
XmACCENT_ALL
};
/*----------------------------------------------------------------------*/
/*----------------------------------------------------------------------*/
/* */
/* Accent filing mode */
/* */
/*----------------------------------------------------------------------*/
typedef enum
{
XmACCENT_FILE_ANYWHERE,
XmACCENT_FILE_SELF
} XfeAccentFileMode;
/*----------------------------------------------------------------------*/
/*----------------------------------------------------------------------*/
/* */
/* Bm Representation types */
/* */
/*----------------------------------------------------------------------*/
extern void
XfeBmRegisterRepresentationTypes (void);
/*----------------------------------------------------------------------*/
/*----------------------------------------------------------------------*/
/* */
/* Accent enabled/disabled functions */
/* */
/*----------------------------------------------------------------------*/
extern void
XfeBmAccentDisable (void);
/*----------------------------------------------------------------------*/
extern void
XfeBmAccentEnable (void);
/*----------------------------------------------------------------------*/
extern Boolean
XfeBmAccentIsEnabled (void);
/*----------------------------------------------------------------------*/
/*----------------------------------------------------------------------*/
/* */
/* Global BmButton/BmCascade accent offset values set/get functions */
/* */
/*----------------------------------------------------------------------*/
extern void
XfeBmAccentSetOffsetLeft (Dimension offset_left);
/*----------------------------------------------------------------------*/
extern void
XfeBmAccentSetOffsetRight (Dimension offset_right);
/*----------------------------------------------------------------------*/
extern void
XfeBmAccentSetShadowThickness (Dimension shadow_thickness);
/*----------------------------------------------------------------------*/
extern void
XfeBmAccentSetThickness (Dimension thickness);
/*----------------------------------------------------------------------*/
extern Dimension
XfeBmAccentGetOffsetLeft (void);
/*----------------------------------------------------------------------*/
extern Dimension
XfeBmAccentGetOffsetRight (void);
/*----------------------------------------------------------------------*/
extern Dimension
XfeBmAccentGetShadowThickness (void);
/*----------------------------------------------------------------------*/
extern Dimension
XfeBmAccentGetThickness (void);
/*----------------------------------------------------------------------*/
/*----------------------------------------------------------------------*/
/* */
/* Global BmButton/BmCascade accent filing mode. */
/* */
/*----------------------------------------------------------------------*/
extern void
XfeBmAccentSetFileMode (XfeAccentFileMode file_mode);
/*----------------------------------------------------------------------*/
extern XfeAccentFileMode
XfeBmAccentGetFileMode (void);
/*----------------------------------------------------------------------*/
/*----------------------------------------------------------------------*/
/* */
/* Global BmButton/BmCascade pixmap offset values set/get functions */
/* */
/*----------------------------------------------------------------------*/
extern void
XfeBmPixmapSetOffset (Dimension offset_lefft);
/*----------------------------------------------------------------------*/
extern Dimension
XfeBmPixmapGetOffset (void);
/*----------------------------------------------------------------------*/
/*----------------------------------------------------------------------*/
/* */
/* Public accent drawing functions. */
/* */
/*----------------------------------------------------------------------*/
extern void
XfeMenuItemDrawAccent (Widget item,
unsigned char accent_type,
Dimension offset_left,
Dimension offset_right,
Dimension shadow_thickness,
Dimension accent_thickness);
/*----------------------------------------------------------------------*/
extern void
XfeMenuItemEraseAccent (Widget item,
unsigned char accent_type,
Dimension offset_left,
Dimension offset_right,
Dimension shadow_thickness,
Dimension accent_thickness);
/*----------------------------------------------------------------------*/
#ifdef __cplusplus /* end C++ */
}
#endif
#endif /* end XfeBm.h */