Back to index

im-sdk  12.3.91
guiIMStsArea.c
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 #include "xiiimp.h"
00043 #include "guiIMSts.h"
00044 #include "XimpIm.h"
00045 
00046 /* ChangeStatus Methods */
00047 static void
00048 create(XicCommon ic, XPointer call_data) {
00049   StatusWin status = (StatusWin)(ic->gui_icpart->status);
00050   XWindowAttributes attr;
00051 
00052   if (!(ic->ximp_icpart->value_mask & XIMP_CLIENT_WIN)) return;
00053 
00054   if (!status) {
00055     SetupStatusExt(ic);
00056     status = (StatusWin)(ic->gui_icpart->status);
00057   }
00058 
00059   if (status->parent != 0) {
00060     /* status window is already created  */
00061     return;
00062   }
00063   if (XGetWindowAttributes(ic->core.im->core.display, 
00064                         ic->core.client_window,
00065                         &attr) > 0) {
00066     if (attr.map_state == IsUnmapped) {
00067       /* not yet ready to create status window */
00068       return;
00069     }
00070     SetupStatusWindow(ic, ic->core.client_window);
00071   }
00072   return;
00073 }
00074 
00075 static void
00076 set_window(XicCommon ic, XPointer call_data) {
00077   StatusWin status = (StatusWin)(ic->gui_icpart->status);
00078   CacheRec *status_cache;
00079 
00080   if (!XIMP_CHK_STSAREAMASK(ic) ||
00081       ic->core.status_attr.area.width == 0 ||
00082       ic->core.status_attr.area.height == 0)
00083     return;
00084 
00085   if (!status) {
00086     create(ic, NULL);
00087     status = (StatusWin)(ic->gui_icpart->status);
00088     if (!status) return;
00089   }
00090 
00091   status_cache = (CacheRec*)&(status->status_cache);
00092 
00093   if (status_cache->win_x == ic->core.status_attr.area.x &&
00094       status_cache->win_y == ic->core.status_attr.area.y &&
00095       status_cache->win_width == ic->core.status_attr.area.width &&
00096       status_cache->win_height == ic->core.status_attr.area.height &&
00097       status_cache->font_set == status->fontset) {
00098     return;
00099   }
00100       
00101   status->x = 0;
00102 
00103   if (!status->fontset) {
00104     SetStatusFont(ic, NULL);
00105   }
00106   if (status->fontset) {
00107     XFontSetExtents *fse;
00108     int height_diff;
00109     fse = XExtentsOfFontSet(status->fontset);
00110     height_diff =
00111            (ic->core.status_attr.area.height - fse->max_ink_extent.height);
00112     height_diff += (height_diff & 1);
00113     status->y = abs((-fse->max_ink_extent.y) + (height_diff / 2));
00114   } else {
00115     status->y = ic->core.status_attr.area.height;
00116   }
00117 
00118   if (!status->window)
00119     SetupStatusWindow(ic, ic->core.client_window);
00120   if (status->window)
00121     XMoveResizeWindow(ic->core.im->core.display,
00122                     status->window,
00123                     ic->core.status_attr.area.x,
00124                     ic->core.status_attr.area.y,
00125                     ic->core.status_attr.area.width,
00126                     ic->core.status_attr.area.height);
00127   /* data cache */
00128   status_cache->win_x = ic->core.status_attr.area.x;
00129   status_cache->win_y = ic->core.status_attr.area.y;
00130   status_cache->win_width = ic->core.status_attr.area.width;
00131   status_cache->win_height = ic->core.status_attr.area.height;
00132   status_cache->font_set = status->fontset;
00133 
00134   return;
00135 }
00136 
00137 static void
00138 HideStatus(XicCommon ic, XPointer call_data) {
00139   /* nothing to do in StatusArea input style */
00140   return;
00141 }
00142 
00143 static StatusCB status_area_methods[] = {
00144   create,                   /* STATUS_CREATE */
00145   set_window,               /* STATUS_WIN */
00146   SetStatusForeground,             /* STATUS_FG */
00147   SetStatusBackground,             /* STATUS_BG */
00148   SetStatusFont,            /* STATUS_FONT */
00149   StatusStart,                     /* STATUS_START */
00150   StatusDrawText,           /* STATUS_DRAW */
00151   StatusDone,               /* STATUS_DONE */
00152   DestroyStatus,            /* STATUS_DESTROY */
00153   HideStatus                /* STATUS_HIDE */
00154 };
00155 
00156 /* Public function */
00157 void
00158 ChangeStatusArea(XIC xic, StatusAttr reason, XPointer call_data) {
00159   XicCommon ic = (XicCommon)xic;
00160   if (reason > STATUS_HIDE) return;
00161   status_area_methods[reason](ic, call_data);
00162   return;
00163 }
00164