Back to index

im-sdk  12.3.91
ResourceDB.cpp
Go to the documentation of this file.
00001 /*
00002 Copyright 1990-2001 Sun Microsystems, Inc. All Rights Reserved.
00003 
00004 Permission is hereby granted, free of charge, to any person obtaining a
00005 copy of this software and associated documentation files (the
00006 "Software"), to deal in the Software without restriction, including
00007 without limitation the rights to use, copy, modify, merge, publish,
00008 distribute, sublicense, and/or sell copies of the Software, and to
00009 permit persons to whom the Software is furnished to do so, subject to
00010 the following conditions: The above copyright notice and this
00011 permission notice shall be included in all copies or substantial
00012 portions of the Software.
00013 
00014 
00015 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
00016 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00017 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
00018 IN NO EVENT SHALL THE OPEN GROUP OR SUN MICROSYSTEMS, INC. BE LIABLE
00019 FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
00020 CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
00021 THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE EVEN IF
00022 ADVISED IN ADVANCE OF THE POSSIBILITY OF SUCH DAMAGES.
00023 
00024 
00025 Except as contained in this notice, the names of The Open Group and/or
00026 Sun Microsystems, Inc. shall not be used in advertising or otherwise to
00027 promote the sale, use or other dealings in this Software without prior
00028 written authorization from The Open Group and/or Sun Microsystems,
00029 Inc., as applicable.
00030 
00031 
00032 X Window System is a trademark of The Open Group
00033 
00034 OSF/1, OSF/Motif and Motif are registered trademarks, and OSF, the OSF
00035 logo, LBX, X Window System, and Xinerama are trademarks of the Open
00036 Group. All other trademarks and registered trademarks mentioned herein
00037 are the property of their respective owners. No right, title or
00038 interest in or to any trademark, service mark, logo or trade name of
00039 Sun Microsystems, Inc. or its licensors is granted.
00040 
00041 */
00042 
00043 #ifdef HAVE_CONFIG_H
00044 #include <config.h>
00045 #endif
00046 
00047 #include <X11/Intrinsic.h>
00048 #include "ResourceDB.hh"
00049 #include <X11/StringDefs.h>
00050 
00051 static XtResource rdb_items[] = {
00052   /* idx = 0 */
00053   {(char*)"engineModule", (char*)"EngineModule", XtRString, sizeof(char*),
00054    offsetof(RmDatabase, if_name), XtRString, (XPointer)""},
00055   {(char*)"conversionOnKeys", (char*)"ConversionOnKeys", XtRString, sizeof(char*), 
00056    offsetof(RmDatabase, conv_keys), XtRString, (XPointer)"<Ctrl>space <Shift>space Henkan_Mode <Alt>Henkan_Mode"},
00057   {(char*)"portNumber", (char*)"PortNumber", XtRString, sizeof(char*),
00058    offsetof(RmDatabase, port_number), XtRString, (XPointer)"9010"},
00059   {(char*)"staticEventFlow", (char*)"StaticEventFlow", XtRBool, sizeof(Bool),
00060    offsetof(RmDatabase, static_event_flow), XtRString, (XPointer)"false"},
00061 
00062   /* idx = 10 */
00063   {XtNbackground, XtCBackground, XtRPixel, sizeof(unsigned long),
00064    offsetof(RmDatabase, background), XtRString, (XPointer) "white"}, 
00065   {XtNforeground, XtCForeground, XtRPixel, sizeof(unsigned long),
00066    offsetof(RmDatabase, foreground), XtRString, (XPointer) "black"}, 
00067   {(char*)"fontSet", (char*)"FontSet", XtRString, sizeof(char *),
00068    offsetof(RmDatabase, fontset), XtRString, (XPointer) "-*-*-medium-*-*-*-*-*-*-*-*-*-*-*"},
00069 
00070   /* idx = 20 */
00071   {(char*)"rootTitle", (char*)"RootTitle", XtRBool, sizeof(Bool),
00072    offsetof(RmDatabase, has_root_title), XtRString, (XPointer) "true"},
00073   {(char*)"rootTitleName", (char*)"RootTitleName", XtRString, sizeof(char*),
00074    offsetof(RmDatabase, root_title), XtRString, (XPointer) "Input Method Server"},
00075   {(char*)"rootGeometry", (char*)"RootGeometry", XtRString, sizeof(char *),
00076    offsetof(RmDatabase, root_geom), XtRString, (XPointer)"1110x40+10+800"},
00077   {(char*)"rootPlacement", (char*)"RootPlacement", XtRString, sizeof(char *),
00078    offsetof(RmDatabase, root_place), XtRString, (XPointer) "bottom"},
00079   {(char*)"rootPosition", (char*)"RootPosition", XtRString, sizeof(char *),
00080    offsetof(RmDatabase, root_position), XtRString, (XPointer) "client"},
00081   {(char*)"rootLayout", (char*)"RootLayout", XtRString, sizeof(char *),
00082    offsetof(RmDatabase, root_layout), XtRString, (XPointer )"normal"},
00083 
00084   /* idx = 30 */
00085   {(char*)"statusPlacement", (char*)"StatusPlacement", XtRString, sizeof(char *),
00086    offsetof(RmDatabase, status_place), XtRString, (XPointer) "bottom"},
00087   {(char*)"statusPosition", (char*)"StatusPosition", XtRString, sizeof(char *),
00088    offsetof(RmDatabase, status_position), XtRString, (XPointer) "client"},
00089   {(char*)"statusMaxWidth", (char*)"StatusMaxWidth", XtRInt, sizeof(int),
00090    offsetof(RmDatabase, status_max_width), XtRImmediate, (XPointer) 8},
00091   {(char*)"statusDisplay", (char*)"StatusDisplay", XtRString, sizeof(char *),
00092    offsetof(RmDatabase, root_display), XtRString, (XPointer)"ondemand"},
00093   {(char*)"preeditAutoWrap", (char*)"PreeditAutoWrap", XtRString, sizeof(char *),
00094    offsetof(RmDatabase, preedit_move), XtRString, (XPointer)"wrap"},
00095   {(char*)"preeditUseArrow", (char*)"PreeditUseArrow", XtRString, sizeof(char *),
00096    offsetof(RmDatabase, preedit_usearrow), XtRString, (XPointer)"true"},
00097   {(char*)"rootStatusGeometry", (char*)"RootStatusGeometry", XtRString, sizeof(char *),
00098    offsetof(RmDatabase, root_status_geom), XtRString, (XPointer) "100X40+0+0"},
00099 
00100   /* idx = 40 */
00101   {(char*)"lookupLabelType", (char*)"LookupLabelType", XtRString, sizeof(char*),
00102    offsetof(RmDatabase, lookup_label), XtRString, (XPointer)"lower"},
00103   {(char*)"lookupRow", (char*)"LookupRow", XtRInt, sizeof(int),
00104    offsetof(RmDatabase, lookup_rows), XtRImmediate, (XPointer)4},
00105   {(char*)"lookupColumn", (char*)"LookupColumn", XtRInt, sizeof(int),
00106    offsetof(RmDatabase, lookup_columns), XtRImmediate, (XPointer)6},
00107   {(char*)"lookupBackground", (char*)"LookupBackground", XtRString, sizeof(char *),
00108    offsetof(RmDatabase, lookup_bg_str), XtRString, (XPointer)"white"},
00109   {(char*)"lookupForeground", (char*)"LookupForeground", XtRString, sizeof(char *),
00110    offsetof(RmDatabase, lookup_fg_str), XtRString, (XPointer)"black"},
00111   {(char*)"lookupPlacement", (char*)"LookupPlacement", XtRString, sizeof(char *),
00112    offsetof(RmDatabase, lookup_place), XtRString, (XPointer) "bottom"},
00113   {(char*)"lookupPosition", (char*)"LookupPosition", XtRString, sizeof(char *),
00114    offsetof(RmDatabase, lookup_position), XtRString, (XPointer)"client"},
00115   {(char*)"lookupWindowType", (char*)"LookupWindowType", XtRString, sizeof(char *),
00116    offsetof(RmDatabase, lookup_window), XtRString, (XPointer)"popup"},
00117   {(char*)"lookupPolicy", (char*)"LookupPolicy", XtRString, sizeof(char *),
00118    offsetof(RmDatabase, lookup_policy), XtRString, (XPointer)"share"},
00119   {(char*)"lookupTitle", (char*)"LookupTitle", XtRBool, sizeof(Bool), 
00120    offsetof(RmDatabase, has_lookup_title), XtRString, (XPointer)"true"},
00121   {(char*)"lookupTitleName", (char*)"LookupTitleName", XtRString, sizeof(char*), 
00122    offsetof(RmDatabase, lookup_title), XtRString, (XPointer)"SelectionWindow"},
00123   {(char*)"hotkeys", (char*)"Hotkeys", XtRString, sizeof(char*), 
00124    offsetof(RmDatabase, hotkey_string), XtRString, (XPointer)0},
00125 
00126   /* hidden resources  */
00127   {(char*)"modeShellDecoration", (char*)"ModeShellDecoration", XtRBool, sizeof(Bool), 
00128    offsetof(RmDatabase, has_decoration), XtRString, (XPointer)"true"},
00129   {(char*)"usedefaultcolors", (char*)"useDefaultColors", XtRBool, sizeof(Bool),
00130    offsetof(RmDatabase, use_default_colors), XtRString, (XPointer) "false"},
00131 
00132   /* disable status area for IM engines which uses floating AuxPalette */
00133   {(char*)"disableStatusArea", (char*)"DisableStatusArea", XtRBool, sizeof(Bool),
00134    offsetof(RmDatabase, disable_status_area), XtRString, (XPointer) "false"}
00135 };
00136 
00137 ResourceDB::ResourceDB(Widget toplevel) {
00138   XtGetApplicationResources(toplevel, (char*)&rdb,
00139                          rdb_items, XtNumber(rdb_items),
00140                          0, 0);
00141 }
00142 
00143 int
00144 ResourceDB::getValues(IMArg *args, unsigned int n) {
00145   for (IMArg *argp = args; argp < &args[n]; argp++) {
00146     switch (argp->id) {
00147     case RDB_CONV_ON_KEY:
00148       {
00149        char **pp = (char**)argp->value;
00150        *pp = (char *)XtMalloc(strlen(rdb.conv_keys) + 1);
00151        if (!*pp) return RDB_CONV_ON_KEY;
00152        strcpy(*pp, rdb.conv_keys);
00153        break;
00154       }
00155     case RDB_IF_NAME:
00156       {
00157        char **pp = (char**)argp->value;
00158        *pp = (char *)XtMalloc(strlen(rdb.if_name) + 1);
00159        if (!*pp) return RDB_IF_NAME;
00160        strcpy(*pp, rdb.if_name);
00161        break;
00162       }
00163     case RDB_FS_NAME:
00164       {
00165        char **pp = (char**)argp->value;
00166        *pp = (char *)XtMalloc(strlen(rdb.fontset) + 1);
00167        if (!*pp) return RDB_FS_NAME;
00168        strcpy(*pp, rdb.fontset);
00169        break;
00170       }
00171     case RDB_DISABLE_STATUS_AREA:
00172       {
00173        char **pp = (char**)argp->value;
00174        *pp = (char*)rdb.disable_status_area;
00175        break;
00176       }
00177     case RDB_STATIC_EVENT_FLOW:
00178       {
00179        char **pp = (char**)argp->value;
00180        *pp = (char*)rdb.static_event_flow;
00181        break;
00182       }
00183       
00184     default:
00185       break;
00186     }
00187   }
00188   return 0;
00189 }