12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778 |
- /*
- * CDE - Common Desktop Environment
- *
- * Copyright (c) 1993-2012, The Open Group. All rights reserved.
- *
- * These libraries and programs are free software; you can
- * redistribute them and/or modify them under the terms of the GNU
- * Lesser General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option)
- * any later version.
- *
- * These libraries and programs are distributed in the hope that
- * they will be useful, but WITHOUT ANY WARRANTY; without even the
- * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
- * PURPOSE. See the GNU Lesser General Public License for more
- * details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with these libraries and programs; if not, write
- * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
- * Floor, Boston, MA 02110-1301 USA
- */
- /************************************<+>*************************************
- ****************************************************************************
- **
- ** File: Mouse.c
- **
- ** Project: DT 3.0
- **
- ** Description: Controls the Dtstyle Mouse dialog
- **
- **
- ** (c) Copyright Hewlett-Packard Company, 1990.
- **
- **
- **
- ****************************************************************************
- ************************************<+>*************************************/
- /*$XConsortium: Mouse.c /main/5 1996/07/19 13:45:42 pascale $*/
- #include <X11/Xlib.h>
- #include <errno.h>
- #include <Xm/Xm.h>
- #include <Xm/Form.h>
- #include <Xm/Frame.h>
- #include <Xm/LabelG.h>
- #include <Xm/MwmUtil.h>
- #include <Xm/MessageB.h>
- #include <Xm/PushB.h>
- #include <Xm/PushBG.h>
- #include <Xm/RowColumn.h>
- #include <Xm/Scale.h>
- #include <Xm/ToggleBG.h>
- #include <Xm/VendorSEP.h>
- #include <Dt/DialogBox.h>
- #include <Dt/Message.h>
- #include <Dt/SessionM.h>
- #include <Dt/HourGlass.h>
- #include <Dt/UserMsg.h>
- #include <Dt/Wsm.h>
- #include <Dt/Session.h>
- #include "Help.h"
- #include "Main.h"
- #include "SaveRestore.h"
- /*+++++++++++++++++++++++++++++++++++++++*/
- /* include extern functions */
- /*+++++++++++++++++++++++++++++++++++++++*/
- #include "Mouse.h"
- #include "Protocol.h"
- /*+++++++++++++++++++++++++++++++++++++++*/
- /* Local #defines */
- /*+++++++++++++++++++++++++++++++++++++++*/
- #define ACCEL_MIN 0
- #define ACCEL_MAX 10
- #define THRESH_MIN 0
- #define THRESH_MAX 15
- #define THRESHDEFAULT 10
- #define DCLICK_MIN 0
- #define DCLICK_MAX 10
- #define POINTER2B 0
- #define POINTER3B 1
- #define DCLICKDEFAULT 500
- #define RIGHT_HANDED 0
- #define LEFT_HANDED 1
- #define TRANSFER 0
- #define ADJUST 1
- #define LEFTMSG ((char *)GETMESSAGE(9, 1, "Left"))
- #define RIGHTMSG ((char *)GETMESSAGE(9, 2, "Right"))
- #define HANDMSG ((char *)GETMESSAGE(9, 3, "Handedness:"))
- #define MIDDLEMSG ((char *)GETMESSAGE(9, 4, "Button 2:"))
- #define MSG3 ((char *)GETMESSAGE(9, 10, "ERROR: setting pointer mapping\n"))
- #define TRANSMSG ((char *)GETMESSAGE(9, 11, "Transfer"))
- #define ADJMSG ((char *)GETMESSAGE(9, 12, "Adjust"))
- #define WARN_MSG ((char *)GETMESSAGE(9, 13, "The right and left mouse buttons will swap\n\
- functions immediately after you click on OK.\n\
- The `Test Double-Click' graphic in the Mouse\n\
- window shows the current handedness by the \n\
- positions of Button 1 and Button 3."))
- #define MID_WARN_MSG_T ((char *)GETMESSAGE(9, 14, "If you click on OK, mouse button 2 will be set\n\
- to `transfer' (drag) at your next session."))
- #define IMMEDIATE_MSG ((char *)GETMESSAGE(9, 15, "The new double-click time will take effect\n\
- as applications are restarted."))
- #define LATER_MSG ((char *)GETMESSAGE(9, 16, "The new double-click time will take effect\n\
- at your next session."))
- #define MID_WARN_MSG_A ((char *)GETMESSAGE(9, 19, "If you click on OK, mouse button 2 will be set\n\
- to `adjust' at your next session. Button 2 may\n\
- be used to adjust text and list selections.\n\
- Transfer actions (drag) on text and lists will\n\
- require the use of Button 1."))
- #define MENUMSG ((char *)GETMESSAGE(9, 20, "Menu"))
- #define B2 "Dtms2B.bm"
- #define B2_REV "Dtms2BR.bm"
- #define B3 "Dtms3B.bm"
- #define B3_REV "Dtms3BR.bm"
- static char *multiClickTimeString = "*multiClickTime:%d\n";
- static char *enableBtn1TransferString = "*enableBtn1Transfer:%s\n";
- static char *mouseString = "Mouse";
- /*+++++++++++++++++++++++++++++++++++++++*/
- /* Internal Functions */
- /*+++++++++++++++++++++++++++++++++++++++*/
- static Widget build_mouseDialog(
- Widget shell) ;
- static void formLayoutCB(
- Widget w,
- XtPointer client_data,
- XtPointer call_data) ;
- static void _DtmapCB_mouseDialog(
- Widget w,
- XtPointer client_data,
- XtPointer call_data) ;
- static int getValue(
- Widget w) ;
- static void valueChangedCB(
- Widget w,
- XtPointer client_data,
- XtPointer call_data) ;
- static void dclickVCCB(
- Widget w,
- XtPointer client_data,
- XtPointer call_data) ;
- static void dclickTestCB(
- Widget w,
- XtPointer client_data,
- XtPointer call_data) ;
- static void reverseToggleCB(
- Widget w,
- XtPointer client_data,
- XtPointer call_data) ;
- static void midreverseToggleCB(
- Widget w,
- XtPointer client_data,
- XtPointer call_data) ;
- static void warnToggleCB(
- Widget w,
- XtPointer client_data,
- XtPointer call_data) ;
- static void midwarnToggleCB(
- Widget w,
- XtPointer client_data,
- XtPointer call_data) ;
- static void cancelWarnCB(
- Widget w,
- XtPointer client_data,
- XtPointer call_data) ;
- static void midcancelWarnCB(
- Widget w,
- XtPointer client_data,
- XtPointer call_data) ;
- static void systemDefaultCB(
- Widget w,
- XtPointer client_data,
- XtPointer call_data) ;
- static void ButtonCB(
- Widget w,
- XtPointer client_data,
- XtPointer call_data) ;
- /*+++++++++++++++++++++++++++++++++++++++*/
- /* Internal Variables */
- /*+++++++++++++++++++++++++++++++++++++++*/
- typedef struct {
- Widget pictFrame;
- Widget pictRC;
- Widget pictButton;
- Widget pictLabel;
- Widget handLabGad;
- Widget rightToggle;
- Widget leftToggle;
- Widget middleLabGad;
- Widget transferToggle;
- Widget adjustToggle;
- Widget systemDefault;
- Widget accelLabGad;
- Widget threshLabGad;
- Widget dclickLabGad;
- Widget accelScale;
- Widget threshScale;
- Widget dclickScale;
- Pixmap pixmap;
- Pixmap b3;
- Pixmap b3_rev;
- Pixmap b2;
- Pixmap b2_rev;
- Pixmap pixmapSel;
- Pixmap b3Sel;
- Pixmap b3_revSel;
- Pixmap b2Sel;
- Pixmap b2_revSel;
- int type;
- int numButtons;
- int accel_numerator;
- int accel_denominator;
- int threshold;
- Boolean dclickChanged;
- Boolean btn2Changed;
- XtIntervalId timeID;
- int mydclick;
- Boolean systemDefaultFlag;
- unsigned char map_return[256];
- unsigned char new_map_return[256];
- Boolean origHanded;
- Boolean handed;
- Boolean function;
- Boolean origFunction;
- } Mouse;
- static Widget warnDialog;
- static Widget midwarnDialog;
- static Mouse mouse;
- static saveRestore save = {FALSE, 0, };
- /*+++++++++++++++++++++++++++++++++++++++*/
- /* popup_mouseBB */
- /*+++++++++++++++++++++++++++++++++++++++*/
- void
- popup_mouseBB( Widget shell )
- {
- if (style.mouseDialog == NULL) {
- _DtTurnOnHourGlass(shell);
- build_mouseDialog(shell);
- mouse.systemDefaultFlag = True;
- mouse.dclickChanged = False;
- mouse.btn2Changed = False;
- XtManageChild(style.mouseDialog);
- _DtTurnOffHourGlass(shell);
- }
- else
- {
- XtManageChild(style.mouseDialog);
- raiseWindow(XtWindow(XtParent(style.mouseDialog)));
- }
- }
- /*+++++++++++++++++++++++++++++++++++++++*/
- /* build__mouseDialog */
- /*+++++++++++++++++++++++++++++++++++++++*/
- static Widget
- build_mouseDialog( Widget shell )
- {
- int i, n;
- Arg args[MAX_ARGS];
- int nmap;
- XmString button_string[NUM_LABELS];
- Widget form;
- int count = 0;
- Widget widget_list[15];
- XmString string;
-
- Dimension MaxLabelWidth1;
- Dimension HandLabelWidth;
- Dimension MiddleLabelWidth;
- Dimension MaxToggleWidth;
- Dimension RightToggleWidth;
- Dimension TransferToggleWidth;
- XrmDatabase database;
- char *str_name;
- char *str_class;
- char **str_type_return;
- XrmValue value_return;
-
- /* check hil device# for 2 or 3 button mouse */
- /* IMPORTANT NOTE: */
- /* X servers will return different values for */
- /* mouse.numButtons in the call below. */
- /* The HP X server will return 5 if a quarted */
- /* threebutton mouse is present and a 3 if a */
- /* quarted two-button mouse is present. The IBM */
- /* does not support a two-button mouse. */
- /* The cod ebelow always loads a three-button */
- /* for IBM/Sun/HP unless a non-quarted two-button */
- /* mouse is present on the HP server. */
- /* When porting this code to a non IBM/Sun/HP */
- /* platform that has or supports a two-button */
- /* mouse the code below may have to be changed to */
- /* take into account the behavior of the new */
- /* server. */
-
- nmap = 256;
- mouse.numButtons = XGetPointerMapping(style.display, mouse.map_return,
- nmap);
- if ( mouse.numButtons == 2 )
- mouse.type = POINTER2B;
- else
- mouse.type = POINTER3B;
- /* choose a bitmap based on button mapping *
- * and number of buttons */
- if(mouse.type == POINTER3B)
- {
- mouse.b3 = XmGetPixmap(style.screen, B3,
- style.secBSCol, style.secTSCol);
- mouse.b3_rev = XmGetPixmap(style.screen, B3_REV,
- style.secBSCol, style.secTSCol);
- mouse.b3Sel = XmGetPixmap(style.screen, B3,
- style.secTSCol, style.secBSCol );
- mouse.b3_revSel = XmGetPixmap(style.screen, B3_REV,
- style.secTSCol, style.secBSCol);
- if(mouse.map_return[0] == 1)
- {
- mouse.pixmap = mouse.b3;
- mouse.pixmapSel = mouse.b3Sel;
- }
- else
- {
- mouse.pixmap = mouse.b3_rev;
- mouse.pixmapSel = mouse.b3_revSel;
- }
- }
- else /* 2 button mouse */
- {
- mouse.b2 = XmGetPixmap(style.screen, B2,
- style.secBSCol, style.secTSCol);
- mouse.b2_rev = XmGetPixmap(style.screen, B2_REV,
- style.secBSCol, style.secTSCol);
- mouse.b2Sel = XmGetPixmap(style.screen, B2,
- style.secTSCol, style.secBSCol);
- mouse.b2_revSel = XmGetPixmap(style.screen, B2_REV,
- style.secTSCol, style.secBSCol);
- if(mouse.map_return[0] == 1)
- {
- mouse.pixmap = mouse.b2;
- mouse.pixmapSel = mouse.b2Sel;
- }
- else
- {
- mouse.pixmap = mouse.b2_rev;
- mouse.pixmapSel = mouse.b2_revSel;
- }
- }
- /*Get the value of doubleclick*/
- mouse.mydclick = XtGetMultiClickTime(style.display);
- if (mouse.mydclick > 0)
- mouse.mydclick = mouse.mydclick/100;
- if (mouse.mydclick < 1)
- mouse.mydclick = 1;
- /*Get the value of the enableBtn1Transfer resource */
- /*from the data base. */
- str_name = "*enableBtn1Transfer";
- str_class = "*EnableBtn1Transfer";
-
- database = XrmGetDatabase(style.display);
- if (!XrmGetResource(database, str_name, str_class, (char **)&str_type_return, &value_return))
- {
- mouse.function = TRANSFER;
- mouse.origFunction = TRANSFER;
- }
- else
- if (strcmp(value_return.addr, "True") == 0)
- {
- mouse.function = ADJUST;
- mouse.origFunction = ADJUST;
- }
- else
- {
- mouse.function = TRANSFER;
- mouse.origFunction = TRANSFER;
- }
-
- /* Set up DialogBoxDialog button labels */
- button_string[0] = CMPSTR((String) _DtOkString);
- button_string[1] = CMPSTR((String) _DtCancelString);
- button_string[2] = CMPSTR((String) _DtHelpString);
- /* Create toplevel DialogBox */
- /* saveRestore
- * Note that save.poscnt has been initialized elsewhere.
- * save.posArgs may contain information from restoreMouse().*/
- XtSetArg(save.posArgs[save.poscnt], XmNbuttonCount, NUM_LABELS);
- save.poscnt++;
- XtSetArg(save.posArgs[save.poscnt], XmNbuttonLabelStrings, button_string);
- save.poscnt++;
- XtSetArg (save.posArgs[save.poscnt], XmNdefaultPosition, False);
- save.poscnt++;
- style.mouseDialog = __DtCreateDialogBoxDialog(shell, mouseString,
- save.posArgs, save.poscnt);
- XtAddCallback(style.mouseDialog, XmNcallback, ButtonCB, NULL);
- XtAddCallback(style.mouseDialog, XmNhelpCallback,
- (XtCallbackProc)HelpRequestCB, (XtPointer)HELP_MOUSE_DIALOG);
- XmStringFree(button_string[0]);
- XmStringFree(button_string[1]);
- XmStringFree(button_string[2]);
- widget_list[0] = _DtDialogBoxGetButton(style.mouseDialog,2);
- n=0;
- XtSetArg(args[n], XmNautoUnmanage, False); n++;
- XtSetArg(args[n], XmNcancelButton, widget_list[0]); n++;
- XtSetValues (style.mouseDialog, args, n);
- n=0;
- XtSetArg(args[n], XmNtitle, ((char *)GETMESSAGE(9, 18, "Style Manager - Mouse"))); n++;
- XtSetArg (args[n], XmNuseAsyncGeometry, True); n++;
- XtSetArg(args[n], XmNmwmFunctions, DIALOG_MWM_FUNC); n++;
- XtSetValues (XtParent(style.mouseDialog), args, n);
- n = 0;
- XtSetArg(args[n], XmNhorizontalSpacing, style.horizontalSpacing); n++;
- XtSetArg(args[n], XmNverticalSpacing, style.verticalSpacing); n++;
- XtSetArg(args[n], XmNallowOverlap, False); n++;
- XtSetArg(args[n], XmNchildType, XmWORK_AREA); n++;
- form = XmCreateForm(style.mouseDialog, "mouseForm", args, n);
- n = 0;
- XtSetArg(args[n], XmNmarginHeight, LB_MARGIN_HEIGHT); n++;
- XtSetArg(args[n], XmNmarginWidth, LB_MARGIN_WIDTH); n++;
- string = CMPSTR(((char *)GETMESSAGE(9, 5, "Default")));
- XtSetArg(args[n], XmNlabelString, string); n++;
- widget_list[count++] =
- mouse.systemDefault= XmCreatePushButtonGadget(form, "systemDefault", args, n);
- XmStringFree(string);
- n = 0;
- XtSetArg(args[n], XmNorientation, XmVERTICAL); n++;
- widget_list[count++] =
- mouse.pictFrame= XmCreateFrame(form, "pictFrame", args, n);
- n = 0;
- XtSetArg(args[n], XmNorientation, XmVERTICAL); n++;
- XtSetArg(args[n], XmNadjustMargin, False); n++;
- XtSetArg(args[n], XmNentryAlignment, XmALIGNMENT_BEGINNING); n++;
- mouse.pictRC = XmCreateRowColumn(mouse.pictFrame, "pictRC", args, n);
- n = 0;
- XtSetArg(args[n], XmNlabelType, XmPIXMAP); n++;
- XtSetArg(args[n], XmNlabelPixmap, mouse.pixmap); n++;
- XtSetArg(args[n], XmNrecomputeSize, False); n++;
- XtSetArg(args[n], XmNmarginWidth, 0); n++;
- XtSetArg(args[n], XmNmarginHeight, 0); n++;
- XtSetArg(args[n], XmNshadowThickness, 0); n++;
- XtSetArg(args[n], XmNmultiClick, XmMULTICLICK_KEEP); n++;
- mouse.pictButton= XmCreatePushButton(mouse.pictRC, "mousePict", args, n);
- n = 0;
- string = CMPSTR ((char *)GETMESSAGE(9, 17, "Test\nDouble-Click"));
- XtSetArg(args[n], XmNlabelString, string); n++;
- mouse.pictLabel= XmCreateLabelGadget(mouse.pictRC, "mouseLabel", args, n);
- XmStringFree(string);
- n = 0;
- XtSetArg(args[n], XmNalignment, XmALIGNMENT_BEGINNING); n++;
- XtSetArg(args[n], XmNmarginHeight, 0); n++;
- string = CMPSTR(HANDMSG);
- XtSetArg(args[n], XmNlabelString, string); n++;
- widget_list[count++] =
- mouse.handLabGad= XmCreateLabelGadget(form,"handLabGad", args, n);
- XmStringFree(string);
- n=0;
- string = CMPSTR(RIGHTMSG);
- XtSetArg(args[n], XmNlabelString, string); n++;
- XtSetArg(args[n], XmNnavigationType, XmTAB_GROUP); n++;
- XtSetArg(args[n], XmNindicatorType, XmONE_OF_MANY); n++;
- XtSetArg(args[n], XmNalignment, XmALIGNMENT_BEGINNING); n++;
- mouse.rightToggle= XmCreateToggleButtonGadget(form,
- "rightToggle", args, n);
- XmStringFree(string);
- n=0;
- string = CMPSTR(LEFTMSG);
- XtSetArg(args[n], XmNlabelString, string); n++;
- XtSetArg(args[n], XmNnavigationType, XmTAB_GROUP); n++;
- XtSetArg(args[n], XmNindicatorType, XmONE_OF_MANY); n++;
- XtSetArg(args[n], XmNalignment, XmALIGNMENT_BEGINNING); n++;
- mouse.leftToggle= XmCreateToggleButtonGadget(form,
- "leftToggle", args, n);
- XmStringFree(string);
- n = 0;
- XtSetArg(args[n], XmNalignment, XmALIGNMENT_BEGINNING); n++;
- XtSetArg(args[n], XmNmarginHeight, 0); n++;
- string = CMPSTR(MIDDLEMSG);
- XtSetArg(args[n], XmNlabelString, string); n++;
- widget_list[count++] =
- mouse.middleLabGad= XmCreateLabelGadget(form,"middleLabGad", args, n);
- XmStringFree(string);
- n=0;
- string = CMPSTR(TRANSMSG);
- XtSetArg(args[n], XmNlabelString, string); n++;
- XtSetArg(args[n], XmNindicatorType, XmONE_OF_MANY); n++;
- XtSetArg(args[n], XmNnavigationType, XmTAB_GROUP); n++;
- XtSetArg(args[n], XmNalignment, XmALIGNMENT_BEGINNING); n++;
- mouse.transferToggle= XmCreateToggleButtonGadget(form,
- "transToggle", args, n);
- XmStringFree(string);
- n=0;
- string = CMPSTR(ADJMSG);
- XtSetArg(args[n], XmNlabelString, string); n++;
- XtSetArg(args[n], XmNnavigationType, XmTAB_GROUP); n++;
- XtSetArg(args[n], XmNindicatorType, XmONE_OF_MANY); n++;
- XtSetArg(args[n], XmNalignment, XmALIGNMENT_BEGINNING); n++;
- mouse.adjustToggle= XmCreateToggleButtonGadget(form,
- "adjToggle", args, n);
- XmStringFree(string);
- n = 0;
- XtSetArg(args[n], XmNalignment, XmALIGNMENT_END); n++;
- XtSetArg(args[n], XmNmarginHeight, 0); n++;
- string = CMPSTR(((char *)GETMESSAGE(9, 6, "Double-Click")));
- XtSetArg(args[n], XmNlabelString, string); n++;
- widget_list[count++] =
- mouse.dclickLabGad= XmCreateLabelGadget(form,"dclickLabGad", args, n);
- XmStringFree(string);
- n = 0;
- XtSetArg(args[n], XmNmaximum, DCLICK_MAX); n++;
- XtSetArg(args[n], XmNminimum, DCLICK_MIN); n++;
- XtSetArg(args[n], XmNorientation, XmHORIZONTAL); n++;
- XtSetArg(args[n], XmNprocessingDirection, XmMAX_ON_RIGHT); n++;
- XtSetArg(args[n], XmNhighlightThickness, SCALE_HIGHLIGHT_THICKNESS); n++;
- XtSetArg(args[n], XmNshowValue, True); n++;
- XtSetArg(args[n], XmNvalue, mouse.mydclick); n++;
- XtSetArg(args[n], XmNdecimalPoints, (short)1); n++;
- widget_list[count++] =
- mouse.dclickScale= XmCreateScale(form,"dclickScale", args, n);
- n = 0;
- XtSetArg(args[n], XmNalignment, XmALIGNMENT_END); n++;
- XtSetArg(args[n], XmNmarginHeight, 0); n++;
- string = CMPSTR(((char *)GETMESSAGE(9, 8, "Acceleration")));
- XtSetArg(args[n], XmNlabelString, string); n++;
- widget_list[count++] =
- mouse.accelLabGad= XmCreateLabelGadget(form,"accelLabGad", args, n);
- XmStringFree(string);
- n = 0;
- XtSetArg(args[n], XmNminimum, ACCEL_MIN); n++;
- XtSetArg(args[n], XmNmaximum, ACCEL_MAX); n++;
- XtSetArg(args[n], XmNorientation, XmHORIZONTAL); n++;
- XtSetArg(args[n], XmNprocessingDirection, XmMAX_ON_RIGHT); n++;
- XtSetArg(args[n], XmNhighlightThickness, SCALE_HIGHLIGHT_THICKNESS); n++;
- XtSetArg(args[n], XmNshowValue, True); n++;
- widget_list[count++] =
- mouse.accelScale= XmCreateScale(form,"accelScale", args, n);
- n = 0;
- XtSetArg(args[n], XmNalignment, XmALIGNMENT_END); n++;
- XtSetArg(args[n], XmNmarginHeight, 0); n++;
- string = CMPSTR(((char *)GETMESSAGE(9, 9, "Threshold")));
- XtSetArg(args[n], XmNlabelString, string); n++;
- widget_list[count++] =
- mouse.threshLabGad= XmCreateLabelGadget(form,"threshLabGad", args, n);
- XmStringFree(string);
- n = 0;
- XtSetArg(args[n], XmNminimum, THRESH_MIN); n++;
- XtSetArg(args[n], XmNmaximum, THRESH_MAX); n++;
- XtSetArg(args[n], XmNorientation, XmHORIZONTAL); n++;
- XtSetArg(args[n], XmNprocessingDirection, XmMAX_ON_RIGHT); n++;
- XtSetArg(args[n], XmNhighlightThickness, SCALE_HIGHLIGHT_THICKNESS); n++;
- XtSetArg(args[n], XmNshowValue, True); n++;
- widget_list[count++] =
- mouse.threshScale= XmCreateScale(form,"threshScale", args, n);
- XtAddCallback(style.mouseDialog, XmNmapCallback, formLayoutCB, NULL);
- XtAddCallback(style.mouseDialog, XmNmapCallback, _DtmapCB_mouseDialog, shell);
- XtAddCallback(mouse.systemDefault, XmNactivateCallback,
- systemDefaultCB, NULL);
-
- /* calculate the max width for toggles for the overall alignment */
- /* Set labels to max label width */
- MaxLabelWidth1 = HandLabelWidth = XtWidth(mouse.handLabGad);
- MiddleLabelWidth = XtWidth(mouse.middleLabGad);
- if (MiddleLabelWidth > MaxLabelWidth1)
- {
- MaxLabelWidth1 = MiddleLabelWidth;
- }
-
- MaxToggleWidth = RightToggleWidth = XtWidth(mouse.rightToggle);
- TransferToggleWidth = XtWidth(mouse.transferToggle);
- if (TransferToggleWidth > MaxToggleWidth)
- {
- MaxToggleWidth = TransferToggleWidth;
- }
-
- if (mouse.function == TRANSFER)
- {
- XmToggleButtonGadgetSetState(mouse.transferToggle, True, True);
- XmToggleButtonGadgetSetState(mouse.adjustToggle, False, False);
- }
- else
- {
- XmToggleButtonGadgetSetState(mouse.adjustToggle, True, True);
- XmToggleButtonGadgetSetState(mouse.transferToggle, False, False);
- }
- XtVaSetValues(mouse.handLabGad, XmNwidth, MaxLabelWidth1, NULL);
- XtVaSetValues(mouse.middleLabGad, XmNwidth, MaxLabelWidth1, NULL);
- XtVaSetValues(mouse.rightToggle, XmNwidth, MaxToggleWidth, NULL);
- XtVaSetValues(mouse.transferToggle, XmNwidth, MaxToggleWidth, NULL);
- XtAddCallback(mouse.rightToggle, XmNvalueChangedCallback,
- warnToggleCB, (XtPointer)RIGHT_HANDED);
- XtAddCallback(mouse.leftToggle, XmNvalueChangedCallback,
- warnToggleCB, (XtPointer)LEFT_HANDED);
- XtAddCallback(mouse.transferToggle, XmNvalueChangedCallback,
- midwarnToggleCB, (XtPointer)TRANSFER);
- XtAddCallback(mouse.adjustToggle, XmNvalueChangedCallback,
- midwarnToggleCB, (XtPointer)ADJUST);
- XtAddCallback(mouse.accelScale, XmNvalueChangedCallback,
- valueChangedCB, NULL);
- XtAddCallback(mouse.threshScale, XmNvalueChangedCallback,
- valueChangedCB, NULL);
- XtAddCallback(mouse.dclickScale, XmNvalueChangedCallback,
- dclickVCCB, (caddr_t)mouse.pictButton);
- XtAddCallback(mouse.pictButton, XmNactivateCallback,
- dclickTestCB, NULL);
- XtManageChild(form);
- XtManageChildren(widget_list,count);
- XtManageChild(mouse.pictRC);
- XtManageChild(mouse.pictButton);
- XtManageChild(mouse.pictLabel);
- XtManageChild(mouse.rightToggle);
- XtManageChild(mouse.leftToggle);
- /*
- * If there are only two mouse buttons then switch the
- * label for the transferToggle to "Menu" and mark it
- * insensitive but checked.
- * Otherwise manage both the transfer and adjust toggles.
- */
- if (mouse.numButtons == 2) {
- n=0;
- string = CMPSTR(MENUMSG);
- XtSetArg(args[n], XmNlabelString, string); n++;
- XtSetValues(mouse.transferToggle, args, n);
- XmStringFree(string);
- XmToggleButtonGadgetSetState(mouse.transferToggle, True, False);
- XtManageChild(mouse.transferToggle);
- } else {
- XtManageChild(mouse.transferToggle);
- XtManageChild(mouse.adjustToggle);
- }
- return(style.mouseDialog);
- }
- /*+++++++++++++++++++++++++++++++++++++++*/
- /* formLayoutCB */
- /*+++++++++++++++++++++++++++++++++++++++*/
- static void
- formLayoutCB(
- Widget w,
- XtPointer client_data,
- XtPointer call_data )
- {
- int n;
- Arg args[MAX_ARGS];
- Dimension MaxLabelWidth;
- Dimension AccelLabelWidth;
- Dimension ThreshLabelWidth;
- Dimension DclickLabelWidth;
- Dimension ScaleHeight;
- Dimension LabelHeight;
- int TopOffset;
- int LeftOffset;
- /* Do the scale and label attachments */
- ScaleHeight = XtHeight(mouse.accelScale);
- MaxLabelWidth = AccelLabelWidth = XtWidth(mouse.accelLabGad);
- LabelHeight = XtHeight(mouse.accelLabGad);
- ThreshLabelWidth = XtWidth(mouse.threshLabGad);
- if (ThreshLabelWidth > MaxLabelWidth)
- {
- MaxLabelWidth = ThreshLabelWidth;
- }
- DclickLabelWidth = XtWidth(mouse.dclickLabGad);
- if (DclickLabelWidth > MaxLabelWidth)
- {
- MaxLabelWidth = DclickLabelWidth;
- }
-
- /* Mouse Picture PushButton */
- n=0;
- XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM); n++;
- XtSetArg(args[n], XmNtopOffset, style.verticalSpacing); n++;
- XtSetArg(args[n], XmNbottomAttachment, XmATTACH_NONE); n++;
- XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++;
- XtSetArg(args[n], XmNleftOffset, style.horizontalSpacing); n++;
- XtSetArg(args[n], XmNrightAttachment, XmATTACH_NONE); n++;
- XtSetValues (mouse.pictFrame, args, n);
-
- /* System Default Button */
- n=0;
- XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM); n++;
- XtSetArg(args[n], XmNtopOffset, style.verticalSpacing); n++;
- XtSetArg(args[n], XmNbottomAttachment, XmATTACH_NONE); n++;
- XtSetArg(args[n], XmNleftAttachment, XmATTACH_NONE); n++;
- XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++;
- XtSetArg(args[n], XmNrightOffset, style.horizontalSpacing); n++;
- XtSetValues (mouse.systemDefault, args, n);
-
-
- /* Handedness Label */
- n=0;
- XtSetArg(args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
- XtSetArg(args[n], XmNtopWidget, mouse.systemDefault); n++;
- XtSetArg(args[n], XmNtopOffset, 4*style.verticalSpacing); n++;
- XtSetArg(args[n], XmNbottomAttachment, XmATTACH_NONE); n++;
- XtSetArg(args[n], XmNleftAttachment, XmATTACH_WIDGET); n++;
- XtSetArg(args[n], XmNleftWidget, mouse.pictFrame); n++;
- XtSetArg(args[n], XmNleftOffset, 2*style.horizontalSpacing); n++;
- XtSetArg(args[n], XmNrightAttachment, XmATTACH_NONE); n++;
- XtSetValues (mouse.handLabGad, args, n);
- /* right toggle */
- n=0;
- XtSetArg(args[n], XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
- XtSetArg(args[n], XmNtopWidget, mouse.handLabGad); n++;
- XtSetArg(args[n], XmNtopOffset, -5); n++;
- XtSetArg(args[n], XmNbottomAttachment, XmATTACH_NONE); n++;
- XtSetArg(args[n], XmNleftAttachment, XmATTACH_WIDGET); n++;
- XtSetArg(args[n], XmNleftWidget, mouse.handLabGad); n++;
- XtSetArg(args[n], XmNleftOffset, style.horizontalSpacing); n++;
- XtSetArg(args[n], XmNrightAttachment, XmATTACH_NONE); n++;
- XtSetValues (mouse.rightToggle, args, n);
-
- /* left toggle */
- n=0;
- XtSetArg(args[n], XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
- XtSetArg(args[n], XmNtopWidget, mouse.handLabGad); n++;
- XtSetArg(args[n], XmNtopOffset, -5); n++;
- XtSetArg(args[n], XmNbottomAttachment, XmATTACH_NONE); n++;
- XtSetArg(args[n], XmNleftAttachment, XmATTACH_WIDGET); n++;
- XtSetArg(args[n], XmNleftWidget, mouse.rightToggle); n++;
- XtSetArg(args[n], XmNleftOffset, style.horizontalSpacing); n++;
- XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++;
- XtSetValues (mouse.leftToggle, args, n);
- /* Middle button Label */
- n=0;
- XtSetArg(args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
- XtSetArg(args[n], XmNtopWidget, mouse.handLabGad); n++;
- XtSetArg(args[n], XmNtopOffset, 3*style.verticalSpacing); n++;
- XtSetArg(args[n], XmNbottomAttachment, XmATTACH_NONE); n++;
- XtSetArg(args[n], XmNleftAttachment, XmATTACH_WIDGET); n++;
- XtSetArg(args[n], XmNleftWidget, mouse.pictFrame); n++;
- XtSetArg(args[n], XmNleftOffset, 2*style.horizontalSpacing); n++;
- XtSetArg(args[n], XmNrightAttachment, XmATTACH_NONE); n++;
- XtSetValues (mouse.middleLabGad, args, n);
- /* transfer toggle */
- n=0;
- XtSetArg(args[n], XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
- XtSetArg(args[n], XmNtopWidget, mouse.middleLabGad); n++;
- XtSetArg(args[n], XmNtopOffset, -5); n++;
- XtSetArg(args[n], XmNbottomAttachment, XmATTACH_NONE); n++;
- XtSetArg(args[n], XmNleftAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
- XtSetArg(args[n], XmNleftWidget, mouse.rightToggle); n++;
- XtSetArg(args[n], XmNleftOffset, 0); n++;
- XtSetArg(args[n], XmNrightAttachment, XmATTACH_NONE); n++;
- XtSetValues (mouse.transferToggle, args, n);
-
- /* adjust toggle */
- n=0;
- XtSetArg(args[n], XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
- XtSetArg(args[n], XmNtopWidget, mouse.middleLabGad); n++;
- XtSetArg(args[n], XmNtopOffset, -5); n++;
- XtSetArg(args[n], XmNbottomAttachment, XmATTACH_NONE); n++;
- XtSetArg(args[n], XmNleftAttachment, XmATTACH_WIDGET); n++;
- XtSetArg(args[n], XmNleftWidget, mouse.transferToggle); n++;
- XtSetArg(args[n], XmNleftOffset, style.horizontalSpacing); n++;
- XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++;
- XtSetValues (mouse.adjustToggle, args, n);
- TopOffset = ScaleHeight + style.verticalSpacing - LabelHeight;
- /* DoubleClick Label */
- n=0;
- XtSetArg(args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
- XtSetArg(args[n], XmNtopWidget, mouse.pictFrame) ; n++;
- XtSetArg(args[n], XmNtopOffset, TopOffset); n++;
- XtSetArg(args[n], XmNbottomAttachment, XmATTACH_NONE); n++;
- XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++;
- LeftOffset = MaxLabelWidth + style.horizontalSpacing - DclickLabelWidth;
- XtSetArg(args[n], XmNleftOffset, LeftOffset); n++;
- XtSetArg(args[n], XmNrightAttachment, XmATTACH_NONE); n++;
- XtSetValues (mouse.dclickLabGad, args, n);
- /* DoubleClick Scale */
- n=0;
- XtSetArg(args[n], XmNtopAttachment, XmATTACH_NONE); n++;
- XtSetArg(args[n], XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
- XtSetArg(args[n], XmNbottomWidget, mouse.dclickLabGad); n++;
- XtSetArg(args[n], XmNbottomOffset, 0); n++;
- XtSetArg(args[n], XmNleftAttachment, XmATTACH_WIDGET); n++;
- XtSetArg(args[n], XmNleftWidget, mouse.dclickLabGad); n++;
- XtSetArg(args[n], XmNleftOffset, 2*style.horizontalSpacing); n++;
- XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++;
- XtSetValues (mouse.dclickScale, args, n);
- /* Acceleration Label */
- n=0;
- XtSetArg(args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
- XtSetArg(args[n], XmNtopWidget, mouse.dclickLabGad); n++;
- XtSetArg(args[n], XmNtopOffset, TopOffset); n++;
- XtSetArg(args[n], XmNbottomAttachment, XmATTACH_NONE); n++;
- XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++;
- LeftOffset = MaxLabelWidth + style.horizontalSpacing - AccelLabelWidth;
- XtSetArg(args[n], XmNleftOffset, LeftOffset); n++;
- XtSetArg(args[n], XmNrightAttachment, XmATTACH_NONE); n++;
- XtSetValues (mouse.accelLabGad, args, n);
- /* Acceleration Scale */
- n=0;
- XtSetArg(args[n], XmNtopAttachment, XmATTACH_NONE); n++;
- XtSetArg(args[n], XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
- XtSetArg(args[n], XmNbottomWidget, mouse.accelLabGad); n++;
- XtSetArg(args[n], XmNbottomOffset, 0); n++;
- XtSetArg(args[n], XmNleftAttachment, XmATTACH_WIDGET); n++;
- XtSetArg(args[n], XmNleftWidget, mouse.accelLabGad); n++;
- XtSetArg(args[n], XmNleftOffset, 2*style.horizontalSpacing); n++;
- XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++;
- XtSetValues (mouse.accelScale, args, n);
- /* Threshold Label */
- n=0;
- XtSetArg(args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
- XtSetArg(args[n], XmNtopWidget, mouse.accelScale); n++;
- XtSetArg(args[n], XmNtopOffset, TopOffset); n++;
- XtSetArg(args[n], XmNbottomAttachment, XmATTACH_FORM); n++;
- XtSetArg(args[n], XmNbottomOffset, style.verticalSpacing); n++;
- XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++;
- LeftOffset = MaxLabelWidth + style.horizontalSpacing - ThreshLabelWidth;
- XtSetArg(args[n], XmNleftOffset, LeftOffset); n++;
- XtSetArg(args[n], XmNrightAttachment, XmATTACH_NONE); n++;
- XtSetValues (mouse.threshLabGad, args, n);
- /* Threshold Scale */
- n=0;
- XtSetArg(args[n], XmNtopAttachment, XmATTACH_NONE); n++;
- XtSetArg(args[n], XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
- XtSetArg(args[n], XmNbottomWidget, mouse.threshLabGad); n++;
- XtSetArg(args[n], XmNbottomOffset, 0); n++;
- XtSetArg(args[n], XmNleftAttachment, XmATTACH_WIDGET); n++;
- XtSetArg(args[n], XmNleftWidget, mouse.threshLabGad); n++;
- XtSetArg(args[n], XmNleftOffset, 2*style.horizontalSpacing); n++;
- XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++;
- XtSetValues (mouse.threshScale, args, n);
- XtRemoveCallback(style.mouseDialog, XmNmapCallback, formLayoutCB, NULL);
- }
- /*+++++++++++++++++++++++++++++++++++++++*/
- /* _DtmapCB_mouseDialog */
- /*+++++++++++++++++++++++++++++++++++++++*/
- static void
- _DtmapCB_mouseDialog(
- Widget w,
- XtPointer client_data,
- XtPointer call_data )
- {
- int n;
- int i;
- int nmap;
- Arg args[MAX_ARGS];
- static int first_time = 1;
- if (first_time)
- {
- DtWsmRemoveWorkspaceFunctions(style.display, XtWindow(XtParent(w)));
- if (!save.restoreFlag)
- putDialog((Widget)client_data, w);
- first_time = 0;
- }
- else
- {
- /* Don't need to do XGetPointerMapping first time dialog
- * is mapped because it is done when dialog is created
- * The type of device will not change between remapping
- */
- nmap = 256;
- mouse.numButtons = XGetPointerMapping(style.display,
- mouse.map_return, nmap);
- }
- /* save mouse mapping values */
- for (i=0; i<mouse.numButtons; i++)
- mouse.new_map_return[i] = mouse.map_return[i];
- /* change Pointer Mapping */
- /* the ReverseToggleCB will set the correct Pixmap */
- if (mouse.map_return[0] == 1) /* right-handed */
- {
- mouse.handed = RIGHT_HANDED;
- mouse.origHanded = RIGHT_HANDED;
- XmToggleButtonGadgetSetState(mouse.rightToggle, True, True);
- XmToggleButtonGadgetSetState(mouse.leftToggle, False, False);
- }
- else /* left-handed */
- {
- mouse.handed = LEFT_HANDED;
- mouse.origHanded = LEFT_HANDED;
- XmToggleButtonGadgetSetState(mouse.leftToggle, True, True);
- XmToggleButtonGadgetSetState(mouse.rightToggle, False, False);
- }
- /* MultiClickTime will not change between remapping */
- XGetPointerControl(style.display, &mouse.accel_numerator,
- &mouse.accel_denominator, &mouse.threshold);
- n=0;
- XtSetArg(args[n], XmNvalue,mouse.accel_numerator); n++;
- XtSetValues(mouse.accelScale, args, n);
- n=0;
- XtSetArg(args[n], XmNvalue,mouse.threshold); n++;
- XtSetValues(mouse.threshScale, args, n);
-
- }
- static int
- getValue(
- Widget w )
- {
- int n, value;
- Arg args[1];
- n=0;
- XtSetArg(args[n], XmNvalue, &value); n++;
- XtGetValues(w, args, n);
- return(value);
- }
- /*+++++++++++++++++++++++++++++++++++++++*/
- /* valueChangedCB */
- /*+++++++++++++++++++++++++++++++++++++++*/
- static void
- valueChangedCB(
- Widget w,
- XtPointer client_data,
- XtPointer call_data )
- {
- int new_acceln, new_acceld, new_thresh;
- /* set mouse parameters to new scale values */
- new_acceld = 1;
- new_acceln = getValue(mouse.accelScale);
- new_thresh = getValue(mouse.threshScale);
- XChangePointerControl(style.display, True, True, new_acceln,
- new_acceld, new_thresh);
- mouse.systemDefaultFlag = False;
- }
- /*+++++++++++++++++++++++++++++++++++++++*/
- /* dclickVCCB */
- /*+++++++++++++++++++++++++++++++++++++++*/
- static void
- dclickVCCB(
- Widget w,
- XtPointer client_data,
- XtPointer call_data )
- {
- XmScaleCallbackStruct *cb = (XmScaleCallbackStruct *) call_data;
- mouse.dclickChanged = True;
- XtSetMultiClickTime (style.display, (cb->value)*100);
- }
- /*+++++++++++++++++++++++++++++++++++++++*/
- /* dclickTestCB */
- /*+++++++++++++++++++++++++++++++++++++++*/
- static void
- dclickTestCB(
- Widget w,
- XtPointer client_data,
- XtPointer call_data )
- {
- Arg color[3], args[10]; /* arg list */
- int n; /* arg count */
- XmPushButtonCallbackStruct *cb = (XmPushButtonCallbackStruct *)call_data;
- static int selectstate = False;
- if (cb->event->xbutton.button == 1)
- {
- if(cb->click_count == 2)
- {
- if (selectstate)
- {
- n=0;
- XtSetArg(color[n], XmNlabelPixmap, mouse.pixmap); n++;
- XtSetValues (w, color, n);
- if (style.useMultiColorIcons)
- {
- n=0;
- XtSetArg(color[n], XmNbackground, style.secBgCol); n++;
- XtSetValues (w, color, n);
- XtSetValues (mouse.pictRC, color, n);
- XtSetValues (mouse.pictLabel, color, n);
- }
- selectstate = False;
- }
- else
- {
- /* This will change the background color to select color,
- but it causes the pixmap to redraw if IT was changed.*/
- n=0;
- XtSetArg(color[n], XmNlabelPixmap, mouse.pixmapSel); n++;
- XtSetValues (w, color, n);
-
- if (style.useMultiColorIcons)
- {
- n=0;
- XtSetArg(color[n], XmNbackground, style.secSelectColor); n++;
- XtSetValues (w, color, n);
- XtSetValues (mouse.pictRC, color, n);
- XtSetValues (mouse.pictLabel, color, n);
- }
- selectstate = True;
- }
- }
- }
- }
- /*+++++++++++++++++++++++++++++++++++++++**/
- /* warnToggleCB - put up a warning dialog */
- /* about changing the handedness. */
- /*+++++++++++++++++++++++++++++++++++++++**/
- static void
- warnToggleCB(
- Widget w,
- XtPointer client_data,
- XtPointer call_data )
- {
-
- int n;
- Arg args[10];
- XmString string;
- Boolean set;
- if (w == mouse.leftToggle && mouse.handed == LEFT_HANDED)
- {
- XmToggleButtonGadgetSetState(mouse.leftToggle, True, False);
- return;
- }
- if (w == mouse.rightToggle && mouse.handed == RIGHT_HANDED)
- {
- XmToggleButtonGadgetSetState(mouse.rightToggle, True, False);
- return;
- }
- if (w == mouse.rightToggle)
- {
- XmToggleButtonGadgetSetState(mouse.leftToggle, False, False);
- }
- else
- {
- XmToggleButtonGadgetSetState(mouse.rightToggle, False, False);
- }
-
- n = 0;
- XtSetArg(args[n], XmNokLabelString, CMPSTR((String) _DtOkString)); n++;
- XtSetArg(args[n], XmNcancelLabelString, CMPSTR((String) _DtCancelString)); n++;
- string = CMPSTR(WARN_MSG);
- XtSetArg(args[n], XmNmessageString, string); n++;
- XtSetArg(args[n], XmNmwmFunctions, DIALOG_MWM_FUNC ); n++;
- XtSetArg(args[n], XmNborderWidth, 3); n++;
- XtSetArg(args[n], XmNdialogStyle, XmDIALOG_SYSTEM_MODAL); n++;
- XtSetArg(args[n], XmNdialogTitle, CMPSTR((char *)GETMESSAGE(2,2, "Notice"))); n++;
- warnDialog = XmCreateInformationDialog(style.shell, "WarnDialog", args, n);
- XmStringFree(string);
- XtUnmanageChild (XmMessageBoxGetChild(warnDialog, XmDIALOG_HELP_BUTTON));
- XtAddCallback(warnDialog, XmNokCallback, reverseToggleCB, client_data);
- XtAddCallback(warnDialog, XmNcancelCallback, cancelWarnCB, client_data);
- XtManageChild(warnDialog);
- }
- /*++++++++++++++++++++++++++++++++++++++++++**/
- /* midwarnToggleCB - put up a warning dialog */
- /* about changing the function of the middle */
- /* button. */
- /*++++++++++++++++++++++++++++++++++++++++++**/
- static void
- midwarnToggleCB(
- Widget w,
- XtPointer client_data,
- XtPointer call_data )
- {
-
- int n;
- Arg args[10];
- XmString warnstring;
- Boolean set;
-
- if (w == mouse.adjustToggle && mouse.function == ADJUST)
- {
- XmToggleButtonGadgetSetState(mouse.adjustToggle, True, False);
- return;
- }
- if (w == mouse.transferToggle && mouse.function == TRANSFER)
- {
- XmToggleButtonGadgetSetState(mouse.transferToggle, True, False);
- return;
- }
- n = 0;
- XtSetArg(args[n], XmNokLabelString, CMPSTR((String) _DtOkString)); n++;
- XtSetArg(args[n], XmNcancelLabelString, CMPSTR((String) _DtCancelString)); n++;
- XtSetArg(args[n], XmNborderWidth, 3); n++;
- XtSetArg(args[n], XmNmwmFunctions, DIALOG_MWM_FUNC ); n++;
- XtSetArg(args[n], XmNdialogStyle, XmDIALOG_FULL_APPLICATION_MODAL); n++;
- XtSetArg(args[n], XmNdialogTitle, CMPSTR((char *)GETMESSAGE(2,2, "Notice"))); n++;
- midwarnDialog = XmCreateInformationDialog(style.shell, "MidWarnDialog", args, n);
-
- XtUnmanageChild (XmMessageBoxGetChild(midwarnDialog, XmDIALOG_HELP_BUTTON));
-
-
- if ((intptr_t)client_data == TRANSFER)
- {
- warnstring = CMPSTR(MID_WARN_MSG_T);
- XtVaSetValues(midwarnDialog, XmNmessageString, warnstring, NULL); n++;
-
- XmToggleButtonGadgetSetState(mouse.adjustToggle, False, False);
- }
- else
- {
- warnstring = CMPSTR(MID_WARN_MSG_A);
- XtVaSetValues(midwarnDialog, XmNmessageString, warnstring, NULL); n++;
-
- XmToggleButtonGadgetSetState(mouse.transferToggle, False, False);
- }
- XmStringFree(warnstring);
-
- XtAddCallback(midwarnDialog, XmNokCallback, midreverseToggleCB,
- client_data);
- XtAddCallback(midwarnDialog, XmNcancelCallback, midcancelWarnCB,
- client_data);
- XtManageChild(midwarnDialog);
- }
- /*+++++++++++++++++++++++++++++++++++++++*/
- /* cancelWarnCB - callback for the */
- /* cancel button of the warnDialog */
- /*+++++++++++++++++++++++++++++++++++++++*/
- static void
- cancelWarnCB(
- Widget w,
- XtPointer client_data,
- XtPointer call_data )
- {
- int n;
- Arg args[10];
- XmString string;
-
- if (mouse.handed == RIGHT_HANDED)
- {
- XmToggleButtonGadgetSetState(mouse.rightToggle, True, False);
- XmToggleButtonGadgetSetState(mouse.leftToggle, False, False);
- }
- else
- {
- XmToggleButtonGadgetSetState(mouse.leftToggle, True, False);
- XmToggleButtonGadgetSetState(mouse.rightToggle, False, False);
- }
- XtDestroyWidget(warnDialog);
- }
- /*+++++++++++++++++++++++++++++++++++++++*/
- /* midcancelWarnCB - callback for the */
- /* cancel button of the midwarnDialog */
- /*+++++++++++++++++++++++++++++++++++++++*/
- static void
- midcancelWarnCB(
- Widget w,
- XtPointer client_data,
- XtPointer call_data )
- {
- int n;
- Arg args[10];
- XmString string;
-
- if (mouse.function == TRANSFER)
- {
- XmToggleButtonGadgetSetState(mouse.transferToggle, True, True);
- XmToggleButtonGadgetSetState(mouse.adjustToggle, False, False);
- }
- else
- {
- XmToggleButtonGadgetSetState(mouse.adjustToggle, True, True);
- XmToggleButtonGadgetSetState(mouse.transferToggle, False, False);
- }
- XtDestroyWidget(midwarnDialog);
- }
- /*+++++++++++++++++++++++++++++++++++++++*/
- /* reverseToggleCB */
- /*+++++++++++++++++++++++++++++++++++++++*/
- static void
- reverseToggleCB(
- Widget w,
- XtPointer client_data,
- XtPointer call_data )
- {
- int n;
- int i, j;
- Arg args[MAX_ARGS];
- Boolean set;
- Boolean toggle;
-
- toggle = (Boolean) (intptr_t) client_data;
-
- if(mouse.type == POINTER3B)
- {
- if (toggle == LEFT_HANDED)
- {
- if (mouse.handed == LEFT_HANDED)
- return;
- mouse.handed = LEFT_HANDED;
- mouse.pixmap = mouse.b3_rev;
- mouse.pixmapSel = mouse.b3_revSel;
- for(i = 0, j = 3; i < 3; i++, j--)
- mouse.new_map_return[i] = j;
- }
- else
- {
- if (mouse.handed == RIGHT_HANDED)
- return;
- mouse.handed = RIGHT_HANDED;
- mouse.pixmap = mouse.b3;
- mouse.pixmapSel = mouse.b3Sel;
- for(i = 0, j = 1; i < 3; i++, j++)
- mouse.new_map_return[i] = j;
- }
- }
- else /* 2B mouse */
- {
- if (toggle == LEFT_HANDED)
- {
- if (mouse.handed == LEFT_HANDED)
- return;
- mouse.handed = LEFT_HANDED;
- mouse.pixmap = mouse.b2_rev;
- mouse.pixmapSel = mouse.b2_revSel;
- for(i = 0, j = 2; i < 2; i++, j--)
- mouse.new_map_return[i] = j;
- }
- else
- {
- if (mouse.handed == RIGHT_HANDED)
- return;
- mouse.handed = RIGHT_HANDED;
- mouse.pixmap = mouse.b2;
- mouse.pixmapSel = mouse.b2Sel;
- for(i = 0, j = 1; i < 2; i++, j++)
- mouse.new_map_return[i] = j;
- }
- }
-
- n=0;
- XtSetArg(args[n], XmNlabelPixmap, mouse.pixmap); n++;
- XtSetValues(mouse.pictButton, args, n);
-
- /* change Pointer Mapping */
- if (XSetPointerMapping(style.display, mouse.new_map_return, mouse.numButtons)
- != MappingSuccess)
- _DtSimpleError (progName, DtWarning, NULL, MSG3, NULL);
-
- mouse.systemDefaultFlag = False;
- XtDestroyWidget(warnDialog);
-
- }
- /*+++++++++++++++++++++++++++++++++++++++*/
- /* midreverseToggleCB */
- /*+++++++++++++++++++++++++++++++++++++++*/
- static void
- midreverseToggleCB(
- Widget w,
- XtPointer client_data,
- XtPointer call_data )
- {
- int n;
- int i, j;
- Arg args[MAX_ARGS];
- Boolean set;
- Boolean toggle;
- toggle = (Boolean) (intptr_t) client_data;
- if (toggle == ADJUST)
- {
- if (mouse.function == ADJUST)
- return;
- mouse.function = ADJUST;
- }
- else
- {
- if (mouse.function == TRANSFER)
- return;
- mouse.function = TRANSFER;
- }
- mouse.btn2Changed = True;
- mouse.systemDefaultFlag = False;
-
- XtDestroyWidget(midwarnDialog);
- }
- /*+++++++++++++++++++++++++++++++++++++++*/
- /* systemDefaultCB */
- /*+++++++++++++++++++++++++++++++++++++++*/
- static void
- systemDefaultCB(
- Widget w,
- XtPointer client_data,
- XtPointer call_data )
- {
- int n, i, j;
- Arg args[MAX_ARGS];
- Bool do_accel, do_thresh;
- int new_acceln, new_acceld, new_thresh;
- char dclickRes[40];
-
- /* set default mouse values */
- new_acceld = -1;
- new_acceln = -1;
- new_thresh = THRESHDEFAULT;
- do_accel = 1;
- do_thresh = 1;
- XChangePointerControl(style.display, do_accel, do_thresh, new_acceln,
- new_acceld, new_thresh);
-
- /*get default mouse values for sliders*/
- XGetPointerControl(style.display, &new_acceln, &new_acceld, &new_thresh);
-
- n=0;
- XtSetArg(args[n], XmNvalue,new_acceln); n++;
- XtSetValues(mouse.accelScale, args, n);
-
- n=0;
- XtSetArg(args[n], XmNvalue,new_thresh); n++;
- XtSetValues(mouse.threshScale, args, n);
-
- n=0;
- XtSetArg(args[n], XmNvalue,DCLICKDEFAULT/100); n++;
- XtSetValues(mouse.dclickScale, args, n);
-
- sprintf(dclickRes, multiClickTimeString, DCLICKDEFAULT);
- _DtAddToResource(style.display,dclickRes);
-
- /* change mouse mapping to default */
- if(mouse.type == POINTER3B)
- {
- mouse.pixmap = mouse.b3;
- mouse.pixmapSel = mouse.b3Sel;
- for(i = 0, j = 1; i < 3; i++, j++)
- mouse.new_map_return[i] = j;
- mouse.new_map_return[3] = 4;
- mouse.new_map_return[4] = 5;
- }
- else
- {
- mouse.pixmap = mouse.b2;
- mouse.pixmapSel = mouse.b2Sel;
- for(i = 0, j = 1; i < 2; i++, j++)
- mouse.new_map_return[i] = j;
- }
-
- if (mouse.handed != RIGHT_HANDED)
- {
- /* change Pointer Mapping */
- if(XSetPointerMapping(style.display, mouse.new_map_return,
- mouse.numButtons) != MappingSuccess)
- _DtSimpleError (progName, DtWarning, NULL, MSG3, NULL);
-
- n=0;
- XtSetArg(args[n], XmNlabelPixmap, mouse.pixmap); n++;
- XtSetValues(mouse.pictButton, args, n);
-
-
- mouse.handed = RIGHT_HANDED;
- XmToggleButtonGadgetSetState(mouse.rightToggle, True, True);
- XmToggleButtonGadgetSetState(mouse.leftToggle, False, False);
-
- }
-
- if (mouse.function != TRANSFER)
- {
- mouse.function = TRANSFER;
- mouse.btn2Changed = True;
- XmToggleButtonGadgetSetState(mouse.transferToggle, True, True);
- XmToggleButtonGadgetSetState(mouse.adjustToggle, False, False);
- }
-
- mouse.systemDefaultFlag = True;
- }
- /*+++++++++++++++++++++++++++++++++++++++*/
- /* ButtonCB */
- /* callback for PushButtons in DialogBox */
- /*+++++++++++++++++++++++++++++++++++++++*/
- static void
- ButtonCB(
- Widget w,
- XtPointer client_data,
- XtPointer call_data )
- {
- int n, i, j;
- Arg args[MAX_ARGS];
- DtDialogBoxCallbackStruct *cb = (DtDialogBoxCallbackStruct *) call_data;
- Bool do_accel, do_thresh;
- Bool set;
- char message1[6], message2[50], message3[6], message4[6];
- char pointerStr[128];
- static char dclickRes[40];
- static char enableBtn1Res[40];
- int dclick;
- int new_acceln, new_acceld, new_thresh;
- switch (cb->button_position)
- {
- case OK_BUTTON:
- XtUnmanageChild(w);
- /* if sendSettings is true send data to Session Manager */
- if(style.smState.smSendSettings)
- {
- if (mouse.systemDefaultFlag && !mouse.dclickChanged)
- {
- SmDefaultPointerSettings();
- }
- else /* dclick or one of the sliders changed */
- {
- sprintf(message1,"%d", mouse.numButtons );
- if(mouse.numButtons == 3 || mouse.numButtons == 5)
- sprintf(message2,"%d_%d_%d", mouse.new_map_return[0],
- mouse.new_map_return[1],
- mouse.new_map_return[2]);
- else
- sprintf(message2,"%d_%d_%d_%d_%d", mouse.new_map_return[0],
- mouse.new_map_return[1],
- mouse.new_map_return[2],
- mouse.new_map_return[3],
- mouse.new_map_return[4]);
- sprintf(message3,"%d", getValue(mouse.accelScale));
- sprintf(message4,"%d", getValue(mouse.threshScale));
- sprintf(dclickRes, multiClickTimeString,
- getValue(mouse.dclickScale)*100);
-
- if (mouse.dclickChanged)
- {
- if (style.xrdb.writeXrdbImmediate) {
- InfoDialog(IMMEDIATE_MSG, style.shell, False);
- _DtAddToResource(style.display,dclickRes);
- }
- else
- InfoDialog(LATER_MSG, style.shell, False);
- }
-
- sprintf (pointerStr,"%s %s %s %s %s",
- message1, message2, message3, message4,
- dclickRes );
-
- SmNewPointerSettings (pointerStr);
-
- }
- }
- else
- { /* sendSettings is False. If double click has changed update Xrdb */
-
- if (mouse.dclickChanged)
- {
- InfoDialog(IMMEDIATE_MSG, style.shell, False);
- sprintf(dclickRes, multiClickTimeString,
- getValue(mouse.dclickScale)*100);
- _DtAddToResource(style.display,dclickRes);
- }
- }
- mouse.dclickChanged = False;
- if (mouse.btn2Changed)
- if(mouse.function == TRANSFER)
- sprintf(enableBtn1Res, enableBtn1TransferString, "button2_transfer");
- else
- sprintf(enableBtn1Res, enableBtn1TransferString, "True");
- _DtAddToResource(style.display,enableBtn1Res);
- break;
-
- case CANCEL_BUTTON:
-
- XtUnmanageChild(w);
-
- /* check if values and changePonterControl only if needed */
-
- new_acceln = getValue(mouse.accelScale);
- if (new_acceln != mouse.accel_numerator)
- {
- /* reset to incoming mouse values */
- n=0;
- XtSetArg(args[n], XmNvalue,mouse.accel_numerator); n++;
- XtSetValues(mouse.accelScale, args, n);
- }
- new_thresh = getValue(mouse.threshScale);
- if (new_thresh != mouse.threshold)
- {
- /* reset to incoming mouse values */
- n=0;
- XtSetArg(args[n], XmNvalue,mouse.threshold); n++;
- XtSetValues(mouse.threshScale, args, n);
- }
- n=0;
- XtSetArg(args[n], XmNvalue,mouse.mydclick); n++;
- XtSetValues(mouse.dclickScale, args, n);
- mouse.dclickChanged = False;
- XtSetMultiClickTime(style.display, mouse.mydclick*100);
- if ((new_thresh != mouse.threshold) ||
- (new_acceln != mouse.accel_numerator))
- {
- do_accel = mouse.accel_numerator ? 1:0;
- do_thresh = mouse.threshold ? 1:0;
- XChangePointerControl(style.display, do_accel, do_thresh,
- mouse.accel_numerator, mouse.accel_denominator,
- mouse.threshold);
- }
-
- if (mouse.handed != mouse.origHanded)
- {
- if (XSetPointerMapping(style.display, mouse.map_return,
- mouse.numButtons) != MappingSuccess)
- _DtSimpleError (progName, DtWarning, NULL, MSG3, NULL);
-
- /* load the correct mouse pixmaps */
-
- if(mouse.type == POINTER3B)
- {
- if (mouse.origHanded == LEFT_HANDED)
- {
- mouse.pixmap = mouse.b3_rev;
- mouse.pixmapSel = mouse.b3_revSel;
- }
- else
- {
- if (mouse.origHanded == RIGHT_HANDED)
- {
- mouse.pixmap = mouse.b3;
- mouse.pixmapSel = mouse.b3Sel;
- }
- }
- }
- else /* 2B mouse */
- {
- if (mouse.origHanded == LEFT_HANDED)
- {
- mouse.pixmap = mouse.b2_rev;
- mouse.pixmapSel = mouse.b2_revSel;
- }
- else
- {
- if (mouse.origHanded == RIGHT_HANDED)
- {
- mouse.pixmap = mouse.b2;
- mouse.pixmapSel = mouse.b2Sel;
- }
- }
- }
-
- n=0;
- XtSetArg(args[n], XmNlabelPixmap, mouse.pixmap); n++;
- XtSetValues(mouse.pictButton, args, n);
- }
-
- if (mouse.function != mouse.origFunction)
- {
- mouse.function = mouse.origFunction;
- if (mouse.origFunction == TRANSFER)
- {
- XmToggleButtonGadgetSetState(mouse.transferToggle, True, True);
- XmToggleButtonGadgetSetState(mouse.adjustToggle, False, False);
- }
- else
- {
- XmToggleButtonGadgetSetState(mouse.transferToggle, False, False);
- XmToggleButtonGadgetSetState(mouse.adjustToggle, True, True);
- }
- }
- break;
-
- case HELP_BUTTON:
- XtCallCallbacks(style.mouseDialog, XmNhelpCallback, (XtPointer)NULL);
- break;
-
- default:
- break;
- }
- }
- /************************************************************************
- * restoreMouse()
- *
- * restore any state information saved with saveMouse.
- * This is called from restoreSession with the application
- * shell and the special xrm database retrieved for restore.
- ************************************************************************/
- void
- restoreMouse(
- Widget shell,
- XrmDatabase db )
- {
- XrmName xrm_name[5];
- XrmRepresentation rep_type;
- XrmValue value;
- xrm_name [0] = XrmStringToQuark ("Mouse");
- xrm_name [2] = 0;
- /* get x position */
- xrm_name [1] = XrmStringToQuark ("x");
- if (XrmQGetResource (db, xrm_name, xrm_name, &rep_type, &value)){
- XtSetArg (save.posArgs[save.poscnt], XmNx, atoi((char *)value.addr)); save.poscnt++;
- save.restoreFlag = True;
- }
- /* get y position */
- xrm_name [1] = XrmStringToQuark ("y");
- if (XrmQGetResource (db, xrm_name, xrm_name, &rep_type, &value)){
- XtSetArg (save.posArgs[save.poscnt], XmNy, atoi((char *)value.addr)); save.poscnt++;
- }
- xrm_name [1] = XrmStringToQuark ("ismapped");
- XrmQGetResource (db, xrm_name, xrm_name, &rep_type, &value);
- /* Are we supposed to be mapped? */
- if (strcmp(value.addr, "True") == 0)
- popup_mouseBB(shell);
- }
- /************************************************************************
- * saveMouse()
- *
- * This routine will write out to the passed file descriptor any state
- * information this dialog needs. It is called from saveSessionCB with the
- * file already opened.
- * All information is saved in xrm format. There is no restriction
- * on what can be saved. It doesn't have to be defined or be part of any
- * widget or Xt definition. Just name and save it here and recover it in
- * restoreBackdrop. The suggested minimum is whether you are mapped, and your
- * location.
- ************************************************************************/
- void
- saveMouse(
- int fd )
- {
- Position x,y;
- char bufr[1024]; /* size=[1024], make bigger if needed */
- XmVendorShellExtObject vendorExt;
- XmWidgetExtData extData;
- if (style.mouseDialog != NULL)
- {
- if (XtIsManaged(style.mouseDialog))
- sprintf(bufr, "*Mouse.ismapped: True\n");
- else
- sprintf(bufr, "*Mouse.ismapped: False\n");
- WRITE_STR2FD(fd, bufr);
- /* Get and write out the geometry info for our Window */
- x = XtX(XtParent(style.mouseDialog));
- y = XtY(XtParent(style.mouseDialog));
- /* Modify x & y to take into account window mgr frames
- * This is pretty bogus, but I don't know a better way to do it.
- */
- extData = _XmGetWidgetExtData(style.shell, XmSHELL_EXTENSION);
- vendorExt = (XmVendorShellExtObject)extData->widget;
- x -= vendorExt->vendor.xOffset;
- y -= vendorExt->vendor.yOffset;
- snprintf(bufr, sizeof(bufr), "*Mouse.x: %d\n", x);
- WRITE_STR2FD(fd, bufr);
- snprintf(bufr, sizeof(bufr), "*Mouse.y: %d\n", y);
- WRITE_STR2FD(fd, bufr);
- }
- }
|